diff --git a/collate_search_data.py b/collate_search_data.py new file mode 100644 index 0000000..f7354c4 --- /dev/null +++ b/collate_search_data.py @@ -0,0 +1,24 @@ +import os, glob, json, codecs + +F_SEARCH = sorted(glob.glob("search_data/*")) + +def load_word_file(f): + with codecs.open(f,'r','utf-8') as FIN: + js = json.loads(FIN.read()) + return js + +for f in F_SEARCH: + js = load_word_file(f) + + try: + js["items"] = [item["full_name"] for item in js["items"]] + except: + print "{} looks to be collated already".format(f) + continue + + with codecs.open(f,'w','utf-8') as FOUT: + FOUT.write(json.dumps(js)) + + print "Completed {}".format(f) + + diff --git a/run_fixer.py b/run_fixer.py index 540bfaf..159fd04 100644 --- a/run_fixer.py +++ b/run_fixer.py @@ -1,4 +1,5 @@ - +import os, glob +from src.word_fix import fix_word ''' def load_word_file(f): diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/word_fix.py b/src/word_fix.py similarity index 99% rename from word_fix.py rename to src/word_fix.py index a46fa26..46a7eeb 100644 --- a/word_fix.py +++ b/src/word_fix.py @@ -4,9 +4,6 @@ logging.basicConfig(level=logging.INFO) logging.getLogger("requests").setLevel(logging.WARNING) -## TO DO: -## LOG AS COMPLETE! - FLAG_fork = True FLAG_delete = True