本文整理匯總了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)