本文整理汇总了Python中source.Source.add_target方法的典型用法代码示例。如果您正苦于以下问题:Python Source.add_target方法的具体用法?Python Source.add_target怎么用?Python Source.add_target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source.Source
的用法示例。
在下文中一共展示了Source.add_target方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_sources
# 需要导入模块: from source import Source [as 别名]
# 或者: from source.Source import add_target [as 别名]
def _load_sources(self):
for source_file_physical_path, dirnames, filenames in os.walk(self.source_dir):
# get relative path starting from self.source_dir
source_file_relative_path = os.path.relpath(source_file_physical_path, self.source_dir)
get_formats = etree.XPath("//meta[@name='dcterms.Format']/@content")
for f in filenames:
# append a Source object to sources files list
s = Source(os.path.abspath(source_file_physical_path), source_file_relative_path, f)
xml = etree.parse(s.source)
formats = get_formats(xml)
for ext in formats:
physical_path = os.path.abspath(os.path.join(self.out_dir, s.relative_path))
target = Target(physical_path, s.relative_path, s.basename, ext)
s.add_target(target)
# XXX: only use one format for now
break
self.sources.append(s)
logging.debug(self.sources)