From db9d6cec97321ce4081e5158973334224c3775ca Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Wed, 22 Nov 2017 13:09:17 -0800 Subject: [PATCH] upgrade wakatime-cli to v10.0.3 --- packages/wakatime/__about__.py | 2 +- packages/wakatime/heartbeat.py | 31 +++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/wakatime/__about__.py b/packages/wakatime/__about__.py index 0dcad47..d19d364 100644 --- a/packages/wakatime/__about__.py +++ b/packages/wakatime/__about__.py @@ -1,7 +1,7 @@ __title__ = 'wakatime' __description__ = 'Common interface to the WakaTime api.' __url__ = 'https://github.com/wakatime/wakatime' -__version_info__ = ('10', '0', '2') +__version_info__ = ('10', '0', '3') __version__ = '.'.join(__version_info__) __author__ = 'Alan Hamlett' __author_email__ = 'alan@wakatime.com' diff --git a/packages/wakatime/heartbeat.py b/packages/wakatime/heartbeat.py index 31c5044..c60d188 100644 --- a/packages/wakatime/heartbeat.py +++ b/packages/wakatime/heartbeat.py @@ -141,27 +141,42 @@ class Heartbeat(object): def dict(self): return { 'time': self.time, - 'entity': self.entity, + 'entity': self._unicode(self.entity), 'type': self.type, 'is_write': self.is_write, - 'project': self.project, - 'branch': self.branch, - 'language': self.language, - 'dependencies': self.dependencies, + 'project': self._unicode(self.project), + 'branch': self._unicode(self.branch), + 'language': self._unicode(self.language), + 'dependencies': self._unicode_list(self.dependencies), 'lines': self.lines, 'lineno': self.lineno, 'cursorpos': self.cursorpos, - 'user_agent': self.user_agent, + 'user_agent': self._unicode(self.user_agent), } def items(self): return self.dict().items() def get_id(self): - return u('{h.time}-{h.type}-{h.project}-{h.branch}-{h.entity}-{h.is_write}').format( - h=self, + return u('{time}-{type}-{project}-{branch}-{entity}-{is_write}').format( + time=self.time, + type=self.type, + project=self._unicode(self.project), + branch=self._unicode(self.branch), + entity=self._unicode(self.entity), + is_write=self.is_write, ) + def _unicode(self, value): + if value is None: + return None + return u(value) + + def _unicode_list(self, values): + if values is None: + return None + return [self._unicode(value) for value in values] + def _excluded_by_pattern(self): return should_exclude(self.entity, self.args.include, self.args.exclude)