Python shutil 模块,ignore_patterns() 实例源码

我们从Python开源项目中,提取了以下31个代码示例,用于说明如何使用shutil.ignore_patterns()

项目:build-calibre    作者:kovidgoyal    | 项目源码 | 文件源码
def add_qt_framework(self, f):
        libname = f
        f = f + '.framework'
        src = join(PREFIX, 'qt', 'lib', f)
        ignore = shutil.ignore_patterns('Headers', '*.h', 'Headers/*')
        dest = join(self.frameworks_dir, f)
        shutil.copytree(src, dest, symlinks=True,
                        ignore=ignore)
        lib = os.path.realpath(join(dest, libname))
        rpath = os.path.relpath(lib, self.frameworks_dir)
        self.set_id(lib, self.FID + '/' + rpath)
        self.fix_dependencies_in_lib(lib)
        # The following is needed for codesign in OS X >= 10.9.5
        # The presence of the .prl file in the root of the framework causes
        # codesign to fail.
        with current_dir(dest):
            for x in os.listdir('.'):
                if x != 'Versions' and not os.path.islink(x):
                    os.remove(x)
项目:PyBackup    作者:FRReinert    | 项目源码 | 文件源码
def process_item(self, source, destination):
        '''
        Backup a single item 
        '''
        try:
            copytree(source, destination, ignore=ignore_patterns(*self.ignored_extensions))

        except OSError as e:
            if e.errno == ENOTDIR:
                try:
                    copy(source, destination)

                except:
                    log.update_log("Error processing file <%s>: <%s>" % (source, e))

            else:
                self.log.update_log("Source <%s> could not be copied to <%s>: <%s>" % (source, destination, e))

        except BaseException as e:
            self.log.update_log("Unkown error copying <%s>: <%s>" % (source, e))
项目:blender-addon-updater    作者:CGCookie    | 项目源码 | 文件源码
def create_backup(self):
        if self._verbose: print("Backing up current addon folder")
        local = os.path.join(self._updater_path,"backup")
        tempdest = os.path.join(self._addon_root,
                        os.pardir,
                        self._addon+"_updater_backup_temp")

        if os.path.isdir(local) == True:
            shutil.rmtree(local)
        if self._verbose: print("Backup destination path: ",local)

        # make the copy
        if self._backup_ignore_patterns != None:
            shutil.copytree(
                self._addon_root,tempdest,
                ignore=shutil.ignore_patterns(*self._backup_ignore_patterns))
        else:
            shutil.copytree(self._addon_root,tempdest)
        shutil.move(tempdest,local)

        # save the date for future ref
        now = datetime.now()
        self._json["backup_date"] = "{m}-{d}-{yr}".format(
                m=now.strftime("%B"),d=now.day,yr=now.year)
        self.save_updater_json()
项目:lago    作者:lago-project    | 项目源码 | 文件源码
def env(request, init_fname, test_results, tmp_workdir, external_log):
    workdir = os.path.join(str(tmp_workdir), 'lago')
    env = sdk.init(
        init_fname,
        workdir=workdir,
        logfile=str(external_log),
        loglevel=logging.DEBUG,
    )
    env.start()
    try:
        yield env
        collect_path = os.path.join(test_results, 'collect')
        env.collect_artifacts(output_dir=collect_path, ignore_nopath=True)
        shutil.copytree(
            workdir,
            os.path.join(test_results, 'workdir'),
            ignore=shutil.ignore_patterns('*images*')
        )
    finally:
        env.stop()
        env.destroy()
项目:icnn    作者:locuslab    | 项目源码 | 文件源码
def run(main, outdir):
    script = os.path.abspath(sys.modules['__main__'].__file__)
    scriptdir, scriptfile = os.path.split(script)

    if not os.path.exists(outdir):
        os.makedirs(outdir)

    print("outdir: " + outdir)

    if FLAGS.copy:
        shutil.copytree(run_folder, path, symlinks=True, ignore=shutil.ignore_patterns('.*'))

    Executor(main, outdir).execute()


# register clean up before anybody else does
项目:mbuild    作者:intelxed    | 项目源码 | 文件源码
def copy_tree(src,tgt, ignore_patterns=None, symlinks=False):
    """Copy the tree at src to tgt. This will first remove tgt if it
    already exists."""
    if verbose(1):
        msgb("COPYTREE", tgt + " <- " + src)
    if not os.path.exists(src):
        error_msg("SRC TREE DOES NOT EXIST", src)
        raise Exception
    if os.path.exists(tgt):
        if verbose(1):
            msgb("Removing existing target tree", tgt)
        shutil.rmtree(tgt, ignore_errors=True)
    if verbose(1):
        msgb("Copying to tree", tgt)
    if ignore_patterns:
        sp = shutil.ignore_patterns(ignore_patterns)
    else:
        sp = None
    shutil.copytree(src,tgt,ignore=sp, symlinks=symlinks)
    if verbose(1):
        msgb("Done copying tree", tgt)
项目:zoocore    作者:dsparrow27    | 项目源码 | 文件源码
def copyDirectoy(src, dst, ignorePattern=None):
    try:
        if ignorePattern:
            shutil.copytree(src, dst, ignore=shutil.ignore_patterns(*ignorePattern))
            return
        shutil.copytree(src, dst)

    except OSError as exc:
        if exc.errno == errno.ENOTDIR:
            shutil.copy(src, dst)
        else:
            logger.error("Failed to copy directory {} to destination: {}".format(src, dst), exc_info=True)
            raise
项目:devsecops-example-helloworld    作者:boozallen    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    #Public Methods
项目:malboxes    作者:GoSecure    | 项目源码 | 文件源码
def _prepare():
    """Preparing files for package"""
    # Here are files I want packaged but also in top-level directory as it is mostly
    # unrelated to actual build
    # pip will install data_files in an odd location so I copy them in package at
    # build time
    root_data_files = ['LICENSE', 'README.adoc', 'TODO.adoc']

    for f in root_data_files:
        _tempfiles.append(shutil.copy(path.join(here, f),
                                      path.join(here, 'malboxes')))

    # docs
    shutil.copytree(path.join(here, 'docs'), path.join(here, 'malboxes/docs'),
                    ignore=shutil.ignore_patterns('presentation'))
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    #Public Methods
项目:wq.start    作者:wq    | 项目源码 | 文件源码
def start(project_name, destination, domain=None, app_id=None):
    """
    Start a new project with wq.app and wq.db.  A new Django project will be
    created from a wq-specific template.  After running this command, you may
    want to do the following:

    \b
        sudo chown www-data media/
        cd app
        wq init

    See https://wq.io/docs/setup for more tips on getting started with wq.
    """

    if app_id is None:
        app_id = '.'.join(reversed(domain.split('.')))

    args = [project_name]
    if destination:
        args.append(destination)
    kwargs = dict(
        template=template,
        extensions="py,yml,conf,html,sh,js,css,json,xml".split(","),
        domain=domain,
        app_id=app_id,
        wq_start_version=VERSION,
    )
    call_command(StartProjectCommand(), *args, **kwargs)

    path = destination or project_name
    txt = os.path.join(path, 'requirements.txt')
    print_versions(txt, [
        'wq.app',
        'wq.db',
    ])
    shutil.copytree(
        resource_filename('xlsconv', 'templates'),
        os.path.join(path, 'master_templates'),
        ignore=shutil.ignore_patterns("*.py-tpl"),
    )
项目:qiime2    作者:qiime2    | 项目源码 | 文件源码
def add_ancestor(self, artifact):
        other_path = artifact._archiver.provenance_dir
        if other_path is None:
            # The artifact doesn't have provenance (e.g. version 0)
            # it would be possible to invent a metadata.yaml, but we won't know
            # the framework version for the VERSION file. Even if we did
            # it won't accomplish a lot and there shouldn't be enough
            # version 0 artifacts in the wild to be important in practice.
            # NOTE: this implies that it is possible for an action.yaml file to
            # contain an artifact UUID that is not in the artifacts/ directory.
            return NoProvenance(artifact.uuid)

        destination = self.ancestor_dir / str(artifact.uuid)
        # If it exists, then the artifact is already in the provenance
        # (and so are its ancestors)
        if not destination.exists():
            # Handle root node of ancestor
            shutil.copytree(
                str(other_path), str(destination),
                ignore=shutil.ignore_patterns(self.ANCESTOR_DIR + '*'))

            # Handle ancestral nodes of ancestor
            grandcestor_path = other_path / self.ANCESTOR_DIR
            if grandcestor_path.exists():
                for grandcestor in grandcestor_path.iterdir():
                    destination = self.ancestor_dir / grandcestor.name
                    if not destination.exists():
                        shutil.copytree(str(grandcestor), str(destination))

        return str(artifact.uuid)
