Python shutil.ignore_patterns() Examples

The following are code examples for showing how to use shutil.ignore_patterns(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: build-calibre   Author: kovidgoyal   File: __init__.py    (license) View Source Project 7 votes vote down vote up
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) 
Example 2
Project: PyBackup   Author: FRReinert   File: backup.py    (license) View Source Project 6 votes vote down vote up
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)) 
Example 3
Project: blender-addon-updater   Author: CGCookie   File: addon_updater.py    (license) View Source Project 6 votes vote down vote up
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() 
Example 4
Project: lago   Author: lago-project   File: test_sdk_sanity.py    (license) View Source Project 6 votes vote down vote up
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() 
Example 5
Project: icnn   Author: locuslab   File: runtime_env.py    (license) View Source Project 6 votes vote down vote up
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 
Example 6
Project: mbuild   Author: intelxed   File: util.py    (license) View Source Project 6 votes vote down vote up
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) 
Example 7
Project: zoocore   Author: dsparrow27   File: filesystem.py    (GNU General Public License v3.0) View Source Project 5 votes vote down vote up
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 
Example 8
Project: devsecops-example-helloworld   Author: boozallen   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 9
Project: malboxes   Author: GoSecure   File: setup.py    (license) View Source Project 5 votes vote down vote up
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')) 
Example 10
Project: flasky   Author: RoseOu   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 11
Project: wq.start   Author: wq   File: projects.py    (license) View Source Project 5 votes vote down vote up
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"),
    ) 
Example 12
Project: qiime2   Author: qiime2   File: provenance.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 13
Project: leetcode   Author: thomasyimgit   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 14
Project: relocate-venv   Author: firedrakeproject   File: core.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 15
Project: FLASH   Author: yuyuz   File: setup.py    (license) View Source Project 5 votes vote down vote up
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 
Example 16
Project: ShuoshuoMonitor   Author: aploium   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 17
Project: siphon-cli   Author: getsiphon   File: create.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 18
Project: amazon_order_history_scraper   Author: drewctate   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 19
Project: webapp   Author: superchilli   File: firefox_profile.py    (license) View Source Project 5 votes vote down vote up
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 
Example 20
Project: config-sesame   Author: 1and1   File: tasks.py    (license) View Source Project 5 votes vote down vote up
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") 
Example 21
Project: ouroboros   Author: pybee   File: test_shutil.py    (license) View Source Project 5 votes vote down vote up
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)) 
Example 22
Project: skin.confluence.480   Author: YggdrasiI   File: buildPackage.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 23
Project: streamalert   Author: airbnb   File: package.py    (license) View Source Project 5 votes vote down vote up
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)) 
Example 24
Project: kibitzr   Author: kibitzr   File: fetcher.py    (license) View Source Project 5 votes vote down vote up
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",
        ),
    ) 
Example 25
Project: urnote   Author: urnote   File: filehandler.py    (license) View Source Project 5 votes vote down vote up
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 
Example 26
Project: urnote   Author: urnote   File: filehandler.py    (license) View Source Project 5 votes vote down vote up
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 
Example 27
Project: urnote   Author: urnote   File: filehandler.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 28
Project: urnote   Author: urnote   File: filehandler.py    (license) View Source Project 5 votes vote down vote up
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 
Example 29
Project: QTodoTxt2   Author: QTodoTxt   File: buildDebPackage.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 30
Project: dockeroo   Author: dockeroo   File: __init__.py    (license) View Source Project 5 votes vote down vote up
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 
Example 31
Project: elm-ops-tooling   Author: NoRedInk   File: elm_self_publish.py    (BSD 3-Clause "New" or "Revised" License) View Source Project 4 votes vote down vote up
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)