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


Python shutil.ignore_patterns函数代码示例

本文整理汇总了Python中shutil.ignore_patterns函数的典型用法代码示例。如果您正苦于以下问题:Python ignore_patterns函数的具体用法?Python ignore_patterns怎么用?Python ignore_patterns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: exe

def exe():
    makedirs( DIST_DIR )
    shutil.copy( "pyautocore.pyd", DIST_DIR )
    shutil.copy( "__init__.py", DIST_DIR )
    shutil.copy( "pyauto_const.py", DIST_DIR )
    shutil.copy( "pyauto_input.py", DIST_DIR )
    rmtree( DIST_DIR + "/sample" )
    shutil.copytree( "sample", DIST_DIR + "/sample", ignore=shutil.ignore_patterns(".svn","*.pyc","*.pyo") )
    rmtree( DIST_DIR + "/doc" )
    shutil.copytree( "doc/html", DIST_DIR + "/doc", ignore=shutil.ignore_patterns(".svn") )

    if 1:
        os.chdir("dist")
        createZip( "pyauto.zip", DIST_FILES )
        os.chdir("..")
    
    fd = open("dist/pyauto.zip","rb")
    m = hashlib.md5()
    while 1:
        data = fd.read( 1024 * 1024 )
        if not data: break
        m.update(data)
    fd.close()
    print( "" )
    print( m.hexdigest() )
开发者ID:crftwr,项目名称:pyauto,代码行数:25,代码来源:makefile.py

示例2: prepare

    def prepare(self):
        root_dir = self.get_bindings_root_directory()

        # Create directories
        common.recreate_directory(self.tmp_dir)
        os.makedirs(self.tmp_examples_dir)
        os.makedirs(self.tmp_source_dir)
        os.makedirs(self.tmp_build_dir)

        # Copy blockly and closure-library to build directory
        shutil.copytree(os.path.join(root_dir, '..', '..', 'tvpl-blockly'), self.tmp_build_blockly_dir,
                        ignore=shutil.ignore_patterns('*/.git'))
        shutil.copytree(os.path.join(root_dir, '..', '..', 'tvpl-closure-library'), self.tmp_build_closure_library_dir,
                        ignore=shutil.ignore_patterns('*/.git', '*_test.js'))

        # Copy css/, js/, index.html and programEditor.html
        shutil.copytree(os.path.join(root_dir, 'css'), os.path.join(self.tmp_source_dir, 'css'))
        shutil.copytree(os.path.join(root_dir, 'js'), os.path.join(self.tmp_source_dir, 'js'))
        shutil.copy(os.path.join(root_dir, 'index.html'), self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'programEditor.html'), self.tmp_source_dir)

        # Copy changelog.txt and readme.txt
        shutil.copy(os.path.join(root_dir, 'changelog.txt'),self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'readme.txt'),self.tmp_dir)

        # Generate JavaScript bindings
        with common.ChangedDirectory(os.path.join(root_dir, '..', 'javascript')):
            common.execute(['python', 'generate_javascript_bindings.py'])
            common.execute(['python', 'generate_javascript_zip.py'])

        shutil.copy(os.path.join(self.tmp_javascript_dir, 'browser', 'source', 'Tinkerforge.js'),
                    os.path.join(self.tmp_source_dir, 'js', 'Tinkerforge.js'))
开发者ID:ck365tools,项目名称:generators,代码行数:32,代码来源:generate_tvpl_zip.py

示例3: save_firefox_profile

    def save_firefox_profile(self, remove_old=False):
        """Function to save the firefox profile to the permanant one"""
        self.logger.info("Saving profile from %s to %s" % (self._profile.path, self._profile_path))

        if remove_old:
            if os.path.exists(self._profile_path):
                try:
                    shutil.rmtree(self._profile_path)
                except OSError:
                    pass

            shutil.copytree(os.path.join(self._profile.path), self._profile_path,
                            ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
        else:
            for item in os.listdir(self._profile.path):
                if item in ["parent.lock", "lock", ".parentlock"]:
                    continue
                s = os.path.join(self._profile.path, item)
                d = os.path.join(self._profile_path, item)
                if os.path.isdir(s):
                    shutil.copytree(s, d,
                                    ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
                else:
                    shutil.copy2(s, d)

        with open(os.path.join(self._profile_path, self._LOCAL_STORAGE_FILE), 'w') as f:
            f.write(dumps(self.get_local_storage()))
开发者ID:hifenhur,项目名称:wppbot,代码行数:27,代码来源:__init__.py

示例4: _perform_utilproc

def _perform_utilproc(src, cmd_args,
                      on_cmd=None, include=None, ignore=None, verbose=False):
    if include is None:
        return

    names = os.listdir(src)
    inc_p = ignore_patterns(*include)
    include_names = inc_p(src, names)

    if ignore is None:
        ignore_files = set()
    else:
        patterns = ignore_patterns(*ignore)
        ignore_files = patterns(src, names)

    for name in names:
        if name in ignore_files:
            if verbose:
                cprint.warning('ignored: ', os.path.join(src, name))
            continue

        srcname = os.path.join(src, name)
        if not os.path.isdir(srcname) and name not in include_names:
            if verbose:
                cprint.warning('excluded: ', os.path.join(src, name))
            continue

        try:
            if os.path.isdir(srcname):
                _perform_utilproc(srcname,
                                  cmd_args,
                                  on_cmd=on_cmd,
                                  include=include,
                                  ignore=ignore,
                                  verbose=verbose)
            else:
                args = [a if a != '{FILENAME}' else srcname for a in cmd_args]
                if verbose:
                    cprint.ok(str(' '.join(c for c in args)))

                p = Popen(args, stdout=PIPE, stderr=PIPE)
                stdout, stderr = p.communicate()

                if p.returncode != 0:
                    cprint.error('ERROR PROCESSING: ', '{0} -> {1}'.
                                 format(srcname, args))
                    cprint.error(stderr)
                    continue

                if on_cmd is not None:
                    on_cmd(srcname, stdout)
                elif verbose:
                    cprint(stdout)

        except (IOError, os.error) as err:
            msg = "Failed to perform util on {0}: ".format(srcname, str(err))
            return (False, msg)

    return (True, None)
开发者ID:juztin,项目名称:mini,代码行数:59,代码来源:mini.py

示例5: do_copy

    def do_copy(self, src, dest, perms=None):
        """Copy the src dir to the dest dir omitting the self.ignore globs."""
        if os.path.isdir(self.dest_path):
            self.copy_if_missing(src, dest, ignore=shutil.ignore_patterns(*self.ignore))
        else:
            shutil.copytree(src, dest, ignore=shutil.ignore_patterns(*self.ignore))

        if perms:
            for dirname, dirnames, filenames in os.walk(dest):
                for filename in filenames:
                    os.chmod(os.path.join(dirname, filename), perms)
开发者ID:huwf,项目名称:nbgrader,代码行数:11,代码来源:fetchapp.py

示例6: _copy_data_files

def _copy_data_files(rpath, datadir, rdatadir):
    try:
        shutil.copytree(os.path.join(DATA_DIR, rpath), os.path.join(datadir,
                    rpath), ignore=shutil.ignore_patterns('*.pyc', '*.pyo'))
    except FileNotFoundError:
        pass

    try:
        shutil.copytree(os.path.join(RDATA_DIR, rpath), os.path.join(rdatadir,
                    rpath), ignore=shutil.ignore_patterns('*.pyc', '*.pyo'))
    except FileNotFoundError:
        pass
开发者ID:kynikos,项目名称:outspline,代码行数:12,代码来源:release.py

示例7: cmd_co

def cmd_co(db, tree_name, path):
    check_path_shape(path)
    curs = db.cursor()

    # sanity checks
    curs.execute("SELECT * FROM checkout WHERE pkgpath = ?", (path, ))
    if len(curs.fetchall()) != 0:
        print("Error: Already checked out in %s" % \
            os.path.join(MYSTUFF_PATH, path))
        exit_nicely(db)

    if tree_name == "wip":
        tree = WIP_PATH
        origin = ORIGIN_WIP
    elif tree_name ==  "main":
        tree = PORTS_PATH
        origin = ORIGIN_PORTS
    else:
        print("Error: Bad tree path. Should be either 'wip' or 'main'")
        exit_nicely(db)

    if os.path.exists(os.path.join(MYSTUFF_PATH, path)):
        print("error: Destination path exists: %s" % \
            os.path.join(MYSTUFF_PATH, path))
        exit_nicely(db)

    if not os.path.exists(os.path.join(tree, path)):
        print("error: Source path does not exist: %s" % \
            os.path.join(tree, path))
        exit_nicely(db)

    # We might have to create the category directory
    category_dir = os.path.dirname(os.path.join(MYSTUFF_PATH, path))
    if not os.path.exists(category_dir):
        os.mkdir(category_dir)

    # Copy in from source
    shutil.copytree( \
        os.path.join(tree, path), os.path.join(MYSTUFF_PATH, path), \
        ignore=shutil.ignore_patterns("CVS"))

    # Archive away a copy for merges
    shutil.copytree(os.path.join(tree, path), os.path.join(ARCHIVE_PATH, path), \
        ignore=shutil.ignore_patterns("CVS"))

    # Update db
    curs.execute("INSERT INTO checkout (pkgpath, origin, flags) VALUES " + \
        "(?, ?, ?)", (path, origin, 0))
    db.commit()

    print("Port checked out into %s" % (os.path.join(MYSTUFF_PATH, path)))
开发者ID:vext01,项目名称:openbsd-wip-tools,代码行数:51,代码来源:owip.py

示例8: copy_dirs

def copy_dirs():
	if os.path.exists("dist") == False:
		os.mkdir("dist")
		
	if os.path.exists(os.path.join("dist", "docs")):
		shutil.rmtree(os.path.join("dist", "docs"))
	if os.path.exists(os.path.join("dist", "bin")):
		shutil.rmtree(os.path.join("dist", "bin"))
	if os.path.exists(os.path.join("dist", "etc")):
		shutil.rmtree(os.path.join("dist", "etc"))
	if os.path.exists(os.path.join("dist", "interface")):
		shutil.rmtree(os.path.join("dist", "interface"))
	if os.path.exists(os.path.join("dist", "lib")):
		shutil.rmtree(os.path.join("dist", "lib"))
	if os.path.exists(os.path.join("dist", "pixmaps")):
		shutil.rmtree(os.path.join("dist", "pixmaps"))
	if os.path.exists(os.path.join("dist", "share")):
		shutil.rmtree(os.path.join("dist", "share"))
	if os.path.exists(os.path.join("dist", "po")):
		shutil.rmtree(os.path.join("dist", "po"))
		
	shutil.copytree("docs", os.path.join("dist", "docs"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("bin", os.path.join("dist", "bin"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("etc", os.path.join("dist", "etc"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("interface", os.path.join("dist", "interface"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("lib", os.path.join("dist", "lib"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("pixmaps", os.path.join("dist", "pixmaps"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("share", os.path.join("dist", "share"), ignore=shutil.ignore_patterns('.git*'))
	shutil.copytree("po", os.path.join("dist", "po"), ignore=shutil.ignore_patterns('.git*'))
开发者ID:majorsilence,项目名称:Devede,代码行数:29,代码来源:setup.windows.py

示例9: copy_application

def copy_application(src, dst):

    application_name = os.path.basename(src)

    if not os.path.exists(dst):
        shutil.copytree(src, dst, ignore=shutil.ignore_patterns(IGNORE_PATTERNS))
        os.remove(dst+"/__init__.py")
        os.remove(dst+"/__init__.pyc")
        
        app_files = os.listdir(dst+"/application/")
        app_files = [dst+"/application/"+filename for filename in app_files]
        
        for file in app_files:
            shutil.move(file, dst)
    
        os.rmdir(dst+"/application/")

        #every wordpress plugin becomes a new application
        if (dst.find("wordpress") != -1 and os.path.exists(dst+"/plugins/")):
            plugins = os.listdir(dst+"/plugins/")

            if(".DS_Store" in plugins):
                plugins.remove(".DS_Store")

            plugins = [dst+"/plugins/"+filename for filename in plugins]
            
            for plugin in plugins:
                
                plugin_name = os.path.basename(plugin)
                plugin_dst = settings.applications_path+application_name+"_"+plugin_name
                
                shutil.copytree(dst,plugin_dst, ignore=shutil.ignore_patterns(IGNORE_PATTERNS))
                
                os.makedirs(plugin_dst+"/wp-content/plugins/"+plugin_name.split("_")[0]+"/")

                if(os.path.isfile(plugin_dst+"/plugins/"+plugin_name+"/database.sql")):
                    shutil.move(plugin_dst+"/plugins/"+plugin_name+"/database.sql", plugin_dst+"/wp-content/plugins/"+plugin_name.split("_")[0]+"/")
                
                plugin_files = os.listdir(plugin_dst+"/plugins/"+plugin_name+"/plugin/")
                plugin_files = [plugin_dst+"/plugins/"+plugin_name+"/plugin/"+filename for filename in plugin_files]
                
                for plugin_file in plugin_files:
                    shutil.move(plugin_file, plugin_dst+"/wp-content/plugins/"+plugin_name.split("_")[0]+"/")

                shutil.rmtree(plugin_dst+"/plugins/")
                generate_configuration(application_name+"_"+plugin_name, plugin_name=plugin_name)

    else:
        print("application " +dst+ " already imported")
开发者ID:beejhuff,项目名称:TestREx,代码行数:49,代码来源:bugbox-to-testbed.py

示例10: install

    def install(self, spec, prefix):
        """Install under the projectdir (== prefix/name-version)"""
        self.build(spec, prefix)  # Should be a separate phase
        opts = self.wm_options

        # Fairly ugly since intermediate targets are scattered inside sources
        appdir = 'applications'
        mkdirp(self.projectdir, join_path(self.projectdir, appdir))

        # Retain build log file
        out = "spack-build.out"
        if isfile(out):
            install(out, join_path(self.projectdir, "log." + opts))

        # All top-level files, except spack build info and possibly Allwmake
        if '+source' in spec:
            ignored = re.compile(r'^spack-.*')
        else:
            ignored = re.compile(r'^(Allclean|Allwmake|spack-).*')

        files = [
            f for f in glob.glob("*") if isfile(f) and not ignored.search(f)
        ]
        for f in files:
            install(f, self.projectdir)

        # Install directories. install applications/bin directly
        for d in ['bin', 'etc', 'wmake', 'lib', join_path(appdir, 'bin')]:
            install_tree(
                d,
                join_path(self.projectdir, d))

        if '+source' in spec:
            subitem = join_path(appdir, 'Allwmake')
            install(subitem, join_path(self.projectdir, subitem))

            ignored = [opts]  # Intermediate targets
            for d in ['src', 'tutorials']:
                install_tree(
                    d,
                    join_path(self.projectdir, d),
                    ignore=shutil.ignore_patterns(*ignored))

            for d in ['solvers', 'utilities']:
                install_tree(
                    join_path(appdir, d),
                    join_path(self.projectdir, appdir, d),
                    ignore=shutil.ignore_patterns(*ignored))
开发者ID:justintoo,项目名称:spack,代码行数:48,代码来源:package.py

示例11: virtualenv

def virtualenv(tmpdir, monkeypatch):
    """
    Return a virtual environment which is unique to each test function
    invocation created inside of a sub directory of the test function's
    temporary directory. The returned object is a
    ``tests.lib.venv.VirtualEnvironment`` object.
    """
    # Force shutil to use the older method of rmtree that didn't use the fd
    # functions. These seem to fail on Travis (and only on Travis).
    monkeypatch.setattr(shutil, "_use_fd_functions", False, raising=False)

    # Copy over our source tree so that each virtual environment is self
    # contained
    pip_src = tmpdir.join("pip_src").abspath
    shutil.copytree(
        SRC_DIR,
        pip_src,
        ignore=shutil.ignore_patterns(
            "*.pyc", "tests", "pip.egg-info", "build", "dist", ".tox",
        ),
    )

    # Create the virtual environment
    venv = VirtualEnvironment.create(
        tmpdir.join("workspace", "venv"),
        pip_source_dir=pip_src,
    )

    # Undo our monkeypatching of shutil
    monkeypatch.undo()

    return venv
开发者ID:fpytloun,项目名称:pip,代码行数:32,代码来源:conftest.py

示例12: __init__

    def __init__(self,profile_directory=None):
        """
        Initialises a new instance of a Firefox Profile

        :args:
         - profile_directory: Directory of profile that you want to use.
           This defaults to None and will create a new
           directory when object is created.
        """
        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES)
        self.profile_dir = profile_directory
        self.tempfolder = None
        if self.profile_dir is None:
            self.profile_dir = self._create_tempfolder()
        else:
            self.tempfolder = tempfile.mkdtemp()
            newprof = os.path.join(self.tempfolder,
                "webdriver-py-profilecopy")
            shutil.copytree(self.profile_dir, newprof,
                ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
            self.profile_dir = newprof
            self._read_existing_userjs()
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")
开发者ID:151706061,项目名称:X,代码行数:25,代码来源:firefox_profile.py

示例13: packaging

def packaging(src):
	"""
		reading install.rdf and packaging a xpi file. 
		for example: 
			xxx-0.1.xpi
	"""
	work_copy = osp.dirname(src)
	
	addon_info = "".join(open(work_copy + osp.sep + "install.rdf"))
	addon_name = re.search("(?<=em\:name\=\").*(?=\")",addon_info).group(0)
	addon_version =  re.search("(?<=em\:version\=\").*(?=\")",addon_info).group(0)

	temp_copy_base = tempfile.mkdtemp()
	temp_copy = osp.join(temp_copy_base,addon_name)
	
	xpi_name = "%s-%s.xpi" % (addon_name,addon_version)
	xpi_fullpath = osp.join(work_copy,xpi_name);
	
	print """
	Add-on    : %s
	Version   : %s
	Work Copy : %s
	Temp Copy : %s
	XPI File  : %s
	""" % (addon_name,addon_version,work_copy,temp_copy, xpi_name)

	print "copying work to temp dir..."
	copytree(work_copy,temp_copy,ignore=ignore_patterns('scriptdemo','*.xpi','.*','*.bat','*.py','*LOG','*~','*.swp'))

	print "packaging xpi..."
	compress(temp_copy,xpi_fullpath);

	print "cleaning..."
	rmtree(temp_copy_base)
开发者ID:riptide766,项目名称:easyscripts,代码行数:34,代码来源:packaging.py

示例14: _writeInputsFunction

def _writeInputsFunction(i, f, epoch, inputpath, coorname):
    regex = re.compile('(e\d+s\d+)_')
    frameNum = f.frame
    piece = f.piece
    if f.sim.parent is None:
        currSim = f.sim
    else:
        currSim = f.sim.parent

    traj = currSim.trajectory[piece]
    if currSim.input is None:
        raise NameError('Could not find input folder in simulation lists. Cannot create new simulations.')

    wuName = _simName(traj)
    res = regex.search(wuName)
    if res:  # If we are running on top of adaptive, use the first name part for the next sim name
        wuName = res.group(1)

    # create new job directory
    newName = 'e' + str(epoch) + 's' + str(i + 1) + '_' + wuName + 'p' + str(piece) + 'f' + str(frameNum)
    newDir = path.join(inputpath, newName, '')

    # copy previous input directory including input files
    copytree(currSim.input, newDir, symlinks=False, ignore=ignore_patterns('*.coor', '*.rst', '*.out', *_IGNORE_EXTENSIONS))

    # overwrite input file with new one. frameNum + 1 as catdcd does 1 based indexing

    mol = Molecule(currSim.molfile)  # Always read the mol file, otherwise it does not work if we need to save a PDB as coorname
    mol.read(traj)
    mol.dropFrames(keep=frameNum)  # Making sure only specific frame to write is kept
    mol.write(path.join(newDir, coorname))
开发者ID:alejandrovr,项目名称:htmd,代码行数:31,代码来源:adaptive.py

示例15: _init

    def _init(self):
        from natsort import natsorted
        folders = natsorted(glob(path.join(self.generatorspath, '*', ''))) # I need the extra ''  to add a finishing /
        if len(folders) == 0:
            logger.info('Generators folder has no subdirectories, using folder itself')
            folders.append(self.generatorspath)

        numF = len(folders)
        numCopies = np.ones(numF, dtype=int) * int(np.floor(self.nmax / numF))
        numExtra = np.mod(self.nmax, numF)
        extraChoices = np.random.choice(numF, numExtra, replace=False) # draw the extra
        numCopies[extraChoices] += 1
        # numCopies = numCopies + np.random.multinomial(numExtra, [1/numF]*numF)  # draw the extra equally from a flat distribution
        if not path.exists(self.inputpath):
            makedirs(self.inputpath)

        # Check if epoch 1 directories already exist in the input folder
        existing = glob(path.join(self.inputpath, 'e1s*'))
        if len(existing) != 0:
            raise NameError('Epoch 1 directories already exist.')

        k = 1
        for i in range(numF):
            for j in range(numCopies[i]):
                name = _simName(folders[i])
                inputdir = path.join(self.inputpath, 'e1s' + str(k) + '_' + name)
                #src = path.join(self.generatorspath, name, '*')
                src = folders[i]
                copytree(src, inputdir, symlinks=True, ignore=ignore_patterns(*_IGNORE_EXTENSIONS))
                k += 1
开发者ID:alejandrovr,项目名称:htmd,代码行数:30,代码来源:adaptive.py


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