mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Update Mako-1.1.5
This commit is contained in:
parent
4eb0fea423
commit
668f6bfbb8
5 changed files with 28 additions and 12 deletions
|
@ -5,4 +5,4 @@
|
||||||
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
# the MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
|
|
||||||
|
|
||||||
__version__ = '1.1.2'
|
__version__ = "1.1.5"
|
||||||
|
|
|
@ -99,11 +99,20 @@ else:
|
||||||
|
|
||||||
|
|
||||||
if py3k:
|
if py3k:
|
||||||
from importlib import machinery
|
from importlib import machinery, util
|
||||||
|
|
||||||
def load_module(module_id, path):
|
|
||||||
return machinery.SourceFileLoader(module_id, path).load_module()
|
|
||||||
|
|
||||||
|
if hasattr(util, 'module_from_spec'):
|
||||||
|
# Python 3.5+
|
||||||
|
def load_module(module_id, path):
|
||||||
|
spec = util.spec_from_file_location(module_id, path)
|
||||||
|
module = util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
return module
|
||||||
|
else:
|
||||||
|
def load_module(module_id, path):
|
||||||
|
module = machinery.SourceFileLoader(module_id, path).load_module()
|
||||||
|
del sys.modules[module_id]
|
||||||
|
return module
|
||||||
|
|
||||||
else:
|
else:
|
||||||
import imp
|
import imp
|
||||||
|
@ -111,7 +120,9 @@ else:
|
||||||
def load_module(module_id, path):
|
def load_module(module_id, path):
|
||||||
fp = open(path, "rb")
|
fp = open(path, "rb")
|
||||||
try:
|
try:
|
||||||
return imp.load_source(module_id, path, fp)
|
module = imp.load_source(module_id, path, fp)
|
||||||
|
del sys.modules[module_id]
|
||||||
|
return module
|
||||||
finally:
|
finally:
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,15 @@ class LinguaMakoExtractor(Extractor, MessageExtractor):
|
||||||
self.python_extractor = get_extractor("x.py")
|
self.python_extractor = get_extractor("x.py")
|
||||||
if fileobj is None:
|
if fileobj is None:
|
||||||
fileobj = open(filename, "rb")
|
fileobj = open(filename, "rb")
|
||||||
return self.process_file(fileobj)
|
must_close = True
|
||||||
|
else:
|
||||||
|
must_close = False
|
||||||
|
try:
|
||||||
|
for message in self.process_file(fileobj):
|
||||||
|
yield message
|
||||||
|
finally:
|
||||||
|
if must_close:
|
||||||
|
fileobj.close()
|
||||||
|
|
||||||
def process_python(self, code, code_lineno, translator_strings):
|
def process_python(self, code, code_lineno, translator_strings):
|
||||||
source = code.getvalue().strip()
|
source = code.getvalue().strip()
|
||||||
|
|
|
@ -201,7 +201,7 @@ class Lexer(object):
|
||||||
"""
|
"""
|
||||||
if isinstance(text, compat.text_type):
|
if isinstance(text, compat.text_type):
|
||||||
m = self._coding_re.match(text)
|
m = self._coding_re.match(text)
|
||||||
encoding = m and m.group(1) or known_encoding or "ascii"
|
encoding = m and m.group(1) or known_encoding or "utf-8"
|
||||||
return encoding, text
|
return encoding, text
|
||||||
|
|
||||||
if text.startswith(codecs.BOM_UTF8):
|
if text.startswith(codecs.BOM_UTF8):
|
||||||
|
@ -222,7 +222,7 @@ class Lexer(object):
|
||||||
if m:
|
if m:
|
||||||
parsed_encoding = m.group(1)
|
parsed_encoding = m.group(1)
|
||||||
else:
|
else:
|
||||||
parsed_encoding = known_encoding or "ascii"
|
parsed_encoding = known_encoding or "utf-8"
|
||||||
|
|
||||||
if decode_raw:
|
if decode_raw:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -12,7 +12,6 @@ import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import types
|
import types
|
||||||
import weakref
|
import weakref
|
||||||
|
@ -414,14 +413,12 @@ class Template(object):
|
||||||
self, data, filename, path, self.module_writer
|
self, data, filename, path, self.module_writer
|
||||||
)
|
)
|
||||||
module = compat.load_module(self.module_id, path)
|
module = compat.load_module(self.module_id, path)
|
||||||
del sys.modules[self.module_id]
|
|
||||||
if module._magic_number != codegen.MAGIC_NUMBER:
|
if module._magic_number != codegen.MAGIC_NUMBER:
|
||||||
data = util.read_file(filename)
|
data = util.read_file(filename)
|
||||||
_compile_module_file(
|
_compile_module_file(
|
||||||
self, data, filename, path, self.module_writer
|
self, data, filename, path, self.module_writer
|
||||||
)
|
)
|
||||||
module = compat.load_module(self.module_id, path)
|
module = compat.load_module(self.module_id, path)
|
||||||
del sys.modules[self.module_id]
|
|
||||||
ModuleInfo(module, path, self, filename, None, None, None)
|
ModuleInfo(module, path, self, filename, None, None, None)
|
||||||
else:
|
else:
|
||||||
# template filename and no module directory, compile code
|
# template filename and no module directory, compile code
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue