diff --git a/documents/troggle-tables.jpg b/documents/troggle-tables.jpg new file mode 100644 index 000000000..e06f63915 Binary files /dev/null and b/documents/troggle-tables.jpg differ diff --git a/scripts/detect-filename-clashes.py b/scripts/detect-filename-clashes.py new file mode 100644 index 000000000..5794537f5 --- /dev/null +++ b/scripts/detect-filename-clashes.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +""" +Recursively checks that no filenames from the current working directory +down are the same, even if they are in different subdirectories. Exits +with status 0 if no matching filenames are found, or 1 if a match is +found. + +2020-03-25 PMS Copied originally from https://gist.github.com/seanh/229455 +Modified to lowercase everything before checking, to detect clashes caused +by capitalisation, and to capture full path for all clashing files +""" +import sys,os +print "Checking for filename clashes...", + +def sortSecond(val): + return val[1] + +allfilenames = [] +detect = [] +clashes = [] +report = [] +for root, dirs, files in os.walk('.'): + if root.startswith('./.git'): + # Ignore .git directory. + continue + if root.startswith('./.hg'): + # Ignore mercurial directory. + continue + for filename in files: + if filename.endswith('~'): + # Ignore automatically created backup files. + continue + if os.path.islink(os.path.join(root,filename)): + # Don't count symlinks as filename clashes. + continue + allfilenames.append((root,filename)) + if filename.lower() in detect: + clashes.append(filename.lower()) + else: + detect.append(filename.lower()) + +print len(allfilenames), 'files found...', +if clashes == []: + print 'OK' + sys.exit(0) +else: + print len(clashes)," clash(es) found." + for r,f in allfilenames: + if f in clashes: + report.append((r,f)) + # sorts the array in descending according to + # second element: the clashing filename + report.sort(key = sortSecond) + for r,f in report: + print os.path.join(r,f) + print len(clashes)," clash(es) found." + sys.exit(1) \ No newline at end of file