From: Dylan Baker Date: Sun, 13 Oct 2013 09:07:36 +0000 (-0700) Subject: catalyst: use a more pythonic method to import modules X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1762a4c10f5e30cc98a32ef45a07f35b87257b55;p=catalyst.git catalyst: use a more pythonic method to import modules Rather than appending a directory to the system path, this patch adds a __init__.py file to modules, which allows python to search it, and it's children for python modules. This also requires changes to a few of the module files to make them happy. Reviewed-by: Matt Turner --- diff --git a/catalyst b/catalyst index 11560fb4..2378a872 100755 --- a/catalyst +++ b/catalyst @@ -11,12 +11,8 @@ import os, sys, imp, string, getopt import pdb import os.path -__selfpath__ = os.path.abspath(os.path.dirname(__file__)) - -sys.path.append(__selfpath__ + "/modules") - -import catalyst.config -import catalyst.util +import modules.catalyst.config +import modules.catalyst.util __maintainer__="Catalyst " __version__="2.0.14" @@ -91,7 +87,7 @@ def parse_config(myconfig): # now, try and parse the config file "config_file" try: # execfile(config_file, myconf, myconf) - myconfig = catalyst.config.ConfigParser(config_file) + myconfig = modules.catalyst.config.ConfigParser(config_file) myconf.update(myconfig.get_values()) except: @@ -226,7 +222,7 @@ def build_target(addlargs, targetmap): mytarget.run() except: - catalyst.util.print_traceback() + modules.catalyst.util.print_traceback() print "!!! catalyst: Error encountered during run of target " + addlargs["target"] sys.exit(1) @@ -379,12 +375,12 @@ if __name__ == "__main__": addlargs={} if myspecfile: - spec = catalyst.config.SpecParser(myspecfile) + spec = modules.catalyst.config.SpecParser(myspecfile) addlargs.update(spec.get_values()) if mycmdline: try: - cmdline = catalyst.config.ConfigParser() + cmdline = modules.catalyst.config.ConfigParser() cmdline.parse_lines(mycmdline) addlargs.update(cmdline.get_values()) except CatalystError: diff --git a/modules/__init__.py b/modules/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/modules/catalyst/config.py b/modules/catalyst/config.py index 00da3439..726bf747 100644 --- a/modules/catalyst/config.py +++ b/modules/catalyst/config.py @@ -1,5 +1,5 @@ import re -from catalyst_support import * +from modules.catalyst_support import * class ParserBase: