diff --git a/.travis.yml b/.travis.yml index 2316c4bacc..563545ca02 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,5 +26,6 @@ script: - (! find nano/templates/ -type f -exec md5sum {} + | sort | uniq -D -w 32 | grep nano) - (num=`grep -E '\\\\(red|blue|green|black|b|i[^mc])' **/*.dm | wc -l`; [ $num -le 1355 ]) - ( md5sum -c - <<< "0af969f671fba6cf9696c78cd175a14a *baystation12.int") - - DreamMaker baystation12.dme + - python tools/TagMatcher/tag-matcher.py ../.. - python tools/GenerateChangelog/ss13_genchangelog.py html/changelog.html html/changelogs + - DreamMaker baystation12.dme diff --git a/tools/TagMatcher/checkTagMatches.bat b/tools/TagMatcher/checkTagMatches.bat new file mode 100644 index 0000000000..191c30bbba --- /dev/null +++ b/tools/TagMatcher/checkTagMatches.bat @@ -0,0 +1,3 @@ +@echo off +call python tag-matcher.py ../.. +pause diff --git a/tools/TagMatcher/tag-matcher.py b/tools/TagMatcher/tag-matcher.py new file mode 100644 index 0000000000..00f205c6b7 --- /dev/null +++ b/tools/TagMatcher/tag-matcher.py @@ -0,0 +1,40 @@ +import argparse, re, sys +from os import path, walk + +opt = argparse.ArgumentParser() +opt.add_argument('dir', help='The directory to scan for files with non-matching spans') + +args = opt.parse_args() + +if(not path.isdir(args.dir)): + print('Not a directory') + sys.exit(1) + +pair_of_tags = [('','')] +mismatches = { } + +for root, subdirs, files in walk(args.dir): + for filename in files: + if filename.endswith('.dm'): + open_match = 0 + close_match = 0 + file_path = path.join(root, filename) + with open(file_path, 'r') as f: + open_span = re.compile(pair_of_tags[0][0], re.IGNORECASE) + close_span = re.compile(pair_of_tags[0][1], re.IGNORECASE) + for x in f: + open_match += len(open_span.findall(x)) + close_match += len(close_span.findall(x)) + + if open_match != close_match: + if not pair_of_tags[0][0] in mismatches.keys(): + mismatches[pair_of_tags[0][0]] = [] + mismatches[pair_of_tags[0][0]].append('{0} - {1}/{2}'.format(file_path, open_match, close_match)) + +for mismatch_key in mismatches.keys(): + print(mismatch_key) + for mismatch_value in mismatches[mismatch_key]: + print('\t{0}').format(mismatch_value) + +if len(mismatches.keys()) > 0: + sys.exit(1)