當前位置: 首頁>>代碼示例>>Python>>正文


Python Paths.relpath方法代碼示例

本文整理匯總了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()
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:27,代碼來源:runtest_module.py

示例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)
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:17,代碼來源:collector.py

示例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))
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:17,代碼來源:__init__.py

示例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
     ]
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:7,代碼來源:__init__.py


注:本文中的scripts.core.base.Paths.relpath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。