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


Python Paths.basename方法代碼示例

本文整理匯總了Python中scripts.core.base.Paths.basename方法的典型用法代碼示例。如果您正苦於以下問題:Python Paths.basename方法的具體用法?Python Paths.basename怎麽用?Python Paths.basename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scripts.core.base.Paths的用法示例。


在下文中一共展示了Paths.basename方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_one

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [as 別名]
 def get_one(self, yaml_case_file):
     """
     :rtype: list[ConfigCase]
     """
     result = list()
     for case in self.cases:
         for f in case[yamlc.TAG_FILES]:
             if Paths.basename(f) == Paths.basename(yaml_case_file):
                 dummy_case = deepcopy(case)
                 dummy_case[yamlc.TAG_FILES] = [yaml_case_file]
                 result.extend(self._get_all_for_case(dummy_case))
     return [ConfigCase(r, self) for r in result]
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:14,代碼來源:yaml_config.py

示例2: __iter__

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [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: list_tests

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [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

示例4: __init__

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [as 別名]
    def __init__(self, yaml_config_file):
        self.yaml_config_file = yaml_config_file
        self.root = Paths.dirname(self.yaml_config_file)
        self.yamls = self._get_all_yamls()
        self.cases = list()
        self.common_config = None

        # create dummy case for every yaml file in folder
        if not Paths.exists(self.yaml_config_file):
            self.common_config = deepcopy(DEFAULTS)
            for y in self.yamls:
                dummy_case = deepcopy(DEFAULTS)
                dummy_case['file'] = [y]
                self.cases.append(dummy_case)
        else:
            # setup common config values
            self.yaml_config = self._read_yaml()
            self.common_config = self.merge(DEFAULTS, self.yaml_config.get('common_config', {}))

            # first process files which are specified in test_cases
            missing = [Paths.basename(y) for y in self.yamls]
            for case in self.yaml_config.get('test_cases', []):
                case_config = self.merge(self.common_config, case)
                self.cases.append(case_config)
                for f in case_config['file']:
                    if f in missing:
                        missing.remove(f)

            # process rest (dummy case)
            for y in missing:
                dummy_case = deepcopy(self.common_config)
                dummy_case['file'] = [y]
                self.cases.append(dummy_case)
開發者ID:andrew-c-esp,項目名稱:Flow123d-python-utils,代碼行數:35,代碼來源:yaml_config.py

示例5: __init__

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [as 別名]
    def __init__(self, o, config):
        o = ConfigBase.merge(yamlc.DEFAULTS, deepcopy(o))

        self.file = o.get(yamlc.TAG_FILES, None)
        self.proc = int(o.get(yamlc.TAG_PROC, None))
        self.time_limit = float(o.get(yamlc.TAG_TIME_LIMIT, None))
        self.memory_limit = float(o.get(yamlc.TAG_MEMORY_LIMIT, None))
        self.tags = set(o.get(yamlc.TAG_TAGS, None))
        self.check_rules = o.get(yamlc.TAG_CHECK_RULES, None)
        self.config = config

        if self.config:
            self.file = Paths.join(self.config.root, Paths.basename(self.file))
            self.without_ext = Paths.basename(Paths.without_ext(self.file))
            self.shortname = '{name}.{proc}'.format(
                name=self.without_ext, proc=self.proc)

            self.fs = yamlc.ConfigCaseFiles(
                root=self.config.root,
                ref_output=Paths.join(
                    self.config.root, yamlc.REF_OUTPUT_DIR, self.without_ext),
                output=Paths.join(
                    self.config.root,
                    yamlc.TEST_RESULTS,
                    self.shortname
                ))
        else:
            # create temp folder where files will be
            tmp_folder = Paths.temp_file(o.get('tmp') + '-{date}-{time}-{rnd}')
            Paths.ensure_path(tmp_folder, is_file=False)

            self.fs = yamlc.ConfigCaseFiles(
                root=tmp_folder,
                ref_output=tmp_folder,
                output=tmp_folder
            )
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:38,代碼來源:yaml_config.py

示例6: create_comparisons

# 需要導入模塊: from scripts.core.base import Paths [as 別名]
# 或者: from scripts.core.base.Paths import basename [as 別名]
    def create_comparisons(self):
        comparisons = ComparisonMultiThread(self.case.fs.ndiff_log)
        comparisons.thread_name_property = True

        for check_rule in self.case.check_rules:
            method = str(check_rule.keys()[0])
            module = getattr(file_comparison, 'Compare{}'.format(method.capitalize()), None)
            comp_data = check_rule[method]
            if not module:
                Printer.all.err('Warning! No module for check_rule method "{}"', method)
                continue

            pairs = self._get_ref_output_files(comp_data)
            if pairs:
                for pair in pairs:
                    command = module.get_command(*pair, **comp_data)
                    pm = PyPy(BinExecutor(command), progress=True)

                    # if we fail, set error to 13
                    pm.custom_error = 13
                    pm.start_monitor.deactivate()
                    pm.end_monitor.deactivate()
                    pm.progress_monitor.deactivate()
                    pm.limit_monitor.deactivate() # TODO: maybe some time limit would be useful
                    pm.output_monitor.policy = pm.output_monitor.POLICY_ERROR_ONLY

                    pm.error_monitor.message = 'Comparison using method {} failed!'.format(method)
                    pm.error_monitor.indent = 1

                    # catch output
                    pm.executor.output = OutputMode.variable_output()
                    pm.full_output = self.case.fs.ndiff_log

                    path = Paths.path_end_until(pair[0], REF_OUTPUT_DIR)
                    test_name = Paths.basename(Paths.dirname(Paths.dirname(self.case.fs.ref_output)))
                    size = Paths.filesize(pair[0], True)
                    pm.name = '{}: {} ({})'.format(test_name, path, size)
                    comparisons.add(pm)

        return comparisons
開發者ID:jbrezmorf,項目名稱:flow123d,代碼行數:42,代碼來源:local_run.py


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