项目:leetcode    作者:thomasyimgit    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    # Public Methods
项目:relocate-venv    作者:firedrakeproject    | 项目源码 | 文件源码
def main(src_dir, new_dir, map_d, archer):
    """ Call out the necessary functions."""

    print "Creating a copy of %s in %s" % (src_dir, new_dir)
    shutil.copytree(src_dir, new_dir, symlinks=False, ignore=shutil.ignore_patterns('*.pyc'))

    print "Changing the paths according to the mapping table."
    for key in map_d.keys():
        grep_and_sed(key, new_dir, map_d[key])

    fn = shutil.make_archive(new_dir, 'tar', new_dir)
    print "%s can now be copied elsewhere and used." %(fn)
项目:FLASH    作者:yuyuz    | 项目源码 | 文件源码
def copy_folder(new_dir, old_dir):
    try:
        shutil.copytree(old_dir, new_dir, symlinks=True,
                        ignore=shutil.ignore_patterns('*.pyc', '*_src*'))
    except shutil.Error as e:
        sys.stderr.write("[shutil.ERROR] Could not copy folder from %s to %s\n" % (old_dir, new_dir))
        sys.stderr.write("%s\n" % e.message)
        return False
    except Exception, e:
        sys.stderr.write("[ERROR] Could not copy folder from %s to %s\n" % (old_dir, new_dir))
        sys.stderr.write("%s\n" % e.message)
        return False
    return True
项目:ShuoshuoMonitor    作者:aploium    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    #Public Methods
项目:siphon-cli    作者:getsiphon    | 项目源码 | 文件源码
def copy_app_template(app_name, to_path):
    path = os.path.dirname(os.path.abspath(__file__))
    source_dir = os.path.join(path, '../../../app-template/')
    ignore_func = shutil.ignore_patterns('.DS_Store', 'Thumbs.db')
    shutil.copytree(source_dir, to_path, ignore=ignore_func)

    # Replace the app name placeholder
    index_path = os.path.join(to_path, 'index.js')
    s = open(index_path, 'r').read().replace('{{app_name}}', app_name)
    with open(index_path, 'w') as fp:
        fp.write(s)
