From: Dylan Baker <baker.dylan.c@gmail.com>
To: gentoo-catalyst@lists.gentoo.org
Cc: Dylan Baker <baker.dylan.c@gmail.com>
Subject: [gentoo-catalyst] [Patch v2 2/4] Catalyst: use a more pythonic method to import modules
Date: Sun, 13 Oct 2013 02:07:36 -0700 [thread overview]
Message-ID: <1381655258-6084-2-git-send-email-baker.dylan.c@gmail.com> (raw)
In-Reply-To: <1381655258-6084-1-git-send-email-baker.dylan.c@gmail.com>
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.
---
catalyst | 16 ++++++----------
modules/__init__.py | 0
modules/catalyst/config.py | 2 +-
3 files changed, 7 insertions(+), 11 deletions(-)
create mode 100644 modules/__init__.py
diff --git a/catalyst b/catalyst
index 11560fb..2378a87 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 <catalyst@gentoo.org>"
__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 0000000..e69de29
diff --git a/modules/catalyst/config.py b/modules/catalyst/config.py
index 00da343..726bf74 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:
--
1.8.1.5
next prev parent reply other threads:[~2013-10-13 9:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-13 9:07 [gentoo-catalyst] [Patch v2 1/4] catalyst: Specify python2 rather than the generic python Dylan Baker
2013-10-13 9:07 ` Dylan Baker [this message]
2013-10-13 9:07 ` [gentoo-catalyst] [Patch v2 3/4] catalyst: split combined import Dylan Baker
2013-10-13 9:07 ` [gentoo-catalyst] [Patch v2 4/4] catalyst: Remove commented sections of code Dylan Baker
2013-10-13 20:15 ` [gentoo-catalyst] [Patch v2 1/4] catalyst: Specify python2 rather than the generic python Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381655258-6084-2-git-send-email-baker.dylan.c@gmail.com \
--to=baker.dylan.c@gmail.com \
--cc=gentoo-catalyst@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox