diff --git a/plugin/packages/wakatime/__about__.py b/plugin/packages/wakatime/__about__.py index d6d7377..5264594 100644 --- a/plugin/packages/wakatime/__about__.py +++ b/plugin/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__ = ('6', '0', '8') +__version_info__ = ('6', '0', '9') __version__ = '.'.join(__version_info__) __author__ = 'Alan Hamlett' __author_email__ = 'alan@wakatime.com' diff --git a/plugin/packages/wakatime/main.py b/plugin/packages/wakatime/main.py index ac0eb81..432f41b 100644 --- a/plugin/packages/wakatime/main.py +++ b/plugin/packages/wakatime/main.py @@ -471,6 +471,17 @@ def sync_offline_heartbeats(args, hostname): return SUCCESS +def format_file_path(filepath): + """Formats a path as absolute and with the correct platform separator.""" + + try: + filepath = os.path.realpath(os.path.abspath(filepath)) + filepath = re.sub(r'[/\\]', os.path.sep, filepath) + except: + pass # pragma: nocover + return filepath + + def process_heartbeat(args, configs, hostname, heartbeat): exclude = should_exclude(heartbeat['entity'], args.include, args.exclude) if exclude is not False: @@ -482,6 +493,9 @@ def process_heartbeat(args, configs, hostname, heartbeat): if heartbeat.get('entity_type') not in ['file', 'domain', 'app']: heartbeat['entity_type'] = 'file' + if heartbeat['entity_type'] == 'file': + heartbeat['entity'] = format_file_path(heartbeat['entity']) + if heartbeat['entity_type'] != 'file' or os.path.isfile(heartbeat['entity']): stats = get_file_stats(heartbeat['entity'], diff --git a/plugin/packages/wakatime/packages/pygments/plugin.py b/plugin/packages/wakatime/packages/pygments/plugin.py index f9ea089..546619a 100644 --- a/plugin/packages/wakatime/packages/pygments/plugin.py +++ b/plugin/packages/wakatime/packages/pygments/plugin.py @@ -37,7 +37,7 @@ """ try: import pkg_resources -except ImportError: +except (ImportError, IOError): pkg_resources = None LEXER_ENTRY_POINT = 'pygments.lexers'