本文整理汇总了Python中scripts.core.base.Paths.relpath方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.relpath方法的具体用法?Python Paths.relpath怎么用?Python Paths.relpath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scripts.core.base.Paths
的用法示例。
在下文中一共展示了Paths.relpath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_tests
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import relpath [as 别名]
def list_tests():
test_dir = Paths.join(Paths.flow123d_root(), 'tests')
tests = Paths.walk(test_dir, [
PathFilters.filter_type_is_file(),
PathFilters.filter_endswith('.yaml'),
PathFilters.filter_not(PathFilters.filter_name('config.yaml')),
])
result = dict()
for r in tests:
dirname = Paths.dirname(r)
basename = Paths.basename(r)
if Paths.dirname(dirname) != test_dir:
continue
if dirname not in result:
result[dirname] = list()
result[dirname].append(basename)
keys = sorted(result.keys())
for dirname in keys:
Printer.all.out(Paths.relpath(dirname, test_dir))
with Printer.all.with_level(1):
for basename in result[dirname]:
Printer.all.out('{: >4s} {: <40s} {}', '', basename, Paths.relpath(Paths.join(dirname, basename), test_dir))
Printer.all.newline()
示例2: __iter__
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import relpath [as 别名]
def __iter__(self):
fileset = formic.FileSet(self.includes, directory=self.source)
for filename in fileset:
name = Paths.basename(filename) if not self.name else self.name.format(
path=self.create_path_dict(filename),
name=Paths.basename(filename),
)
if self.flat:
root = self.target
else:
rel_path = Paths.relpath(Paths.dirname(filename), Paths.abspath(self.source))
root = Paths.abspath(Paths.join(self.target, rel_path))
yield CopyRule(filename, Paths.join(root, name), self.remove_original)
示例3: _get_ref_output_files
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import relpath [as 别名]
def _get_ref_output_files(self, comp_data):
"""
:type comp_data: dict
"""
# parse filters
filters = [PathFilters.filter_wildcards(x) for x in comp_data.get('files', [])]
# browse files and make them relative to ref output so filters works properly
files = Paths.walk(self.case.fs.ref_output, [PathFilters.filter_type_is_file()])
files = [Paths.relpath(f, self.case.fs.ref_output) for f in files]
# filter files and make them absolute again
files = Paths.match(files, filters)
files = [Paths.join(self.case.fs.ref_output, f) for f in files]
return zip(files, self._get_mirror_files(files))
示例4: _get_mirror_files
# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import relpath [as 别名]
def _get_mirror_files(self, paths):
return [
Paths.join(self.case.fs.output, Paths.relpath(p, self.case.fs.ref_output))
for p in paths
]