Skip to content

Commit 53145ff

Browse files
authored
add github workflow to detect duplicates (#545)
1 parent 13f53f7 commit 53145ff

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.github/workflows/check.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Data check
2+
on:
3+
push:
4+
branches: [master]
5+
jobs:
6+
duplicates:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
- run: |
11+
python duplicates.py

duplicates.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: Zlib
2+
3+
import difflib
4+
import sys
5+
6+
CROSS_PLATFORM=False
7+
8+
cdict = {}
9+
for i, l in enumerate(open("gamecontrollerdb.txt")):
10+
l = l.strip()
11+
if l.startswith("#") or not l:
12+
continue
13+
14+
c = l.split(",")
15+
key = tuple([c[0]]+[ce for ce in c[1:] if "platform:" in ce])
16+
if CROSS_PLATFORM:
17+
key = c[0]
18+
19+
if key in cdict:
20+
print("Duplicate:", c[1], "at line", i + 1)
21+
out = list(difflib.unified_diff(cdict[key], sorted(c), n=0))[3:]
22+
out = [o for o in out if not o.startswith("@@")]
23+
print("\t", " ".join(out))
24+
if not CROSS_PLATFORM:
25+
sys.exit(1)
26+
cdict[key] = sorted(c)

0 commit comments

Comments
 (0)