mirror of
https://github.com/wakatime/sublime-wakatime.git
synced 2023-08-10 21:13:02 +03:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
3127f264b4 | |||
049bc57019 | |||
03ec38bb67 | |||
4fc1a55ff7 | |||
f60815b813 |
12
HISTORY.rst
12
HISTORY.rst
@ -3,6 +3,18 @@ History
|
||||
-------
|
||||
|
||||
|
||||
1.4.12 (2013-11-21)
|
||||
+++++++++++++++++++
|
||||
|
||||
- handle UnicodeDecodeError exceptions when json encoding log messages
|
||||
|
||||
|
||||
1.4.11 (2013-11-13)
|
||||
+++++++++++++++++++
|
||||
|
||||
- placing .wakatime-project file in a folder will read the project's name from that file
|
||||
|
||||
|
||||
1.4.10 (2013-10-31)
|
||||
++++++++++++++++++
|
||||
|
||||
|
@ -5,7 +5,7 @@ Maintainer: WakaTi.me <support@wakatime.com>
|
||||
Website: https://www.wakati.me/
|
||||
==========================================================="""
|
||||
|
||||
__version__ = '1.4.10'
|
||||
__version__ = '1.4.12'
|
||||
|
||||
import sublime
|
||||
import sublime_plugin
|
||||
|
@ -3,6 +3,12 @@ History
|
||||
-------
|
||||
|
||||
|
||||
0.4.10 (2013-11-13)
|
||||
+++++++++++++++++++
|
||||
|
||||
- Placing .wakatime-project file in a folder will read the project's name from that file
|
||||
|
||||
|
||||
0.4.9 (2013-10-27)
|
||||
++++++++++++++++++
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
__title__ = 'wakatime'
|
||||
__version__ = '0.4.9'
|
||||
__version__ = '0.4.10'
|
||||
__author__ = 'Alan Hamlett'
|
||||
__license__ = 'BSD'
|
||||
__copyright__ = 'Copyright 2013 Alan Hamlett'
|
||||
@ -63,6 +63,9 @@ def parseConfigFile(configFile):
|
||||
'verbose': False,
|
||||
}
|
||||
|
||||
if not os.path.isfile(configFile):
|
||||
return configs
|
||||
|
||||
try:
|
||||
with open(configFile) as fh:
|
||||
for line in fh:
|
||||
|
@ -25,7 +25,12 @@ class CustomEncoder(json.JSONEncoder):
|
||||
if isinstance(obj, bytes):
|
||||
obj = bytes.decode(obj)
|
||||
return json.dumps(obj)
|
||||
return super(CustomEncoder, self).default(obj)
|
||||
try:
|
||||
encoded = super(CustomEncoder, self).default(obj)
|
||||
except UnicodeDecodeError:
|
||||
obj = obj.decode('utf-8', 'ignore')
|
||||
encoded = super(CustomEncoder, self).default(obj)
|
||||
return encoded
|
||||
|
||||
|
||||
class JsonFormatter(logging.Formatter):
|
||||
|
@ -12,6 +12,7 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
from .projects.wakatime import WakaTime
|
||||
from .projects.git import Git
|
||||
from .projects.mercurial import Mercurial
|
||||
from .projects.subversion import Subversion
|
||||
@ -20,6 +21,7 @@ from .projects.subversion import Subversion
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
PLUGINS = [
|
||||
WakaTime,
|
||||
Git,
|
||||
Mercurial,
|
||||
Subversion,
|
||||
|
51
packages/wakatime/wakatime/projects/wakatime.py
Normal file
51
packages/wakatime/wakatime/projects/wakatime.py
Normal file
@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
wakatime.projects.wakatime
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Information from a .wakatime-project file about the project for
|
||||
a given file.
|
||||
|
||||
:copyright: (c) 2013 Alan Hamlett.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from .base import BaseProject
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WakaTime(BaseProject):
|
||||
|
||||
def process(self):
|
||||
self.config = self._find_config(self.path)
|
||||
if self.config:
|
||||
return True
|
||||
return False
|
||||
|
||||
def name(self):
|
||||
project_name = None
|
||||
try:
|
||||
with open(self.config) as fh:
|
||||
project_name = fh.readline().strip()
|
||||
except IOError as e:
|
||||
log.exception("Exception:")
|
||||
return project_name
|
||||
|
||||
def branch(self):
|
||||
return None
|
||||
|
||||
def _find_config(self, path):
|
||||
path = os.path.realpath(path)
|
||||
if os.path.isfile(path):
|
||||
path = os.path.split(path)[0]
|
||||
if os.path.isfile(os.path.join(path, '.wakatime-project')):
|
||||
return os.path.join(path, '.wakatime-project')
|
||||
split_path = os.path.split(path)
|
||||
if split_path[1] == '':
|
||||
return None
|
||||
return self._find_config(split_path[0])
|
@ -25,8 +25,9 @@ log = logging.getLogger(__name__)
|
||||
|
||||
# force file name extensions to be recognized as a certain language
|
||||
EXTENSIONS = {
|
||||
'md': 'Markdown',
|
||||
'j2': 'HTML',
|
||||
'markdown': 'Markdown',
|
||||
'md': 'Markdown',
|
||||
}
|
||||
TRANSLATIONS = {
|
||||
'CSS+Genshi Text': 'CSS',
|
||||
|
Reference in New Issue
Block a user