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


Python dir_util.mkpath方法代码示例

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


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

示例1: run

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def run(self):
        """Run the command"""
        srcdir = os.path.join('docs', 'man')
        manpages = os.listdir(srcdir)
        self._outfiles = []
        for man in manpages:
            src_man = os.path.join(srcdir, man)
            section = os.path.splitext(man)[1][1:]
            dest_dir = os.path.join(self.prefix, 'man' + section)
            self.mkpath(dest_dir)  # Could be different section
            dest_man = os.path.join(dest_dir, man)
            self.copy_file(src_man, dest_man)
            self._outfiles.append(dest_man)

        # Disabled, done in the RPM spec
        # self._write_record() 
开发者ID:mysql,项目名称:mysql-utilities,代码行数:18,代码来源:setup.py

示例2: make_name

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def make_name(opt, prefix="", eval_=False, is_dir=True, set_epoch=None,
              do_epoch=True):
    string = prefix
    string += "{}-{}".format(opt.dataset, opt.exp)
    string += "/"
    string += "{}-{}-{}".format(opt.trainer, opt.cycle, opt.iters)
    string += "/"
    string += opt.model
    if opt.mle:
        string += "-{}".format(opt.mle)
    string += "/"
    string += make_name_string(opt.data) + "/"

    string += make_name_string(opt.net) + "/"
    string += make_name_string(opt.train.static) + "/"

    if eval_:
        string += make_name_string(opt.eval) + "/"
    # mkpath caches whether a directory has been created
    # In IPython, this can be a problem if the kernel is
    # not reset after a dir is deleted. Trying to recreate
    # that dir will be a problem because mkpath will think
    # the directory already exists
    if not is_dir:
        mkpath(string)
    string += make_name_string(
        opt.train.dynamic, True, do_epoch, set_epoch)
    if is_dir:
        mkpath(string)

    return string 
开发者ID:atcbosselut,项目名称:comet-commonsense,代码行数:33,代码来源:utils.py

示例3: generate_config_files

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def generate_config_files(type_, key, name="base", eval_mode=False):
    with open("config/default.json".format(type_), "r") as f:
        base_config = json.load(f)
    with open("config/{}/default.json".format(type_), "r") as f:
        base_config_2 = json.load(f)
    if eval_mode:
        with open("config/{}/eval_changes.json".format(type_), "r") as f:
            changes_by_machine = json.load(f)
    else:
        with open("config/{}/changes.json".format(type_), "r") as f:
            changes_by_machine = json.load(f)

    base_config.update(base_config_2)

    if name in changes_by_machine:
        changes = changes_by_machine[name]
    else:
        changes = changes_by_machine["base"]

    # for param in changes[key]:
    #     base_config[param] = changes[key][param]

    replace_params(base_config, changes[key])

    mkpath("config/{}".format(type_))

    with open("config/{}/config_{}.json".format(type_, key), "w") as f:
        json.dump(base_config, f, indent=4) 
开发者ID:atcbosselut,项目名称:comet-commonsense,代码行数:30,代码来源:utils.py

示例4: mkpath

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def mkpath(self, name, mode=0777):
        dir_util.mkpath(name, mode, dry_run=self.dry_run) 
开发者ID:glmcdona,项目名称:meddle,代码行数:4,代码来源:cmd.py

示例5: _copy_files

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def _copy_files(self, filelist):
        self.outfiles = []
        if not filelist:
            return
        self.mkpath(self.install_dir)
        for f in filelist:
            self.copy_file(f, self.install_dir)
            self.outfiles.append(os.path.join(self.install_dir, f)) 
开发者ID:glmcdona,项目名称:meddle,代码行数:10,代码来源:cmd.py

示例6: mkpath

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def mkpath(self, name, mode=0777):
        mkpath(name, mode, dry_run=self.dry_run)


# class CCompiler


# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
# type for that platform. Keys are interpreted as re match
# patterns. Order is important; platform mappings are preferred over
# OS names. 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:ccompiler.py

示例7: pack

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def pack(self, dst_path):
        '''Pack pipeline to zip file.

        Args:
            dst_path: Path to store zipfile. E.g 'test/my_cool_pipe.zip'
        '''
        # Do everything relative from pipeline definition file path.
        tmp = dict()
        used_lib_paths = dict()
        used_static_paths = dict()
        tmp_path = os.path.abspath('tmp_pipe_packer')
        tmp['root'] = os.path.join(tmp_path, self.pipe['name'])
        dst = os.path.abspath(dst_path)
        oldwd = os.getcwd()
        os.chdir(self.pipe_template_path)
        for pe_j in self.pipe['elements']:
            if 'script' in pe_j:
                element_j = pe_j['script']
                script = parse_script(element_j)
                src_script_dir_path = os.path.split(script.path)[0]
                # Calculate all paths
                tmp['script.rel'] = os.path.splitext(os.path.basename(script.path))[0]
                tmp['script.abs'] = os.path.join(tmp['root'], tmp['script.rel'])
                # Create folder structure
                if not os.path.exists(tmp['script.abs']):
                    dir_util.mkpath(tmp['script.abs'])
                # Copy files
                dir_util.copy_tree(src_script_dir_path, tmp['script.abs'])
                logging.info("Copyed script from %s to %s"%(src_script_dir_path,
                                                            tmp['script.abs']))
                script_name = os.path.basename(script.path)
                # Write new paths to back to json dict
                element_j['path'] = script_name
        with open(join(tmp['root'], os.path.basename(self.json_path)), 'w') as outfile:
            json.dump(self.pipe, outfile)
        fm.zipdir(src=tmp['root'], dst=dst)
        dir_util.remove_tree(tmp_path)
        os.chdir(oldwd) # Change dir back to old working directory. 
开发者ID:l3p-cv,项目名称:lost,代码行数:40,代码来源:template_import.py

示例8: mkpath

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def mkpath(self, name, mode=0o777):
        dir_util.mkpath(name, mode, dry_run=self.dry_run) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:cmd.py

示例9: mkpath

# 需要导入模块: from distutils import dir_util [as 别名]
# 或者: from distutils.dir_util import mkpath [as 别名]
def mkpath (self, name, mode=0o777):
        mkpath(name, mode, dry_run=self.dry_run)


# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
# type for that platform. Keys are interpreted as re match
# patterns. Order is important; platform mappings are preferred over
# OS names. 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:10,代码来源:ccompiler.py


注:本文中的distutils.dir_util.mkpath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。