update wakatime-cli to v3.0.3
This commit is contained in:
parent
7c07925527
commit
e1dc4039fd
4 changed files with 135 additions and 2 deletions
|
@ -3,6 +3,12 @@ History
|
|||
-------
|
||||
|
||||
|
||||
3.0.3 (2014-12-25)
|
||||
++++++++++++++++++
|
||||
|
||||
- detect JavaScript frameworks from script tags in Html template files
|
||||
|
||||
|
||||
3.0.2 (2014-12-25)
|
||||
++++++++++++++++++
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
from __future__ import print_function
|
||||
|
||||
__title__ = 'wakatime'
|
||||
__version__ = '3.0.2'
|
||||
__version__ = '3.0.3'
|
||||
__author__ = 'Alan Hamlett'
|
||||
__license__ = 'BSD'
|
||||
__copyright__ = 'Copyright 2014 Alan Hamlett'
|
||||
|
|
|
@ -94,7 +94,7 @@ class DependencyParser(object):
|
|||
try:
|
||||
self.parser = getattr(module, class_name)
|
||||
except AttributeError:
|
||||
log.debug(traceback.format_exc())
|
||||
log.debug('Module {0} is missing class {1}'.format(module.__name__, class_name))
|
||||
except ImportError:
|
||||
log.debug(traceback.format_exc())
|
||||
|
||||
|
|
|
@ -91,3 +91,130 @@ class LassoJavascriptParser(TokenParser):
|
|||
def _process_literal_string(self, token, content):
|
||||
if 'famous/core/' in content.strip('"').strip("'"):
|
||||
self.append('famous')
|
||||
|
||||
|
||||
class HtmlDjangoParser(TokenParser):
|
||||
tags = []
|
||||
getting_attrs = False
|
||||
current_attr = None
|
||||
current_attr_value = None
|
||||
|
||||
def parse(self, tokens=[]):
|
||||
if not tokens and not self.tokens:
|
||||
self.tokens = self._extract_tokens()
|
||||
for index, token, content in self.tokens:
|
||||
self._process_token(token, content)
|
||||
return self.dependencies
|
||||
|
||||
def _process_token(self, token, content):
|
||||
if u(token) == 'Token.Name.Tag':
|
||||
self._process_tag(token, content)
|
||||
elif u(token) == 'Token.Literal.String':
|
||||
self._process_string(token, content)
|
||||
elif u(token) == 'Token.Name.Attribute':
|
||||
self._process_attribute(token, content)
|
||||
|
||||
@property
|
||||
def current_tag(self):
|
||||
return None if len(self.tags) == 0 else self.tags[0]
|
||||
|
||||
def _process_tag(self, token, content):
|
||||
if content.startswith('</') or content.startswith('/'):
|
||||
self.tags.pop(0)
|
||||
self.getting_attrs = False
|
||||
elif content.startswith('<'):
|
||||
self.tags.insert(0, content.replace('<', '', 1).strip().lower())
|
||||
self.getting_attrs = True
|
||||
elif content.startswith('>'):
|
||||
self.getting_attrs = False
|
||||
self.current_attr = None
|
||||
|
||||
def _process_attribute(self, token, content):
|
||||
if self.getting_attrs:
|
||||
self.current_attr = content.lower().strip('=')
|
||||
else:
|
||||
self.current_attr = None
|
||||
self.current_attr_value = None
|
||||
|
||||
def _process_string(self, token, content):
|
||||
if self.getting_attrs and self.current_attr is not None:
|
||||
if content.endswith('"') or content.endswith("'"):
|
||||
if self.current_attr_value is not None:
|
||||
self.current_attr_value += content
|
||||
if self.current_tag == 'script' and self.current_attr == 'src':
|
||||
self.append(self.current_attr_value)
|
||||
self.current_attr = None
|
||||
self.current_attr_value = None
|
||||
else:
|
||||
if len(content) == 1:
|
||||
self.current_attr_value = content
|
||||
else:
|
||||
if self.current_tag == 'script' and self.current_attr == 'src':
|
||||
self.append(content)
|
||||
self.current_attr = None
|
||||
self.current_attr_value = None
|
||||
elif content.startswith('"') or content.startswith("'"):
|
||||
if self.current_attr_value is None:
|
||||
self.current_attr_value = content
|
||||
else:
|
||||
self.current_attr_value += content
|
||||
|
||||
|
||||
class VelocityHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class MyghtyHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class MasonParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class MakoHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class CheetahHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class HtmlGenshiParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class RhtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class HtmlPhpParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class HtmlSmartyParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class EvoqueHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class ColdfusionHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class LassoHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class HandlebarsHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class YamlJinjaParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
||||
|
||||
class TwigHtmlParser(HtmlDjangoParser):
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue