generates patches of src/ in packages/
 the latest commit marked as tarball is taken as the base version,
 other commits are assumed to be patches on top
 returns filenames
355375
def write_source_patches
      from_directory do
        id = @git.latest_id("tetra: sources-tarball")
        destination_path = File.join(full_path, packages_dir, name)
        @git.format_patch("src", id, destination_path)
      end
    end
701073
def get_versions(verbose=False):
    
    if "versioneer" in sys.modules:
        # see the discussion in cmdclass.py:get_cmdclass()
        del sys.modules["versioneer"]

    root = get_root()
    cfg = get_config_from_root(root)

    assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg"
    handlers = HANDLERS.get(cfg.VCS)
    assert handlers, "unrecognized VCS '%s'" % cfg.VCS
    verbose = verbose or cfg.verbose
    assert cfg.versionfile_source is not None, \
        "please set versioneer.versionfile_source"
    assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix"

    versionfile_abs = os.path.join(root, cfg.versionfile_source)

    # extract version from first of: _version.py, VCS command (e.g. 'git
    # describe'), parentdir. This is meant to work for developers using a
    # source checkout, for users of a tarball created by 'setup.py sdist',
    # and for users of a tarball/zipball created by 'git archive' or github's
    # download-from-tag feature or the equivalent in other VCSes.

    get_keywords_f = handlers.get("get_keywords")
    from_keywords_f = handlers.get("keywords")
    if get_keywords_f and from_keywords_f:
        try:
            keywords = get_keywords_f(versionfile_abs)
            ver = from_keywords_f(keywords, cfg.tag_prefix, verbose)
            if verbose:
                print("got version from expanded keyword %s" % ver)
            return ver
        except NotThisMethod:
            pass

    try:
        ver = versions_from_file(versionfile_abs)
        if verbose:
            print("got version from file %s %s" % (versionfile_abs, ver))
        return ver
    except NotThisMethod:
        pass

    from_vcs_f = handlers.get("pieces_from_vcs")
    if from_vcs_f:
        try:
            pieces = from_vcs_f(cfg.tag_prefix, root, verbose)
            ver = render(pieces, cfg.style)
            if verbose:
                print("got version from VCS %s" % ver)
            return ver
        except NotThisMethod:
            pass

    try:
        if cfg.parentdir_prefix:
            ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
            if verbose:
                print("got version from parentdir %s" % ver)
            return ver
    except NotThisMethod:
        pass

    if verbose:
        print("unable to compute version")

    return {"version": "0+unknown", "full-revisionid": None,
            "dirty": None, "error": "unable to compute version"}
267990
def upgrade(self):
        
        for pkg in self.upgrade_all:
            check_md5(pkg_checksum(pkg, "slack_patches"), self.patch_path + pkg)
            pkg_ver = "{0}-{1}".format(split_package(pkg)[0],
                                       split_package(pkg)[1])
            if find_package(split_package(pkg)[0] + self.meta.sp,
                            self.meta.pkg_path):
                print("[ {0}upgrading{1} ] --> {2}".format(
                    self.meta.color["YELLOW"], self.meta.color["ENDC"],
                    pkg[:-4]))
                PackageManager((self.patch_path + pkg).split()).upgrade(
                    "--install-new")
                self.upgraded.append(pkg_ver)
            else:
                print("[ {0}installing{1} ] --> {2}".format(
                    self.meta.color["GREEN"], self.meta.color["ENDC"],
                    pkg[:-4]))
                PackageManager((self.patch_path + pkg).split()).upgrade(
                    "--install-new")
                self.installed.append(pkg_ver)
583701
def create_packages_archive(packages, filename):
    
    import tarfile
    tar = tarfile.open(filename, "w")

    def add(src, dst):
        logger.debug('adding to tar: %s -> %s', src, dst)
        tar.add(src, dst)

    def add_files_for_package(sub_package_path, root_package_path, root_package_name):
        for root, dirs, files in os.walk(sub_package_path):
            if '.svn' in dirs:
                dirs.remove('.svn')
            for f in files:
                if not f.endswith(".pyc") and not f.startswith("."):
                    add(dereference(root + "/" + f), root.replace(root_package_path, root_package_name) + "/" + f)

    for package in packages:
        # Put a submodule's entire package in the archive. This is the
        # magic that usually packages everything you need without
        # having to attach packages/modules explicitly
        if not getattr(package, "__path__", None) and '.' in package.__name__:
            package = __import__(package.__name__.rpartition('.')[0], None, None, 'non_empty')

        n = package.__name__.replace(".", "/")

        if getattr(package, "__path__", None):
            # TODO: (BUG) picking only the first path does not
            # properly deal with namespaced packages in different
            # directories
            p = package.__path__[0]

            if p.endswith('.egg') and os.path.isfile(p):
                raise 'egg files not supported!!!'
                # Add the entire egg file
                # p = p[:p.find('.egg') + 4]
                # add(dereference(p), os.path.basename(p))

            else:
                # include __init__ files from parent projects
                root = []
                for parent in package.__name__.split('.')[0:-1]:
                    root.append(parent)
                    module_name = '.'.join(root)
                    directory = '/'.join(root)

                    add(dereference(__import__(module_name, None, None, 'non_empty').__path__[0] + "/__init__.py"),
                        directory + "/__init__.py")

                add_files_for_package(p, p, n)

                # include egg-info directories that are parallel:
                for egg_info_path in glob.glob(p + '*.egg-info'):
                    logger.debug(
                        'Adding package metadata to archive for "%s" found at "%s"',
                        package.__name__,
                        egg_info_path
                    )
                    add_files_for_package(egg_info_path, p, n)

        else:
            f = package.__file__
            if f.endswith("pyc"):
                f = f[:-3] + "py"
            if n.find(".") == -1:
                add(dereference(f), os.path.basename(f))
            else:
                add(dereference(f), n + ".py")
    tar.close()
894605
def versions_installed(pkg):
    '''
    
    '''

    try:
        # Try to run it, merging stderr into output
        output = subprocess.check_output([SNAP_BINARY_NAME, 'list', pkg], stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError:
        return []

    lines = output.splitlines()[1:]
    ret = []
    for item in lines:
        # If fields contain spaces this will break.
        i = item.split()
        # Ignore 'Notes' field
        ret.append({
            'name':         i[0],
            'version':      i[1],
            'rev':          i[2],
            'tracking':     i[3],
            'publisher':    i[4]
            })

    return ret
386553
def copy_patches(ptches0):
        
        if not isinstance(ptches0, list):
            ptches0 = list(ptches0)
        copyed_ptches = []
        for pt in ptches0:
            pth = pt.get_path().deepcopy()
            ptch = patches.PathPatch(pth,
                                     lw=pt.get_lw(),
                                     fc=pt.get_fc(),
                                     ec=pt.get_ec(),
                                     alpha=pt.get_alpha())
            copyed_ptches.append(ptch)
        return copyed_ptches
586347
def get_versions(default=DEFAULT, verbose=False):
    """"""


    # returns dict with two keys: 'version' and 'full'
    assert versionfile_source is not None, "please set versioneer.versionfile_source"
    assert tag_prefix is not None, "please set versioneer.tag_prefix"
    assert parentdir_prefix is not None, "please set versioneer.parentdir_prefix"
    assert VCS is not None, "please set versioneer.VCS"

    # I am in versioneer.py, which must live at the top of the source tree,
    # which we use to compute the root directory. py2exe/bbfreeze/non-CPython
    # don't have __file__, in which case we fall back to sys.argv[0] (which
    # ought to be the setup.py script). We prefer __file__ since that's more
    # robust in cases where setup.py was invoked in some weird way (e.g. pip)
    root = get_root()
    versionfile_abs = os.path.join(root, versionfile_source)

    # extract version from first of _version.py, VCS command (e.g. 'git
    # describe'), parentdir. This is meant to work for developers using a
    # source checkout, for users of a tarball created by 'setup.py sdist',
    # and for users of a tarball/zipball created by 'git archive' or github's
    # download-from-tag feature or the equivalent in other VCSes.

    # Try to get the version info from the VCS-specific replacement keywords.

    get_keywords_f = vcs_function(VCS, "get_keywords")
    versions_from_keywords_f = vcs_function(VCS, "versions_from_keywords")
    if get_keywords_f and versions_from_keywords_f:
        vcs_keywords = get_keywords_f(versionfile_abs)
        ver = versions_from_keywords_f(vcs_keywords, tag_prefix)
        if ver:
            if verbose: print("got version from expanded keyword %s" % ver)
            return ver

    # Try to get the version info from _version.py .

    ver = versions_from_file(versionfile_abs)
    if ver:
        if verbose: print("got version from file %s %s" % (versionfile_abs,ver))
        return ver

    # Try to get the version info from the VCS, directly.

    versions_from_vcs_f = vcs_function(VCS, "versions_from_vcs")
    if versions_from_vcs_f:
        ver = versions_from_vcs_f(tag_prefix, root, verbose)
        if ver:
            if verbose: print("got version from VCS %s" % ver)
            return ver

    # Try to get the version info from the directory's naming.

    ver = versions_from_parentdir(parentdir_prefix, root, verbose)
    if ver:
        if verbose: print("got version from parentdir %s" % ver)
        return ver

    if verbose: print("got version from default %s" % default)
    return default
1141670
def patch_modules():
    
    old_call = subprocess.call

    def dummy_call(*args, **kwargs):
        with tempfile.TemporaryFile("wb+") as f:
            kwargs["stdout"] = f
            kwargs["stderr"] = f
            rv = subprocess.Popen(*args, **kwargs).wait()
            f.seek(0)
            click.echo(f.read().decode("utf-8", "replace").rstrip())
        return rv

    subprocess.call = dummy_call

    try:
        yield
    finally:
        subprocess.call = old_call
1188394
def _get_patches(installed_only=False):
    '''
    
    '''
    patches = {}

    cmd = [_yum(), '--quiet', 'updateinfo', 'list', 'all']
    ret = __salt__['cmd.run_stdout'](
        cmd,
        python_shell=False
    )
    for line in salt.utils.itertools.split(ret, os.linesep):
        inst, advisory_id, sev, pkg = re.match(r'([i|\s]) ([^\s]+) +([^\s]+) +([^\s]+)',
                                               line).groups()
        if inst != 'i' and installed_only:
            continue
        patches[advisory_id] = {
            'installed': True if inst == 'i' else False,
            'summary': pkg
        }
    return patches
663082
def package_version(self):
        """"""
        vbase = self.base_version
        if self.ncommits:
            vbase += '.dev{0}+{1}'.format(self.ncommits, self.sha)
        return vbase
712285
def _get_config_generator(filename):
    
    for d in _get_config(filename):
        repo = d['git']
        parsedrepo = giturlparse.parse(repo)
        name = '{}.{}'.format(parsedrepo.owner, parsedrepo.name)
        src_dir = os.path.join(_get_clone_dir(), name)
        files = d.get('files')
        post_commands = d.get('post_commands', [])
        dst_dir = None
        if not files:
            dst_dir = _get_dst_dir(d['dst'])
        yield {
            'git': repo,
            'lock_file': _get_lock_file(name),
            'version': d['version'],
            'name': name,
            'src': src_dir,
            'dst': dst_dir,
            'files': _get_files_config(src_dir, files),
            'post_commands': post_commands,
        }
649890
def get_commits_and_names_iter(self, path):
        '''
        
        '''
        log_result = self.git.log(
            '--pretty=%H',
            '--follow',
            '--name-only',
            '--',
            path).splitlines()

        for commit_sha, _, filename in grouper(log_result, 3):
            yield self.repo.commit(commit_sha), filename
784153
def get_version_list(path=None, module=None):
    
    major = 0
    minor = 0
    patch = ''  # PEP440 calls this prerelease, postrelease or devrelease
    ver = get_version(path, module)
    if ver is not None:
        ver_segments = _sane_version_list(ver.split(".", 2))
        major = ver_segments[0]
        minor = ver_segments[1]
        patch = ".".join(ver_segments[2:])  # Rejoin the .

    # Return None as first field, makes substitution easier in next step.
    return [None, major, minor, patch]
289575
def get_versioned_files(cls):
        """"""
        files = cls._git_ls_files()
        submodules = cls._list_submodules()
        for subdir in submodules:
            subdir = os.path.relpath(subdir).replace(os.path.sep, '/')
            files += add_prefix_to_each(subdir, cls._git_ls_files(subdir))
        return add_directories(files)
48918
def recent_changes(parent_path=nil, max=100, offset=0)
    log = []
    # this is more gollum proper, but we can't set the path
    # commits = @gollum_wiki.latest_changes(max_count: max)
    ref = @gollum_wiki.ref # probably 'master'
    commits = @gollum_wiki.repo.log(ref, parent_path, {limit: max, offset: offset})
    commits.each do |c|
      c.stats.files.each do |f|
        path = f[0]
        if parent_path && ! path.starts_with?(parent_path)
          # we don't want this one
        elsif File.extname(path) == '.md'
          path.chomp!('.md')
          log << {path: path, commit: c}
        end
      end
    end
    # if we're out of commits, return nil rather than []
    return commits.empty? ? nil : log
  end
332988
def get_urls(session, name, data, find_changelogs_fn, **kwargs):
    
    # if this package has valid meta data, build up a list of URL candidates we can possibly
    # search for changelogs on
    if "versions" in data:
        candidates = set()
        for version, item in data["versions"].items():
            if "homepage" in item and item["homepage"] is not None:
                if isinstance(item["homepage"], list):
                    candidates.add(*item["homepage"])
                else:
                    candidates.add(item["homepage"])
            if "repository" in item and item["repository"] is not None:
                if "url" in item["repository"]:
                    repo = item["repository"]["url"]
                elif "path" in item["repository"]:
                    repo = item["repository"]["path"]
                else:
                    continue
                repo = repo.replace("git://", "https://").replace(".git", "")
                candidates.add(repo)
        return find_changelogs_fn(session=session, name=name, candidates=candidates)
    return set(), set()
180806
def _get_patches(installed_only=False, root=None):
    '''
    
    '''
    patches = {}
    for element in __zypper__(root=root).nolock.xml.call('se', '-t', 'patch').getElementsByTagName('solvable'):
        installed = element.getAttribute('status') == 'installed'
        if (installed_only and installed) or not installed_only:
            patches[element.getAttribute('name')] = {
                'installed': installed,
                'summary': element.getAttribute('summary'),
            }

    return patches