当前位置: 首页>>代码示例>>Python>>正文


Python ScriptParser.replace方法代码示例

本文整理汇总了Python中picard.script.ScriptParser.replace方法的典型用法代码示例。如果您正苦于以下问题:Python ScriptParser.replace方法的具体用法?Python ScriptParser.replace怎么用?Python ScriptParser.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在picard.script.ScriptParser的用法示例。


在下文中一共展示了ScriptParser.replace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _script_to_filename

# 需要导入模块: from picard.script import ScriptParser [as 别名]
# 或者: from picard.script.ScriptParser import replace [as 别名]
 def _script_to_filename(self, format, file_metadata, settings=None):
     if settings is None:
         settings = config.setting
     metadata = Metadata()
     if config.setting["clear_existing_tags"]:
         metadata.copy(file_metadata)
     else:
         metadata.copy(self.orig_metadata)
         metadata.update(file_metadata)
     # make sure every metadata can safely be used in a path name
     for name in metadata.keys():
         if isinstance(metadata[name], basestring):
             metadata[name] = sanitize_filename(metadata[name])
     format = format.replace("\t", "").replace("\n", "")
     filename = ScriptParser().eval(format, metadata, self)
     if settings["ascii_filenames"]:
         if isinstance(filename, unicode):
             filename = unaccent(filename)
         filename = replace_non_ascii(filename)
     # replace incompatible characters
     if settings["windows_compatibility"] or sys.platform == "win32":
         filename = replace_win32_incompat(filename)
     # remove null characters
     filename = filename.replace("\x00", "")
     return filename
开发者ID:Freso,项目名称:picard,代码行数:27,代码来源:file.py

示例2: _make_image_filename

# 需要导入模块: from picard.script import ScriptParser [as 别名]
# 或者: from picard.script.ScriptParser import replace [as 别名]
 def _make_image_filename(self, filename, dirname, metadata):
     filename = ScriptParser().eval(filename, metadata)
     if config.setting["ascii_filenames"]:
         if isinstance(filename, unicode):
             filename = unaccent(filename)
         filename = replace_non_ascii(filename)
     if not filename:
         filename = "cover"
     if not os.path.isabs(filename):
         filename = os.path.join(dirname, filename)
     # replace incompatible characters
     if config.setting["windows_compatibility"] or sys.platform == "win32":
         filename = replace_win32_incompat(filename)
     # remove null characters
     filename = filename.replace("\x00", "")
     return encode_filename(filename)
开发者ID:hackur,项目名称:picard,代码行数:18,代码来源:image.py

示例3: script_to_filename

# 需要导入模块: from picard.script import ScriptParser [as 别名]
# 或者: from picard.script.ScriptParser import replace [as 别名]
def script_to_filename(naming_format, metadata, file=None, settings=None):
    if settings is None:
        settings = config.setting
    # make sure every metadata can safely be used in a path name
    for name in metadata:
        values = [sanitize_filename(str(v)) for v in metadata.getall(name)]
        metadata.set(name, values)
    naming_format = naming_format.replace("\t", "").replace("\n", "")
    filename = ScriptParser().eval(naming_format, metadata, file)
    if settings["ascii_filenames"]:
        filename = replace_non_ascii(filename, pathsave=True)
    # replace incompatible characters
    if settings["windows_compatibility"] or sys.platform == "win32":
        filename = replace_win32_incompat(filename)
    # remove null characters
    filename = filename.replace("\x00", "")
    return filename
开发者ID:mineo,项目名称:picard,代码行数:19,代码来源:scripttofilename.py


注:本文中的picard.script.ScriptParser.replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。