0

Moved helper function out of overviewer.py and into util.py

Solves a dependency problem where you can't import overviewer unless the extension is built
This commit is contained in:
Andrew Chin
2011-03-24 22:45:26 -04:00
parent 8dc66083e0
commit 172198558a
3 changed files with 22 additions and 18 deletions

18
util.py
View File

@@ -30,3 +30,21 @@ def get_program_path():
return os.path.dirname(__file__)
except NameError:
return os.path.dirname(sys.argv[0])
def findGitVersion():
if os.path.exists(".git"):
with open(os.path.join(".git","HEAD")) as f:
data = f.read().strip()
if data.startswith("ref: "):
with open(os.path.join(".git", data[5:])) as g:
return g.read().strip()
else:
return data
else:
try:
import overviewer_version
return overviewer_version.VERSION
except:
return "unknown"