From da3cf30ddd01f8f5bbcd6ecf0a7ae94ef8836ea9 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Mon, 20 Feb 2017 15:29:44 -0800 Subject: [PATCH] use language as extra heartbeats key name --- .../main_test_timeout_passed_via_command_line | 9 ++++----- tests/samples/output/test_help_contents | 14 ++++++-------- wakatime/arguments.py | 12 ++++++------ wakatime/main.py | 2 +- wakatime/stats.py | 4 ++-- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/tests/samples/output/main_test_timeout_passed_via_command_line b/tests/samples/output/main_test_timeout_passed_via_command_line index 154906a..9de38ab 100644 --- a/tests/samples/output/main_test_timeout_passed_via_command_line +++ b/tests/samples/output/main_test_timeout_passed_via_command_line @@ -2,9 +2,8 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS] [--entity-type ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT] - [--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME] - [--disableoffline] [--hidefilenames] [--exclude EXCLUDE] - [--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE] - [--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG] - [--verbose] [--version] + [--language LANGUAGE] [--hostname HOSTNAME] [--disableoffline] + [--hidefilenames] [--exclude EXCLUDE] [--include INCLUDE] + [--extra-heartbeats] [--logfile LOGFILE] [--apiurl API_URL] + [--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version] wakatime: error: argument --timeout: invalid int value: 'abc' diff --git a/tests/samples/output/test_help_contents b/tests/samples/output/test_help_contents index c4fb4d4..c9b997b 100644 --- a/tests/samples/output/test_help_contents +++ b/tests/samples/output/test_help_contents @@ -2,11 +2,10 @@ usage: wakatime [-h] [--entity FILE] [--key KEY] [--write] [--plugin PLUGIN] [--time time] [--lineno LINENO] [--cursorpos CURSORPOS] [--entity-type ENTITY_TYPE] [--proxy PROXY] [--project PROJECT] [--alternate-project ALTERNATE_PROJECT] - [--language ALTERNATE_LANGUAGE] [--hostname HOSTNAME] - [--disableoffline] [--hidefilenames] [--exclude EXCLUDE] - [--include INCLUDE] [--extra-heartbeats] [--logfile LOGFILE] - [--apiurl API_URL] [--timeout TIMEOUT] [--config CONFIG] - [--verbose] [--version] + [--language LANGUAGE] [--hostname HOSTNAME] [--disableoffline] + [--hidefilenames] [--exclude EXCLUDE] [--include INCLUDE] + [--extra-heartbeats] [--logfile LOGFILE] [--apiurl API_URL] + [--timeout TIMEOUT] [--config CONFIG] [--verbose] [--version] Common interface for the WakaTime api. @@ -35,9 +34,8 @@ optional arguments: --alternate-project ALTERNATE_PROJECT optional alternate project name; auto-discovered project takes priority - --language ALTERNATE_LANGUAGE - optional alternate language name; if valid, takes - priority over auto-detected language + --language LANGUAGE optional language name; if valid, takes priority over + auto-detected language --hostname HOSTNAME hostname of current machine. --disableoffline disables offline time logging instead of queuing logged time diff --git a/wakatime/arguments.py b/wakatime/arguments.py index 36bddad..b6ed963 100644 --- a/wakatime/arguments.py +++ b/wakatime/arguments.py @@ -81,11 +81,11 @@ def parseArguments(): parser.add_argument('--alternate-project', dest='alternate_project', help='optional alternate project name; auto-discovered project '+ 'takes priority') - parser.add_argument('--alternate-language', dest='alternate_language_old', + parser.add_argument('--alternate-language', dest='alternate_language', help=argparse.SUPPRESS) - parser.add_argument('--language', dest='alternate_language', - help='optional alternate language name; if valid, takes priority '+ - 'over auto-detected language') + parser.add_argument('--language', dest='language', + help='optional language name; if valid, takes priority over '+ + 'auto-detected language') parser.add_argument('--hostname', dest='hostname', help='hostname of '+ 'current machine.') parser.add_argument('--disableoffline', dest='offline', @@ -162,8 +162,8 @@ def parseArguments(): else: parser.error('argument --entity is required') - if not args.alternate_language and args.alternate_language_old: - args.alternate_language = args.alternate_language_old + if not args.language and args.alternate_language: + args.language = args.alternate_language if not args.exclude: args.exclude = [] diff --git a/wakatime/main.py b/wakatime/main.py index bd80387..c040b79 100644 --- a/wakatime/main.py +++ b/wakatime/main.py @@ -262,7 +262,7 @@ def process_heartbeat(args, configs, hostname, heartbeat): lineno=heartbeat.get('lineno'), cursorpos=heartbeat.get('cursorpos'), plugin=args.plugin, - alternate_language=heartbeat.get('alternate_language')) + language=heartbeat.get('language')) project = heartbeat.get('project') or heartbeat.get('alternate_project') branch = None diff --git a/wakatime/stats.py b/wakatime/stats.py index 5c0a28d..5107e47 100644 --- a/wakatime/stats.py +++ b/wakatime/stats.py @@ -34,7 +34,7 @@ log = logging.getLogger('WakaTime') def get_file_stats(file_name, entity_type='file', lineno=None, cursorpos=None, - plugin=None, alternate_language=None): + plugin=None, language=None): if entity_type != 'file': stats = { 'language': None, @@ -44,7 +44,7 @@ def get_file_stats(file_name, entity_type='file', lineno=None, cursorpos=None, 'cursorpos': cursorpos, } else: - language = standardize_language(alternate_language, plugin) + language = standardize_language(language, plugin) lexer = get_lexer(language) if not language: