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


Python dir_util.copy_tree方法代碼示例

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


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

示例1: main

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def main(self):
        self.sublconsole.showlog("start to refresh %s..." % (self.sel_dirs))
        self.meta_api = util.sf_login(self.sf_basic_config, Soap_Type=MetadataApi)
        retrive_metadata_objects = []
        for metaObj in self.meta_api.describeMetadata()["metadataObjects"]:
            if metaObj['directoryName'] in self.sel_dirs:
                retrive_metadata_objects.append(metaObj)
        if len(retrive_metadata_objects) > 0 :
            tmp_dir = self.sf_basic_config.get_tmp_dir()
            tmp_file = os.path.join(tmp_dir, "tmp_src.zip")
            tmp_src_dir = os.path.join(tmp_dir, "tmp_src")
            if os.path.exists(tmp_file):
                os.remove(tmp_file)
            if os.path.exists(tmp_src_dir):
                shutil.rmtree(tmp_src_dir)
            self.meta_api.retrieveZip(zip_file_name=tmp_file, retrive_metadata_objects=retrive_metadata_objects)
            if os.path.exists(tmp_file):
                self.meta_api.unzipfile(tmp_file, tmp_src_dir, self.settings["src_dir"])
                tmp_package_xml_path = os.path.join(tmp_src_dir, self.settings["src_dir"], "package.xml")
                if os.path.exists(tmp_package_xml_path): os.remove(tmp_package_xml_path)
                from distutils import dir_util
                dir_util.copy_tree(os.path.join(tmp_src_dir, self.settings["src_dir"]), os.path.join(self.sf_basic_config.get_src_root(), self.settings["src_dir"]))
        else:
            self.sublconsole.showlog("Sorry , Nothing to do. ") 
開發者ID:exiahuang,項目名稱:SalesforceXyTools,代碼行數:26,代碼來源:main_metadata.py

示例2: update_pipe_project

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def update_pipe_project(self):

        if os.path.exists(self.dst_pipe_template_path):
            logging.info('\n\n++++++++++++++++++++++\n\n')
            for pipe in self.pipes:
                if not self.checker.check(pipe):
                    logging.error('Pipeline was not updated!')
                    return False
            for pipe in self.pipes:
                self.update_pipe(pipe)
            dir_util.copy_tree(self.src_pipe_template_path, self.dst_pipe_template_path)
            
            logging.info("Copyed pipeline template dir from %s to %s"%(self.src_pipe_template_path,
                                                    self.dst_pipe_template_path))
        else:
            logging.warning(('Cannot update. No such pipe project: *{}*. '
                            'Maybe you want to import a pipeline instead ' 
                            'of updating it.').format(self.namespace)) 
開發者ID:l3p-cv,項目名稱:lost,代碼行數:20,代碼來源:template_import.py

示例3: start_import

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def start_import(self):
        logging.info('\n\n++++++++++++++++++++++ \n\n')
        logging.info('Start pipe project import for: {}'.format(self.src_pipe_template_path))
        for pipe in self.pipes:
            if not self.checker.check(pipe):
                logging.error('Wrong pipeline definition! Did not import pipe project!')
                return False
        if os.path.exists(self.dst_pipe_template_path):
            logging.warning('Cannot import pipeline!')
            logging.warning('Pipe Template Dir already exist: {}'.format(
                self.dst_pipe_template_path
            ))
            return
        dir_util.copy_tree(self.src_pipe_template_path, self.dst_pipe_template_path)
        logging.info("Copyed pipeline template dir from %s to %s"%(self.src_pipe_template_path,
                                                    self.dst_pipe_template_path))
        for pipe in self.pipes:
            self.import_pipe(pipe) 
開發者ID:l3p-cv,項目名稱:lost,代碼行數:20,代碼來源:template_import.py

示例4: test_copy_tree_verbosity

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def test_copy_tree_verbosity(self):

        mkpath(self.target, verbose=0)

        copy_tree(self.target, self.target2, verbose=0)
        self.assertEqual(self._logs, [])

        remove_tree(self.root_target, verbose=0)

        mkpath(self.target, verbose=0)
        a_file = os.path.join(self.target, 'ok.txt')
        with open(a_file, 'w') as f:
            f.write('some content')

        wanted = ['copying %s -> %s' % (a_file, self.target2)]
        copy_tree(self.target, self.target2, verbose=1)
        self.assertEqual(self._logs, wanted)

        remove_tree(self.root_target, verbose=0)
        remove_tree(self.target2, verbose=0) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:22,代碼來源:test_dir_util.py