项目:amazon_order_history_scraper    作者:drewctate    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    # Public Methods
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
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.
        """
        if not FirefoxProfile.DEFAULT_PREFERENCES:
            with open(os.path.join(os.path.dirname(__file__),
                                   WEBDRIVER_PREFERENCES)) as default_prefs:
                FirefoxProfile.DEFAULT_PREFERENCES = json.load(default_prefs)

        self.default_preferences = copy.deepcopy(
            FirefoxProfile.DEFAULT_PREFERENCES['mutable'])
        self.native_events_enabled = True
        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(os.path.join(self.profile_dir, "user.js"))
        self.extensionsDir = os.path.join(self.profile_dir, "extensions")
        self.userPrefs = os.path.join(self.profile_dir, "user.js")

    #Public Methods
项目:config-sesame    作者:1and1    | 项目源码 | 文件源码
def fresh_cookies(ctx, mold=''):
    """Refresh the project from the original cookiecutter template."""
    mold = mold or "https://github.com/Springerle/py-generic-project.git"  # TODO: URL from config
    tmpdir = os.path.join(tempfile.gettempdir(), "cc-upgrade-config-sesame")

    if os.path.isdir('.git'):
        # TODO: Ensure there are no local unstashed changes
        pass

    # Make a copy of the new mold version
    if os.path.isdir(tmpdir):
        shutil.rmtree(tmpdir)
    if os.path.exists(mold):
        shutil.copytree(mold, tmpdir, ignore=shutil.ignore_patterns(
            ".git", ".svn", "*~",
        ))
    else:
        ctx.run("git clone {} {}".format(mold, tmpdir))

    # Copy recorded "cookiecutter.json" into mold
    shutil.copy2("project.d/cookiecutter.json", tmpdir)

    with pushd('..'):
        ctx.run("cookiecutter --no-input {}".format(tmpdir))
    if os.path.exists('.git'):
        ctx.run("git status")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_module_all_attribute(self):
        self.assertTrue(hasattr(shutil, '__all__'))
        target_api = ['copyfileobj', 'copyfile', 'copymode', 'copystat',
                      'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error',
                      'SpecialFileError', 'ExecError', 'make_archive',
                      'get_archive_formats', 'register_archive_format',
                      'unregister_archive_format', 'get_unpack_formats',
                      'register_unpack_format', 'unregister_unpack_format',
                      'unpack_archive', 'ignore_patterns', 'chown', 'which',
                      'get_terminal_size', 'SameFileError']
        if hasattr(os, 'statvfs') or os.name == 'nt':
            target_api.append('disk_usage')
        self.assertEqual(set(shutil.__all__), set(target_api))
项目:skin.confluence.480    作者:YggdrasiI    | 项目源码 | 文件源码
def copy(src, dest, ignore_patterns=[]):
    try:
        shutil.copytree(
            src, dest,
            ignore=shutil.ignore_patterns(
                *ignore_patterns))
    except OSError as e:
        # If the error was caused because the source wasn't a directory
        if e.errno == errno.ENOTDIR:
            shutil.copy(src, dest)
        else:
            print(' Directory not copied. Error: %s' % e)
项目:streamalert    作者:airbnb    | 项目源码 | 文件源码
def _copy_files(self, temp_package_path):
        """Copy all files and folders into temporary package path."""
        for package_folder in self.package_folders:
            # Skip copying any files with a 'dependencies.zip' suffix
            shutil.copytree(
                os.path.join(self.package_root_dir, package_folder),
                os.path.join(temp_package_path, package_folder),
                ignore=shutil.ignore_patterns(*{'*dependencies.zip'}))

        for package_file in self.package_files:
            shutil.copy(
                os.path.join(self.package_root_dir, package_file),
                os.path.join(temp_package_path, package_file))
项目:kibitzr    作者:kibitzr    | 项目源码 | 文件源码
def update_profile(driver):
    if os.path.exists(PROFILE_DIR):
        shutil.rmtree(PROFILE_DIR)
    shutil.copytree(
        driver.profile.profile_dir,
        PROFILE_DIR,
        ignore=shutil.ignore_patterns(
            "parent.lock",
            "lock",
            ".parentlock",
            "*.sqlite-shm",
            "*.sqlite-wal",
        ),
    )
项目:urnote    作者:urnote    | 项目源码 | 文件源码
def get_paths(self, pattern):
        """?????????????"""
        if pattern:
            patterns = (pattern,)
        else:
            patterns = ()
        for abspath in fs.walk(
                dirpath=self.path_helper.root_dir,
                include_patterns=patterns,
                ignore_patterns=config.IGNORE_FILES,
                ignore_patterns_filepath=self.path_helper.ignore_path):
            yield abspath
项目:urnote    作者:urnote    | 项目源码 | 文件源码
def get_paths_in_taskdir(self, pattern=None):
        """?????????????"""
        if pattern:
            patterns = (pattern,)
        else:
            patterns = ()
        for abspath in fs.walk(
                dirpath=self.path_helper.task_path,
                include_patterns=patterns,
                ignore_patterns=(),
                ignore_patterns_filepath=self.path_helper.ignore_path):
            yield abspath
项目:urnote    作者:urnote    | 项目源码 | 文件源码
def copy_to_purge_dir(self, abspath):
        """
        ?abspath???????????purge???,???????
        config.IGNORE_FILES????
        """
        ignore = shutil.ignore_patterns(*config.IGNORE_FILES)
        if os.path.isdir(abspath):
            shutil.copytree(abspath, self.path_helper.purge_path, ignore=ignore)
        else:
            ignores = ignore(None, abspath)
            if not ignores:
                shutil.copy(abspath, self.path_helper.purge_path)
项目:urnote    作者:urnote    | 项目源码 | 文件源码
def get_paths_in_purge(self):
        """?????????????"""
        for abspath in fs.walk(
                dirpath=self.path_helper.root_dir,
                ignore_patterns=config.IGNORE_FILES,
                ignore_patterns_filepath=self.path_helper.ignore_path):
            yield abspath
项目:QTodoTxt2    作者:QTodoTxt    | 项目源码 | 文件源码
def buildPackageFolder(folderName):
    buildDir=tmpDir+folderName+'_build'
    buildBinDir=buildDir+'/usr/share/qtodotxt/bin/'
    debianDir=buildDir+'/DEBIAN/'

    # Tree structure
    os.makedirs(debianDir)
    os.makedirs(buildDir+'/usr/bin/')
    os.makedirs(buildDir+'/usr/share/doc/qtodotxt')
    os.makedirs(buildDir+'/usr/share/applications')

    #Copy tag folder to build folder except the windows script
    copytree(tmpDir+folderName,buildDir+'/usr/share/qtodotxt',False,ignore_patterns('qtodotxt.pyw'))
    #Fix execution rights on bin folder
    for file in os.listdir(buildBinDir):
        filePath=os.path.join(buildBinDir,file)
        if os.path.isfile(filePath):
            st = os.stat(filePath)
            os.chmod(filePath, st.st_mode | S_IEXEC)

    # Adding copyright file
    copy(scriptDir+'/copyright',buildDir+'/usr/share/doc/qtodotxt/copyright')
    # Adding desktop file
    copy(scriptDir+'/qtodotxt.desktop',buildDir+'/usr/share/applications/qtodotxt.desktop')
    # Adding changelog file
    f_in = open(scriptDir+'/changelog', 'rb')
    f_out = gzip.open(buildDir+'/usr/share/doc/qtodotxt/changelog.gz', 'wb')
    f_out.writelines(f_in)
    f_out.close()
    f_in.close()

    return (buildDir,debianDir)
项目:dockeroo    作者:dockeroo    | 项目源码 | 文件源码
def copy_tree(self, origin, destination, ignore=None):
        if os.path.exists(destination):
            raise shutil.Error(
                '''Destination already exists: "{}"'''.format(destination))
        self.logger.debug('Copying "%s" to "%s"', origin, destination)
        try:
            shutil.copytree(origin, destination,
                            ignore=shutil.ignore_patterns(*ignore or []))
        except (shutil.Error, OSError) as error:
            try:
                shutil.rmtree(destination, ignore_errors=True)
            except (shutil.Error, OSError) as strerror:
                self.logger.error('Error occurred when cleaning after error: "%s"', strerror)
            raise error
项目:elm-ops-tooling    作者:NoRedInk    | 项目源码 | 文件源码
def self_publish(package_location, destination=".", quiet=False):
    """ package_location should be the local package to install
    """

    elm_package_file = "{location}/elm-package.json".format(location=package_location)
    destination_elm_package_file = "{destination}/elm-package.json".format(destination=destination)

    exact_deps_file = "{destination}/elm-stuff/exact-dependencies.json".format(
        destination=destination,
        location=package_location
    )

    git_ignore_file = "{location}/.gitignore".format(location=package_location)


    with open(elm_package_file) as f:
        elm_package = json.load(f)


    package_details = package_name(elm_package['repository'])
    version = elm_package['version']


    place = package_details['user'] + '/' + package_details['project']


    copy_package(package_location, '{destination}/elm-stuff/packages/{place}/{version}'.format(
        place=place,
        version=version,
        destination=destination
    ), ignorer=shutil.ignore_patterns(*gitignores(git_ignore_file)))


    try:
        with open(exact_deps_file) as f:
            data = f.read()
            package_info = {}

            if data:
                package_info = json.loads(data)
    except IOError:
        package_info = {}

    make_elm_stuff_folder(exact_deps_file)

    with open(exact_deps_file, 'w') as f:
        package_info[place] = version
        json.dump(package_info, f, sort_keys=False, indent=4)

    with open(destination_elm_package_file) as f:
        destination_elm_package = json.load(f, object_pairs_hook=OrderedDict)

    with open(destination_elm_package_file, 'w') as f:
        destination_elm_package['dependencies'][place] = "{version} <= v <= {version}".format(version=version)
        json.dump(destination_elm_package, f, sort_keys=False, indent=4)