return line
comments[:] = map(_strip, comments)
+
def extract_from_dir(dirname=os.getcwd(), method_map=DEFAULT_MAPPING,
options_map=None, keywords=DEFAULT_KEYWORDS,
comment_tags=(), callback=None, strip_comment_tags=False):
yield filename, lineno, message, comments
break
+
def extract_from_file(method, filename, keywords=DEFAULT_KEYWORDS,
comment_tags=(), options=None, strip_comment_tags=False):
"""Extract messages from a specific file.
finally:
fileobj.close()
+
def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
options=None, strip_comment_tags=False):
"""Extract messages from the given file-like object using the specified
yield lineno, messages, comments
+
def extract_nothing(fileobj, keywords, comment_tags, options):
"""Pseudo extractor that does not actually extract anything, but simply
returns an empty list.
"""
return []
+
def extract_python(fileobj, keywords, comment_tags, options):
"""Extract messages from Python source code.
elif tok == NAME and value in keywords:
funcname = value
+
def extract_javascript(fileobj, keywords, comment_tags, options):
"""Extract messages from JavaScript source code.
class TokenError(ValueError):
"""Raised if the tokenizer stumbled upon invalid tokens."""
+
class Token(tuple):
"""Represents a token as returned by `tokenize`."""
__slots__ = ()
value = property(itemgetter(1))
lineno = property(itemgetter(2))
+
def indicates_division(token):
"""A helper function that helps the tokenizer to decide if the current
token may be followed by a division operator.
return token.value in (')', ']', '}', '++', '--')
return token.type in ('name', 'number', 'string', 'regexp')
+
def unquote_string(string):
"""Unquote a string with JavaScript rules. The string has to start with
string delimiters (``'`` or ``"``.)
return u''.join(result)
+
def tokenize(source):
"""Tokenize a JavaScript source.