示例5: copy_to_labview_dir

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def copy_to_labview_dir(self, source, relative_destination):
        labview_path = os.path.join(self.path, relative_destination)
        self._helpers.copy_tree(source, labview_path)
        self._helpers.make_writable(labview_path)
        return labview_path 
開發者ID:ni,項目名稱:python_labview_automation,代碼行數:7,代碼來源:labview.py

示例6: copy_tree

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def copy_tree(self, source, destination):
        copy_tree(source, destination) 
開發者ID:ni,項目名稱:python_labview_automation,代碼行數:4,代碼來源:labview.py

示例7: copytree

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def copytree(a, b):
    """shutil's copytree is dumb so use distutils."""
    return dir_util.copy_tree(a, b) 
開發者ID:ParadropLabs,項目名稱:Paradrop,代碼行數:5,代碼來源:pdos.py

示例8: build_template

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def build_template(temp_dir):
    """
    Create HTML file with supporting JS and CSS files in a given directory.
    :param temp_dir: string with path to temp directory in which the html file should be built
    """
    dir_util.copy_tree(STATIC_TEMPLATE_LIB, temp_dir)
    dir_util.copy_tree(STATIC_PATH_LIB, os.path.join(
        temp_dir, STATIC_PATH_TEMP))

    # Move association file to root of temporary directory.
    copyfile(os.path.join(temp_dir, ASSOCIATION_PATH_IN_STATIC),
             os.path.join(temp_dir, ASSOCIATION_PATH_IN_ROOT)) 
開發者ID:gradio-app,項目名稱:gradio-UI,代碼行數:14,代碼來源:networking.py

示例9: datadir

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def datadir(tmpdir, request):
    '''
    Fixture responsible for searching a folder with the same name of test
    module and, if available, moving all contents to a temporary directory so
    tests can use them freely.
    '''
    filename = request.module.__file__
    test_dir, _ = os.path.splitext(filename)

    if os.path.isdir(test_dir):
        dir_util.copy_tree(test_dir, bytes(tmpdir))

    return tmpdir 
開發者ID:cea-hpc,項目名稱:pcocc,代碼行數:15,代碼來源:conftest.py

示例10: copy_tree

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def copy_tree(self, infile, outfile,
                   preserve_mode=1, preserve_times=1, preserve_symlinks=0,
                   level=1):
        """Copy an entire directory tree respecting verbose, dry-run,
        and force flags.
        """
        return dir_util.copy_tree(
            infile, outfile,
            preserve_mode,preserve_times,preserve_symlinks,
            not self.force,
            dry_run=self.dry_run) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:13,代碼來源:cmd.py

示例11: update_dir

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def update_dir(src_dir, dst_dir):
  """Recursively copy from src_dir to dst_dir, replacing files but only if
  they're newer or don't exist."""
  dir_util.copy_tree(src_dir, dst_dir, update=True) 
開發者ID:google,項目名稱:clusterfuzz,代碼行數:6,代碼來源:common.py

示例12: datadir

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def datadir(tmpdir, request):
    '''
    Fixture responsible for searching a folder with the same name of test
    module and, if available, moving all contents to a temporary directory so
    tests can use them freely.
    '''
    filename = request.module.__file__
    test_dir, _ = os.path.splitext(filename)

    if os.path.isdir(test_dir):
        dir_util.copy_tree(test_dir, str(tmpdir))

    return tmpdir 
開發者ID:City-of-Helsinki,項目名稱:linkedevents,代碼行數:15,代碼來源:test_importer_espoo.py

示例13: prepare_project_directory

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def prepare_project_directory(self, new_project_dir):
        check_directory_and_mkdir(new_project_dir)
        # copy_tree(self.engine_path, new_project_dir)
        # default_project_file = os.path.join(new_project_dir, 'defualt.project')
        # if os.path.exists(default_project_file):
        #     os.remove(default_project_file) 
開發者ID:ubuntunux,項目名稱:PyEngine3D,代碼行數:8,代碼來源:ResourceManager.py

示例14: pack

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [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

示例15: copy_appleseed_python

# 需要導入模塊: from distutils import dir_util [as 別名]
# 或者: from distutils.dir_util import copy_tree [as 別名]
def copy_appleseed_python(self):
        progress("Copying appleseed.python to root directory")

        # Create destination directory.
        lib_dir = os.path.join(self.settings.root_dir, "appleseed", "lib")
        safe_make_directory(lib_dir)

        # Copy appleseed.python.
        dir_util.copy_tree(self.settings.appleseed_python_path, lib_dir) 
開發者ID:appleseedhq,項目名稱:blenderseed,代碼行數:11,代碼來源:blenderseed.package.py


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