From 63c2dc2f1ffb3ec93f8fb6b97b0b909c36ecc0bf Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 31 Aug 2013 10:03:37 -0500 Subject: docstring for prequeue.py --- prequeue.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'prequeue.py') diff --git a/prequeue.py b/prequeue.py index c9a9a8bcc..ec6cd9e39 100644 --- a/prequeue.py +++ b/prequeue.py @@ -1,8 +1,9 @@ # coding: utf-8 - -# Starting a new python process to preprocess each source file -# creates too much overhead. Instead, a list of files to preprocess -# is fed into a script run from a single process. +""" +Starting a new python process to preprocess each source file creates too much +overhead. Instead, a list of files to preprocess is fed into a script run from +a single process. +""" import os import sys -- cgit v1.2.3 From 5815edf382d586e84db8d08612d5f4d1c2e7ac96 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 31 Aug 2013 10:13:17 -0500 Subject: refactor preprocessor macros into a function Remove the "macros" global and instead use a function to construct a list of macros. --- prequeue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'prequeue.py') diff --git a/prequeue.py b/prequeue.py index ec6cd9e39..2c8f4cf5a 100644 --- a/prequeue.py +++ b/prequeue.py @@ -14,4 +14,4 @@ if __name__ == '__main__': dest = os.path.splitext(source)[0] + '.tx' sys.stdin = open(source, 'r') sys.stdout = open(dest, 'w') - preprocessor.preprocess(preprocessor.macros) + preprocessor.preprocess(preprocessor.load_pokecrystal_macros()) -- cgit v1.2.3 From 70be18427b069cae7ffcfb84811ae268fa18afce Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 31 Aug 2013 11:04:27 -0500 Subject: don't call load_pokecrystal_macros 2000 times Also, don't call make_macro_table 2000 times by only calling it once and passing the result. --- prequeue.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'prequeue.py') diff --git a/prequeue.py b/prequeue.py index 2c8f4cf5a..58790f702 100644 --- a/prequeue.py +++ b/prequeue.py @@ -9,9 +9,15 @@ import os import sys import preprocessor -if __name__ == '__main__': +def main(): + macros = preprocessor.load_pokecrystal_macros() + macro_table = preprocessor.make_macro_table(macros) + for source in sys.argv[1:]: dest = os.path.splitext(source)[0] + '.tx' sys.stdin = open(source, 'r') sys.stdout = open(dest, 'w') - preprocessor.preprocess(preprocessor.load_pokecrystal_macros()) + preprocessor.preprocess(macro_table) + +if __name__ == '__main__': + main() -- cgit v1.2.3 From 7eaf5bf72656fa84d2aa94a0ea6e534120f40131 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Sat, 31 Aug 2013 11:07:49 -0500 Subject: reset stdout in prequeue.py near end Other output shouldn't be dumped into items/item_attributes.tx by default. --- prequeue.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'prequeue.py') diff --git a/prequeue.py b/prequeue.py index 58790f702..6efc519d1 100644 --- a/prequeue.py +++ b/prequeue.py @@ -13,11 +13,16 @@ def main(): macros = preprocessor.load_pokecrystal_macros() macro_table = preprocessor.make_macro_table(macros) + stdout = sys.stdout + for source in sys.argv[1:]: dest = os.path.splitext(source)[0] + '.tx' sys.stdin = open(source, 'r') sys.stdout = open(dest, 'w') preprocessor.preprocess(macro_table) + # reset stdout + sys.stdout = stdout + if __name__ == '__main__': main() -- cgit v1.2.3