upgrade wakatime cli to v4.1.8
This commit is contained in:
parent
16bbe21be9
commit
192a5c7aa7
28 changed files with 423 additions and 318 deletions
|
@ -11,6 +11,8 @@
|
|||
|
||||
import logging
|
||||
|
||||
from ..exceptions import NotYetImplemented
|
||||
|
||||
|
||||
log = logging.getLogger('WakaTime')
|
||||
|
||||
|
@ -25,29 +27,19 @@ class BaseProject(object):
|
|||
self.path = path
|
||||
self._configs = configs
|
||||
|
||||
def project_type(self):
|
||||
""" Returns None if this is the base class.
|
||||
Returns the type of project if this is a
|
||||
valid project.
|
||||
"""
|
||||
project_type = self.__class__.__name__.lower()
|
||||
if project_type == 'baseproject':
|
||||
project_type = None
|
||||
return project_type
|
||||
|
||||
def process(self):
|
||||
""" Processes self.path into a project and
|
||||
returns True if project is valid, otherwise
|
||||
returns False.
|
||||
"""
|
||||
return False
|
||||
raise NotYetImplemented()
|
||||
|
||||
def name(self):
|
||||
""" Returns the project's name.
|
||||
"""
|
||||
return None
|
||||
raise NotYetImplemented()
|
||||
|
||||
def branch(self):
|
||||
""" Returns the current branch.
|
||||
"""
|
||||
return None
|
||||
raise NotYetImplemented()
|
||||
|
|
|
@ -30,7 +30,7 @@ class Git(BaseProject):
|
|||
base = self._project_base()
|
||||
if base:
|
||||
return u(os.path.basename(base))
|
||||
return None
|
||||
return None # pragma: nocover
|
||||
|
||||
def branch(self):
|
||||
base = self._project_base()
|
||||
|
@ -39,13 +39,13 @@ class Git(BaseProject):
|
|||
try:
|
||||
with open(head, 'r', encoding='utf-8') as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except UnicodeDecodeError:
|
||||
except UnicodeDecodeError: # pragma: nocover
|
||||
try:
|
||||
with open(head, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
except IOError:
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
return None
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Mercurial(BaseProject):
|
|||
def name(self):
|
||||
if self.configDir:
|
||||
return u(os.path.basename(os.path.dirname(self.configDir)))
|
||||
return None
|
||||
return None # pragma: nocover
|
||||
|
||||
def branch(self):
|
||||
if self.configDir:
|
||||
|
@ -37,13 +37,13 @@ class Mercurial(BaseProject):
|
|||
try:
|
||||
with open(branch_file, 'r', encoding='utf-8') as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except UnicodeDecodeError:
|
||||
except UnicodeDecodeError: # pragma: nocover
|
||||
try:
|
||||
with open(branch_file, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
return u(fh.readline().strip().rsplit('/', 1)[-1])
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
except IOError:
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
return u('default')
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ class ProjectMap(BaseProject):
|
|||
|
||||
if self._configs.get(path.lower()):
|
||||
return self._configs.get(path.lower())
|
||||
if self._configs.get('%s/' % path.lower()):
|
||||
if self._configs.get('%s/' % path.lower()): # pragma: nocover
|
||||
return self._configs.get('%s/' % path.lower())
|
||||
if self._configs.get('%s\\' % path.lower()):
|
||||
if self._configs.get('%s\\' % path.lower()): # pragma: nocover
|
||||
return self._configs.get('%s\\' % path.lower())
|
||||
|
||||
split_path = os.path.split(path)
|
||||
if split_path[1] == '':
|
||||
return None
|
||||
return None # pragma: nocover
|
||||
return self._find_project(split_path[0])
|
||||
|
||||
def branch(self):
|
||||
|
@ -63,4 +63,4 @@ class ProjectMap(BaseProject):
|
|||
def name(self):
|
||||
if self.project:
|
||||
return u(self.project)
|
||||
return None
|
||||
return None # pragma: nocover
|
||||
|
|
|
@ -18,8 +18,8 @@ from .base import BaseProject
|
|||
from ..compat import u, open
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from ..packages.ordereddict import OrderedDict
|
||||
except ImportError: # pragma: nocover
|
||||
from ..packages.ordereddict import OrderedDict # pragma: nocover
|
||||
|
||||
|
||||
log = logging.getLogger('WakaTime')
|
||||
|
@ -32,10 +32,14 @@ class Subversion(BaseProject):
|
|||
return self._find_project_base(self.path)
|
||||
|
||||
def name(self):
|
||||
return u(self.info['Repository Root'].split('/')[-1])
|
||||
if 'Repository Root' not in self.info:
|
||||
return None # pragma: nocover
|
||||
return u(self.info['Repository Root'].split('/')[-1].split('\\')[-1])
|
||||
|
||||
def branch(self):
|
||||
return u(self.info['URL'].split('/')[-1])
|
||||
if 'URL' not in self.info:
|
||||
return None # pragma: nocover
|
||||
return u(self.info['URL'].split('/')[-1].split('\\')[-1])
|
||||
|
||||
def _find_binary(self):
|
||||
if self.binary_location:
|
||||
|
@ -69,8 +73,7 @@ class Subversion(BaseProject):
|
|||
else:
|
||||
if stdout:
|
||||
for line in stdout.splitlines():
|
||||
if isinstance(line, bytes):
|
||||
line = bytes.decode(line)
|
||||
line = u(line)
|
||||
line = line.split(': ', 1)
|
||||
if len(line) == 2:
|
||||
info[line[0]] = line[1]
|
||||
|
@ -78,7 +81,7 @@ class Subversion(BaseProject):
|
|||
|
||||
def _find_project_base(self, path, found=False):
|
||||
if platform.system() == 'Windows':
|
||||
return False
|
||||
return False # pragma: nocover
|
||||
path = os.path.realpath(path)
|
||||
if os.path.isfile(path):
|
||||
path = os.path.split(path)[0]
|
||||
|
|
|
@ -35,14 +35,14 @@ class WakaTimeProjectFile(BaseProject):
|
|||
with open(self.config, 'r', encoding='utf-8') as fh:
|
||||
self._project_name = u(fh.readline().strip())
|
||||
self._project_branch = u(fh.readline().strip())
|
||||
except UnicodeDecodeError:
|
||||
except UnicodeDecodeError: # pragma: nocover
|
||||
try:
|
||||
with open(self.config, 'r', encoding=sys.getfilesystemencoding()) as fh:
|
||||
self._project_name = u(fh.readline().strip())
|
||||
self._project_branch = u(fh.readline().strip())
|
||||
except:
|
||||
log.exception("Exception:")
|
||||
except IOError:
|
||||
except IOError: # pragma: nocover
|
||||
log.exception("Exception:")
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue