当前位置: 首页>>代码示例>>Python>>正文


Python Paths.join方法代码示例

本文整理汇总了Python中scripts.core.base.Paths.join方法的典型用法代码示例。如果您正苦于以下问题:Python Paths.join方法的具体用法?Python Paths.join怎么用?Python Paths.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scripts.core.base.Paths的用法示例。


在下文中一共展示了Paths.join方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
    def __init__(self, o, config):
        o = ConfigBase.merge(DEFAULTS, deepcopy(o))

        self.file = o.get('file', None)
        self.proc = int(o.get('proc', None))
        self.time_limit = float(o.get('time_limit', None))
        self.memory_limit = float(o.get('memory_limit', None))
        self.tags = set(o.get('tags', None))
        self.check_rules = o.get('check_rules', None)
        self.config = config

        if self.config:
            self.file = Paths.join(self.config.root, 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 = ConfigCaseFiles(
                root=self.config.root,
                ref_output=Paths.join(self.config.root, 'ref_output', self.without_ext),
                output=Paths.join(
                    self.config.root,
                    '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 = ConfigCaseFiles(
                root=tmp_folder,
                ref_output=tmp_folder,
                output=tmp_folder
            )
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:36,代码来源:yaml_config.py

示例2: __iter__

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [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 join [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: parse

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
    def parse(self):
        for k, v in self.configs.items():
            self.configs[k] = ConfigBase(k)

        for k, v in self.files.items():
            config = Paths.join(Paths.dirname(k), yamlc.CONFIG_YAML)
            self.files[k] = self.configs[config]
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:9,代码来源:yaml_config.py

示例5: __init__

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [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: _get_ref_output_files

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [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

示例7: get_pbs_module

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
def get_pbs_module(hostname_hint=None):
    """
    file host_table.yaml serves as lookup table when using python script in queue mode
    each key is hostname and each value names a module which should be loaded
    modules are located in /src/python/scripts/pbs/modules

    If no matching key for current machine exists try to use pbs_<hostname>
    where all dots(.) are replaced with underscores(_)

    if hostname_hint is not set node name will be used
    :rtype : scripts.pbs.modules.pbs_tarkil_cesnet_cz
    """
    pbs_module_path = None
    host_file = Paths.join(Paths.flow123d_root(), 'config', 'host_table.yaml')
    host_file_exists = Paths.exists(host_file)
    hostname = hostname_hint or platform.node()
    from_host = False

    # try to get name from json file
    if host_file_exists:
        with open(host_file, 'r') as fp:
            hosts = yaml.load(fp)
            pbs_module_path = hosts.get(hostname, None)
            from_host = pbs_module_path is not None

    if not pbs_module_path:
        hostname = hostname.replace('.', '_')
        pbs_module_path = 'pbs_{}'.format(hostname)

    # construct full path for import
    full_module_path = 'scripts.pbs.modules.{module_name}'.format(module_name=pbs_module_path)

    # try to get pbs_module
    try:
        return importlib.import_module(full_module_path)
    except ImportError:
        Printer.all.err('Could not load module "{}" ({}) for hostname "{}"',
                    pbs_module_path, full_module_path, hostname)
        with Printer.all.with_level(2):
            if host_file_exists:
                if from_host:
                    Printer.all.err('Value specified in host_table.yaml "{}" points to non-existing module', pbs_module_path)
                else:
                    Printer.all.err('Config file host_table.yaml does not have entry for hostname "{}"', hostname)
            else:
                Printer.all.err('Config file host_table.yaml does not exists ({}) and auto module detection failed', host_file)
        raise
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:49,代码来源:common.py

示例8: get_pbs_module

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
def get_pbs_module(hostname=None):
    """
    :rtype : scripts.pbs.modules.pbs_tarkil_cesnet_cz
    """
    pbs_module_path = None
    if not hostname:
        hostname = platform.node()

    # try to get name from json file
    host_file = Paths.join(Paths.source_dir(), 'host_table.json')
    if Paths.exists(host_file):
        with open(host_file, 'r') as fp:
            hosts = json.load(fp)
            pbs_module_path = hosts.get(hostname, None)

    if not pbs_module_path:
        hostname = hostname.replace('.', '_')
        pbs_module_path = 'pbs_{}'.format(hostname)
        Printer.wrn('Warning! no host specified assuming module {}', pbs_module_path)

    # try to get pbs_module
    return importlib.import_module('scripts.pbs.modules.{}'.format(pbs_module_path))
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:24,代码来源:common.py

示例9: add_case

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
 def add_case(self, yaml_case_file):
     config = Paths.join(Paths.dirname(yaml_case_file), yamlc.CONFIG_YAML)
     self.configs[config] = None
     self.files[yaml_case_file] = None
     return self
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:7,代码来源:yaml_config.py

示例10: in_root

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
 def in_root(self, *names):
     """
     :rtype: str
     """
     return Paths.join(self.root, *names)
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:7,代码来源:yaml_config.py

示例11: in_output

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [as 别名]
 def in_output(self, *names):
     """
     :rtype: str
     """
     return Paths.join(self.output, *names)
开发者ID:andrew-c-esp,项目名称:Flow123d-python-utils,代码行数:7,代码来源:yaml_config.py

示例12: _get_mirror_files

# 需要导入模块: from scripts.core.base import Paths [as 别名]
# 或者: from scripts.core.base.Paths import join [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.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。