summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorConley Owens <cco3@android.com>2014-01-30 15:09:59 -0800
committerConley Owens <cco3@android.com>2014-01-30 15:17:09 -0800
commit094cdbe090a18c35fdcfb463435d793cc0239e83 (patch)
treee664b3febe4d8da1161b9e8e8ecc3a825b42aaa1 /main.py
parent148a84de0ca7f828564f80cbe2bace33f295e65f (diff)
downloadgit-repo-094cdbe090a18c35fdcfb463435d793cc0239e83.tar.gz
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
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py20
1 files changed, 5 insertions, 15 deletions
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
46from error import RepoChangedException 46from error import RepoChangedException
47from manifest_xml import XmlManifest 47from manifest_xml import XmlManifest
48from pager import RunPager 48from pager import RunPager
49from wrapper import WrapperPath, Wrapper
49 50
50from subcmds import all_commands 51from subcmds import all_commands
51 52
@@ -169,21 +170,10 @@ class _Repo(object):
169 170
170 return result 171 return result
171 172
173
172def _MyRepoPath(): 174def _MyRepoPath():
173 return os.path.dirname(__file__) 175 return os.path.dirname(__file__)
174 176
175def _MyWrapperPath():
176 return os.path.join(os.path.dirname(__file__), 'repo')
177
178_wrapper_module = None
179def WrapperModule():
180 global _wrapper_module
181 if not _wrapper_module:
182 _wrapper_module = imp.load_source('wrapper', _MyWrapperPath())
183 return _wrapper_module
184
185def _CurrentWrapperVersion():
186 return WrapperModule().VERSION
187 177
188def _CheckWrapperVersion(ver, repo_path): 178def _CheckWrapperVersion(ver, repo_path):
189 if not repo_path: 179 if not repo_path:
@@ -193,7 +183,7 @@ def _CheckWrapperVersion(ver, repo_path):
193 print('no --wrapper-version argument', file=sys.stderr) 183 print('no --wrapper-version argument', file=sys.stderr)
194 sys.exit(1) 184 sys.exit(1)
195 185
196 exp = _CurrentWrapperVersion() 186 exp = Wrapper().VERSION
197 ver = tuple(map(int, ver.split('.'))) 187 ver = tuple(map(int, ver.split('.')))
198 if len(ver) == 1: 188 if len(ver) == 1:
199 ver = (0, ver[0]) 189 ver = (0, ver[0])
@@ -205,7 +195,7 @@ def _CheckWrapperVersion(ver, repo_path):
205!!! You must upgrade before you can continue: !!! 195!!! You must upgrade before you can continue: !!!
206 196
207 cp %s %s 197 cp %s %s
208""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) 198""" % (exp_str, WrapperPath(), repo_path), file=sys.stderr)
209 sys.exit(1) 199 sys.exit(1)
210 200
211 if exp > ver: 201 if exp > ver:
@@ -214,7 +204,7 @@ def _CheckWrapperVersion(ver, repo_path):
214... You should upgrade soon: 204... You should upgrade soon:
215 205
216 cp %s %s 206 cp %s %s
217""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr) 207""" % (exp_str, WrapperPath(), repo_path), file=sys.stderr)
218 208
219def _CheckRepoDir(repo_dir): 209def _CheckRepoDir(repo_dir):
220 if not repo_dir: 210 if not repo_dir: