second line in .wakatime-project sets branch name

This commit is contained in:
Alan Hamlett 2013-12-13 16:33:09 +01:00
parent f46b0909c2
commit c3642fade2

View file

@ -4,7 +4,8 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Information from a .wakatime-project file about the project for Information from a .wakatime-project file about the project for
a given file. a given file. First line of .wakatime-project sets the project
name. Second line sets the current branch name.
:copyright: (c) 2013 Alan Hamlett. :copyright: (c) 2013 Alan Hamlett.
:license: BSD, see LICENSE for more details. :license: BSD, see LICENSE for more details.
@ -23,20 +24,26 @@ class WakaTime(BaseProject):
def process(self): def process(self):
self.config = self._find_config(self.path) self.config = self._find_config(self.path)
self._project_name = None
self._project_branch = None
if self.config: if self.config:
try:
with open(self.config) as fh:
self._project_name = unicode(fh.readline().strip())
self._project_branch = unicode(fh.readline().strip())
except IOError as e:
log.exception("Exception:")
return True return True
return False return False
def name(self): def name(self):
try: return self._project_name
with open(self.config) as fh:
return unicode(fh.readline().strip())
except IOError as e:
log.exception("Exception:")
return None
def branch(self): def branch(self):
return None return self._project_branch
def _find_config(self, path): def _find_config(self, path):
path = os.path.realpath(path) path = os.path.realpath(path)