mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
v2.0.5
This commit is contained in:
parent
e19f85f081
commit
c863bde54a
@ -3,6 +3,13 @@ History
|
|||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
||||||
|
2.0.5 (2014-06-18)
|
||||||
|
++++++++++++++++++
|
||||||
|
|
||||||
|
- upgrade external wakatime package to v2.0.3
|
||||||
|
- use project name from sublime-project file when no revision control project found
|
||||||
|
|
||||||
|
|
||||||
2.0.4 (2014-06-09)
|
2.0.4 (2014-06-09)
|
||||||
++++++++++++++++++
|
++++++++++++++++++
|
||||||
|
|
||||||
|
21
WakaTime.py
21
WakaTime.py
@ -6,7 +6,7 @@ License: BSD, see LICENSE for more details.
|
|||||||
Website: https://wakatime.com/
|
Website: https://wakatime.com/
|
||||||
==========================================================="""
|
==========================================================="""
|
||||||
|
|
||||||
__version__ = '2.0.4'
|
__version__ = '2.0.5'
|
||||||
|
|
||||||
import sublime
|
import sublime
|
||||||
import sublime_plugin
|
import sublime_plugin
|
||||||
@ -88,15 +88,23 @@ def enough_time_passed(now, last_time):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def find_project_name_from_folders(folders):
|
||||||
|
for folder in folders:
|
||||||
|
for file_name in os.listdir(folder):
|
||||||
|
if file_name.endswith('.sublime-project'):
|
||||||
|
return file_name.replace('.sublime-project', '', 1)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def handle_action(view, is_write=False):
|
def handle_action(view, is_write=False):
|
||||||
global LOCK, LAST_ACTION
|
global LOCK, LAST_ACTION
|
||||||
with LOCK:
|
with LOCK:
|
||||||
target_file = view.file_name()
|
target_file = view.file_name()
|
||||||
if target_file:
|
if target_file:
|
||||||
project = view.window().project_file_name()
|
project = view.window().project_file_name() if hasattr(view.window(), 'project_file_name') else None
|
||||||
if project:
|
if project:
|
||||||
project = basename(project).replace('.sublime-project', '', 1)
|
project = basename(project).replace('.sublime-project', '', 1)
|
||||||
thread = SendActionThread(target_file, is_write=is_write, project=project)
|
thread = SendActionThread(target_file, is_write=is_write, project=project, folders=view.window().folders())
|
||||||
thread.start()
|
thread.start()
|
||||||
LAST_ACTION = {
|
LAST_ACTION = {
|
||||||
'file': target_file,
|
'file': target_file,
|
||||||
@ -107,11 +115,12 @@ def handle_action(view, is_write=False):
|
|||||||
|
|
||||||
class SendActionThread(threading.Thread):
|
class SendActionThread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, target_file, is_write=False, project=None, force=False):
|
def __init__(self, target_file, is_write=False, project=None, folders=None, force=False):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.target_file = target_file
|
self.target_file = target_file
|
||||||
self.is_write = is_write
|
self.is_write = is_write
|
||||||
self.project = project
|
self.project = project
|
||||||
|
self.folders = folders
|
||||||
self.force = force
|
self.force = force
|
||||||
self.debug = SETTINGS.get('debug')
|
self.debug = SETTINGS.get('debug')
|
||||||
self.api_key = SETTINGS.get('api_key', '')
|
self.api_key = SETTINGS.get('api_key', '')
|
||||||
@ -140,6 +149,10 @@ class SendActionThread(threading.Thread):
|
|||||||
cmd.append('--write')
|
cmd.append('--write')
|
||||||
if self.project:
|
if self.project:
|
||||||
cmd.extend(['--project', self.project])
|
cmd.extend(['--project', self.project])
|
||||||
|
elif self.folders:
|
||||||
|
project_name = find_project_name_from_folders(self.folders)
|
||||||
|
if project_name:
|
||||||
|
cmd.extend(['--project', project_name])
|
||||||
for pattern in self.ignore:
|
for pattern in self.ignore:
|
||||||
cmd.extend(['--ignore', pattern])
|
cmd.extend(['--ignore', pattern])
|
||||||
if self.debug:
|
if self.debug:
|
||||||
|
Loading…
Reference in New Issue
Block a user