From 094cdbe090a18c35fdcfb463435d793cc0239e83 Mon Sep 17 00:00:00 2001 From: Conley Owens Date: Thu, 30 Jan 2014 15:09:59 -0800 Subject: Add wrapper module This takes the wrapper importing code from main.py and moves it into its own module so that other modules may import it without causing circular imports with main.py. Change-Id: I9402950573933ed6f14ce0bfb600f74f32727705 --- main.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index e4cdeb0f..6ec7158d 100755 --- a/main.py +++ b/main.py @@ -46,6 +46,7 @@ from error import NoSuchProjectError from error import RepoChangedException from manifest_xml import XmlManifest from pager import RunPager +from wrapper import WrapperPath, Wrapper from subcmds import all_commands @@ -169,21 +170,10 @@ class _Repo(object): return result + def _MyRepoPath(): return os.path.dirname(__file__) -def _MyWrapperPath(): - return os.path.join(os.path.dirname(__file__), 'repo') - -_wrapper_module = None -def WrapperModule(): - global _wrapper_module - if not _wrapper_module: - _wrapper_module = imp.load_source('wrapper', _MyWrapperPath()) - return _wrapper_module - -def _CurrentWrapperVersion(): - return WrapperModule().VERSION def _CheckWrapperVersion(ver, repo_path): if not repo_path: @@ -193,7 +183,7 @@ def _CheckWrapperVersion(ver, repo_path): print('no --wrapper-version argument', file=sys.stderr) sys.exit(1) - exp = _CurrentWrapperVersion() + exp = Wrapper().VERSION ver = tuple(map(int, ver.split('.'))) if len(ver) == 1: ver = (0, ver[0]) @@ -205,7 +195,7 @@ def _CheckWrapperVersion(ver, repo_path): !!! You must upgrade before you can continue: !!! cp %s %s -""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) +""" % (exp_str, WrapperPath(), repo_path), file=sys.stderr) sys.exit(1) if exp > ver: @@ -214,7 +204,7 @@ def _CheckWrapperVersion(ver, repo_path): ... You should upgrade soon: cp %s %s -""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) +""" % (exp_str, WrapperPath(), repo_path), file=sys.stderr) def _CheckRepoDir(repo_dir): if not repo_dir: -- cgit v1.2.3-54-g00ecf