本文整理汇总了Python中util.Util.prependExtension方法的典型用法代码示例。如果您正苦于以下问题:Python Util.prependExtension方法的具体用法?Python Util.prependExtension怎么用?Python Util.prependExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.prependExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: optimizeJsManifest
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import prependExtension [as 别名]
def optimizeJsManifest(self):
contents = Util.fileGetContents(self.config.js_manifest)
for key, value in self.manifest_ids.items():
if "#" + value in self.id_map:
contents = re.sub(r'((?<!\$)\${1}[A-Z0-9_]+\s?=\s?[\'|\"])(' + value + ')([\'|\"][,|;])', r'\1' + self.id_map["#" + value].replace("#", "") + r'\3', contents)
for key, value in self.manifest_classes.items():
if "." + value in self.class_map:
contents = re.sub(r'(\${2}[A-Z0-9_]+\s?=\s?[\'|\"])(' + value + ')([\'|\"][,|;])', r'\1' + self.class_map["." + value].replace(".", "") + r'\3', contents)
if self.config.rewrite_constants:
constants = re.findall(r'(\s+?(var\s)?([A-Z0-9_]+)\s?=\s?[\'|\"](.*?)[\'|\"][,|;])', contents)
new_constants = {}
i = 0
for constant in constants:
# underscore variables are ignored
if constant[2][0] == "_":
continue
i += 1
new_constant = re.sub(r'=(.*)([,|;])','= ' + str(i) + r'\2', constant[0])
contents = contents.replace(constant[0], new_constant)
new_manifest = Util.prependExtension("opt", self.config.js_manifest)
Util.filePutContents(new_manifest, contents)
if self.config.show_savings:
SizeTracker.trackFile(self.config.js_manifest, new_manifest)
示例2: optimizeFile
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import prependExtension [as 别名]
def optimizeFile(self, file, callback, minimize = False, new_path = None, prepend = "opt"):
"""optimizes a single file
Arguments:
file -- path to file
callback -- function to run the file through
minimize -- whether or not we should minimize the file contents (html)
prepend -- what extension to prepend
Returns:
void
"""
content = callback(file)
if new_path is None:
new_path = Util.prependExtension(prepend, file)
if minimize is True:
self.output("minimizing " + file)
content = self.minimize(content)
self.output("optimizing " + file + " to " + new_path)
Util.filePutContents(new_path, content)
if self.config.show_savings:
SizeTracker.trackFile(file, new_path)