Skip to content

Commit

Permalink
add github workflow to detect duplicates (mdqinc#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj authored Jan 30, 2022
1 parent 13f53f7 commit 53145ff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Data check
on:
push:
branches: [master]
jobs:
duplicates:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: |
python duplicates.py
26 changes: 26 additions & 0 deletions duplicates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: Zlib

import difflib
import sys

CROSS_PLATFORM=False

cdict = {}
for i, l in enumerate(open("gamecontrollerdb.txt")):
l = l.strip()
if l.startswith("#") or not l:
continue

c = l.split(",")
key = tuple([c[0]]+[ce for ce in c[1:] if "platform:" in ce])
if CROSS_PLATFORM:
key = c[0]

if key in cdict:
print("Duplicate:", c[1], "at line", i + 1)
out = list(difflib.unified_diff(cdict[key], sorted(c), n=0))[3:]
out = [o for o in out if not o.startswith("@@")]
print("\t", " ".join(out))
if not CROSS_PLATFORM:
sys.exit(1)
cdict[key] = sorted(c)

0 comments on commit 53145ff

Please sign in to comment.