Transcode duplicate test to python
This commit is contained in:
parent
470d5a5c08
commit
2da9e2e32c
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
#
|
||||||
|
"""Check the compiled lscolors.sh file for duplicate extensions."""
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
with open("../lscolors.sh", "r") as f:
|
||||||
|
data = next(f)
|
||||||
|
|
||||||
|
extensions = re.findall(r"\*\.(.*?)=", data)
|
||||||
|
|
||||||
|
if duplicates := [ext for ext, count in Counter(extensions) if count > 1]:
|
||||||
|
print(f"Duplicates found: {', '.join(duplicates)}")
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
print("No duplicates found.")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
|
|
||||||
|
# EOF
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
|
|
||||||
exts="$(dircolors LS_COLORS | head -n1 | sed 's/=[^:]*//g ; s/:/\n/g')"
|
|
||||||
exts_sorted="$(sort <<< "$exts")"
|
|
||||||
exts_uniq="$(sort -u <<< "$exts")"
|
|
||||||
|
|
||||||
diff --color=auto --text --report-identical-files <(echo "$exts_uniq") <(echo "$exts_sorted")
|
|
Loading…
Reference in New Issue