From 5c46972ebe6c62db1f70e8807851ed8721457681 Mon Sep 17 00:00:00 2001 From: Bryan Bishop Date: Mon, 2 Sep 2013 10:41:50 -0500 Subject: [PATCH] update preprocessor to use a class --- extras | 2 +- preprocessor.py | 10 ++++++---- prequeue.py | 7 +++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extras b/extras index 276111f04..6735813a1 160000 --- a/extras +++ b/extras @@ -1 +1 @@ -Subproject commit 276111f04dcc3e937f1a16f4b7066934409f8ad4 +Subproject commit 6735813a177cecde2a9aa5e961241d8c2419fc2e diff --git a/preprocessor.py b/preprocessor.py index 188db81a6..54fc4cbff 100644 --- a/preprocessor.py +++ b/preprocessor.py @@ -3,6 +3,7 @@ import sys +import extras.pokemontools.config as conf import extras.pokemontools.preprocessor as preprocessor from extras.pokemontools.crystal import ( @@ -41,16 +42,17 @@ def load_pokecrystal_macros(): return ourmacros -def preprocess(macro_table, lines=None): +def preprocess(config, macros, lines=None): """ Entry point for the preprocessor. """ - return preprocessor.preprocess(macro_table, lines=lines) + processor = preprocessor.Preprocessor(config, macros) + return processor.preprocess(lines=lines) def main(): + config = conf.Config() macros = load_pokecrystal_macros() - macro_table = preprocessor.make_macro_table(macros) - preprocess(macro_table) + return preprocess(config, macros) # only run against stdin when not included as a module if __name__ == "__main__": diff --git a/prequeue.py b/prequeue.py index 5c1a9f161..c8b12fd70 100644 --- a/prequeue.py +++ b/prequeue.py @@ -7,11 +7,14 @@ a single process. import os import sys + +import extras.pokemontools.config as conf + import preprocessor def main(): + config = conf.Config() macros = preprocessor.load_pokecrystal_macros() - macro_table = preprocessor.preprocessor.make_macro_table(macros) stdout = sys.stdout @@ -19,7 +22,7 @@ def main(): dest = os.path.splitext(source)[0] + '.tx' sys.stdin = open(source, 'r') sys.stdout = open(dest, 'w') - preprocessor.preprocess(macro_table) + preprocessor.preprocess(config, macros) # reset stdout sys.stdout = stdout