def _set(key, value):<EOL><INDENT>if key in _ATTR2FIELD and value:<EOL><INDENT>self.set(self._convert_name(key), value)<EOL><DEDENT><DEDENT>if not other:<EOL><INDENT>pass<EOL><DEDENT>elif hasattr(other, '<STR_LIT>'):<EOL><INDENT>for k in other.keys():<EOL><INDENT>_set(k, other[k])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for k, v in other:<EOL><INDENT>_set(k, v)<EOL><DEDENT><DEDENT>if kwargs:<EOL><INDENT>for k, v in kwargs.items():<EOL><INDENT>_set(k, v)<EOL><DEDENT><DEDENT>

Set metadata values from the given iterable `other` and kwargs.

        Behavior is like `dict.update`: If `other` has a ``keys`` method,
        they are looped over and ``self[key]`` is assigned ``other[key]``.
        Else, ``other`` is an iterable of ``(key, value)`` iterables.

        Keys that don't match a metadata field or that have an empty value are
        dropped.


name = self._convert_name(name)<EOL>if ((name in _ELEMENTSFIELD or name == '<STR_LIT>') and<EOL>not isinstance(value, (list, tuple))):<EOL><INDENT>if isinstance(value, string_types):<EOL><INDENT>value = [v.strip() for v in value.split('<STR_LIT:U+002C>')]<EOL><DEDENT>else:<EOL><INDENT>value = []<EOL><DEDENT><DEDENT>elif (name in _LISTFIELDS and<EOL>not isinstance(value, (list, tuple))):<EOL><INDENT>if isinstance(value, string_types):<EOL><INDENT>value = [value]<EOL><DEDENT>else:<EOL><INDENT>value = []<EOL><DEDENT><DEDENT>if logger.isEnabledFor(logging.WARNING):<EOL><INDENT>project_name = self['<STR_LIT:Name>']<EOL>scheme = get_scheme(self.scheme)<EOL>if name in _PREDICATE_FIELDS and value is not None:<EOL><INDENT>for v in value:<EOL><INDENT>if not scheme.is_valid_matcher(v.split('<STR_LIT:;>')[<NUM_LIT:0>]):<EOL><INDENT>logger.warning(<EOL>'<STR_LIT>',<EOL>project_name, v, name)<EOL><DEDENT><DEDENT><DEDENT>elif name in _VERSIONS_FIELDS and value is not None:<EOL><INDENT>if not scheme.is_valid_constraint_list(value):<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>project_name, value, name)<EOL><DEDENT><DEDENT>elif name in _VERSION_FIELDS and value is not None:<EOL><INDENT>if not scheme.is_valid_version(value):<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>project_name, value, name)<EOL><DEDENT><DEDENT><DEDENT>if name in _UNICODEFIELDS:<EOL><INDENT>if name == '<STR_LIT>':<EOL><INDENT>value = self._remove_line_prefix(value)<EOL><DEDENT><DEDENT>self._fields[name] = value<EOL>


name = self._convert_name(name)<EOL>if name not in self._fields:<EOL><INDENT>if default is _MISSING:<EOL><INDENT>default = self._default_value(name)<EOL><DEDENT>return default<EOL><DEDENT>if name in _UNICODEFIELDS:<EOL><INDENT>value = self._fields[name]<EOL>return value<EOL><DEDENT>elif name in _LISTFIELDS:<EOL><INDENT>value = self._fields[name]<EOL>if value is None:<EOL><INDENT>return []<EOL><DEDENT>res = []<EOL>for val in value:<EOL><INDENT>if name not in _LISTTUPLEFIELDS:<EOL><INDENT>res.append(val)<EOL><DEDENT>else:<EOL><INDENT>res.append((val[<NUM_LIT:0>], val[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>return res<EOL><DEDENT>elif name in _ELEMENTSFIELD:<EOL><INDENT>value = self._fields[name]<EOL>if isinstance(value, string_types):<EOL><INDENT>return value.split('<STR_LIT:U+002C>')<EOL><DEDENT><DEDENT>return self._fields[name]<EOL>


self.set_metadata_version()<EOL>missing, warnings = [], []<EOL>for attr in ('<STR_LIT:Name>', '<STR_LIT>'):  <EOL><INDENT>if attr not in self:<EOL><INDENT>missing.append(attr)<EOL><DEDENT><DEDENT>if strict and missing != []:<EOL><INDENT>msg = '<STR_LIT>' % '<STR_LIT:U+002CU+0020>'.join(missing)<EOL>raise MetadataMissingError(msg)<EOL><DEDENT>for attr in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if attr not in self:<EOL><INDENT>missing.append(attr)<EOL><DEDENT><DEDENT>if self['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>return missing, warnings<EOL><DEDENT>scheme = get_scheme(self.scheme)<EOL>def are_valid_constraints(value):<EOL><INDENT>for v in value:<EOL><INDENT>if not scheme.is_valid_matcher(v.split('<STR_LIT:;>')[<NUM_LIT:0>]):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>for fields, controller in ((_PREDICATE_FIELDS, are_valid_constraints),<EOL>(_VERSIONS_FIELDS,<EOL>scheme.is_valid_constraint_list),<EOL>(_VERSION_FIELDS,<EOL>scheme.is_valid_version)):<EOL><INDENT>for field in fields:<EOL><INDENT>value = self.get(field, None)<EOL>if value is not None and not controller(value):<EOL><INDENT>warnings.append('<STR_LIT>' % (field, value))<EOL><DEDENT><DEDENT><DEDENT>return missing, warnings<EOL>

Check if the metadata is compliant. If strict is True then raise if
        no Name or Version are provided


self.set_metadata_version()<EOL>mapping_1_0 = (<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT:name>', '<STR_LIT:Name>'),<EOL>('<STR_LIT:version>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT:description>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>)<EOL>data = {}<EOL>for key, field_name in mapping_1_0:<EOL><INDENT>if not skip_missing or field_name in self._fields:<EOL><INDENT>data[key] = self[field_name]<EOL><DEDENT><DEDENT>if self['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>mapping_1_2 = (<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>)<EOL>for key, field_name in mapping_1_2:<EOL><INDENT>if not skip_missing or field_name in self._fields:<EOL><INDENT>if key != '<STR_LIT>':<EOL><INDENT>data[key] = self[field_name]<EOL><DEDENT>else:<EOL><INDENT>data[key] = ['<STR_LIT:U+002C>'.join(u) for u in self[field_name]]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif self['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>mapping_1_1 = (<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>)<EOL>for key, field_name in mapping_1_1:<EOL><INDENT>if not skip_missing or field_name in self._fields:<EOL><INDENT>data[key] = self[field_name]<EOL><DEDENT><DEDENT><DEDENT>return data<EOL>

Return fields as a dict.

        Field names will be converted to use the underscore-lowercase style
        instead of hyphen-mixed case (i.e. home_page instead of Home-page).


def get_requirements(self, reqts, extras=None, env=None):

if self._legacy:<EOL><INDENT>result = reqts<EOL><DEDENT>else:<EOL><INDENT>result = []<EOL>extras = get_extras(extras or [], self.extras)<EOL>for d in reqts:<EOL><INDENT>if '<STR_LIT>' not in d and '<STR_LIT>' not in d:<EOL><INDENT>include = True<EOL><DEDENT>else:<EOL><INDENT>if '<STR_LIT>' not in d:<EOL><INDENT>include = True<EOL><DEDENT>else:<EOL><INDENT>include = d.get('<STR_LIT>') in extras<EOL><DEDENT>if include:<EOL><INDENT>marker = d.get('<STR_LIT>')<EOL>if marker:<EOL><INDENT>include = interpret(marker, env)<EOL><DEDENT><DEDENT><DEDENT>if include:<EOL><INDENT>result.extend(d['<STR_LIT>'])<EOL><DEDENT><DEDENT>for key in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT:test>'):<EOL><INDENT>e = '<STR_LIT>' % key<EOL>if e in extras:<EOL><INDENT>extras.remove(e)<EOL>reqts = self._data.get('<STR_LIT>' % key, [])<EOL>result.extend(self.get_requirements(reqts, extras=extras,<EOL>env=env))<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>

Base method to get dependencies, given a set of extras
to satisfy and an optional environment context.
:param reqts: A list of sometimes-wanted dependencies,
              perhaps dependent on extras and environment.
:param extras: A list of optional components being requested.
:param env: An optional environment for marker evaluation.


scheme = get_scheme(scheme)<EOL>graph = DependencyGraph()<EOL>provided = {}  <EOL>for dist in dists:<EOL><INDENT>graph.add_distribution(dist)<EOL>for p in dist.provides:<EOL><INDENT>name, version = parse_name_and_version(p)<EOL>logger.debug('<STR_LIT>', name, version, dist)<EOL>provided.setdefault(name, []).append((version, dist))<EOL><DEDENT><DEDENT>for dist in dists:<EOL><INDENT>requires = (dist.run_requires | dist.meta_requires |<EOL>dist.build_requires | dist.dev_requires)<EOL>for req in requires:<EOL><INDENT>try:<EOL><INDENT>matcher = scheme.matcher(req)<EOL><DEDENT>except UnsupportedVersionError:<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>req)<EOL>name = req.split()[<NUM_LIT:0>]<EOL>matcher = scheme.matcher(name)<EOL><DEDENT>name = matcher.key   <EOL>matched = False<EOL>if name in provided:<EOL><INDENT>for version, provider in provided[name]:<EOL><INDENT>try:<EOL><INDENT>match = matcher.match(version)<EOL><DEDENT>except UnsupportedVersionError:<EOL><INDENT>match = False<EOL><DEDENT>if match:<EOL><INDENT>graph.add_edge(dist, provider, req)<EOL>matched = True<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if not matched:<EOL><INDENT>graph.add_missing(dist, req)<EOL><DEDENT><DEDENT><DEDENT>return graph<EOL>

Makes a dependency graph from the given distributions.

    :parameter dists: a list of distributions
    :type dists: list of :class:`distutils2.database.InstalledDistribution` and
                 :class:`distutils2.database.EggInfoDistribution` instances
    :rtype: a :class:`DependencyGraph` instance


if dist not in dists:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>' % dist.name)<EOL><DEDENT>graph = make_graph(dists)<EOL>dep = [dist]  <EOL>todo = graph.reverse_list[dist]  <EOL>while todo:<EOL><INDENT>d = todo.pop()<EOL>dep.append(d)<EOL>for succ in graph.reverse_list[d]:<EOL><INDENT>if succ not in dep:<EOL><INDENT>todo.append(succ)<EOL><DEDENT><DEDENT><DEDENT>dep.pop(<NUM_LIT:0>)  <EOL>return dep<EOL>

Recursively generate a list of distributions from *dists* that are
    dependent on *dist*.

    :param dists: a list of distributions
    :param dist: a distribution, member of *dists* for which we are interested


if dist not in dists:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>' % dist.name)<EOL><DEDENT>graph = make_graph(dists)<EOL>req = []  <EOL>todo = graph.adjacency_list[dist]  <EOL>while todo:<EOL><INDENT>d = todo.pop()[<NUM_LIT:0>]<EOL>req.append(d)<EOL>for pred in graph.adjacency_list[d]:<EOL><INDENT>if pred not in req:<EOL><INDENT>todo.append(pred)<EOL><DEDENT><DEDENT><DEDENT>return req<EOL>

Recursively generate a list of distributions from *dists* that are
    required by *dist*.

    :param dists: a list of distributions
    :param dist: a distribution, member of *dists* for which we are interested


summary = kwargs.pop('<STR_LIT>', '<STR_LIT>')<EOL>md = Metadata(**kwargs)<EOL>md.name = name<EOL>md.version = version<EOL>md.summary = summary or '<STR_LIT>'<EOL>return Distribution(md)<EOL>

A convenience method for making a dist given just a name and version.


self.name = {}<EOL>self.path = {}<EOL>self.generated = False<EOL>

Initialise an instance. There is normally one for each DistributionPath.


self.name.clear()<EOL>self.path.clear()<EOL>self.generated = False<EOL>

Clear the cache, setting it to its initial state.


if dist.path not in self.path:<EOL><INDENT>self.path[dist.path] = dist<EOL>self.name.setdefault(dist.key, []).append(dist)<EOL><DEDENT>

Add a distribution to the cache.
:param dist: The distribution to add.


def __init__(self, path=None, include_egg=False):

if path is None:<EOL><INDENT>path = sys.path<EOL><DEDENT>self.path = path<EOL>self._include_dist = True<EOL>self._include_egg = include_egg<EOL>self._cache = _Cache()<EOL>self._cache_egg = _Cache()<EOL>self._cache_enabled = True<EOL>self._scheme = get_scheme('<STR_LIT:default>')<EOL>

Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
             sys.path is used.
:param include_egg: If True, this instance will look for and return legacy
                    distributions as well as those based on PEP 376.


self._cache.clear()<EOL>self._cache_egg.clear()<EOL>


<EOL>seen = set()<EOL>for path in self.path:<EOL><INDENT>finder = resources.finder_for_path(path)<EOL>if finder is None:<EOL><INDENT>continue<EOL><DEDENT>r = finder.find('<STR_LIT>')<EOL>if not r or not r.is_container:<EOL><INDENT>continue<EOL><DEDENT>rset = sorted(r.resources)<EOL>for entry in rset:<EOL><INDENT>r = finder.find(entry)<EOL>if not r or r.path in seen:<EOL><INDENT>continue<EOL><DEDENT>if self._include_dist and entry.endswith(DISTINFO_EXT):<EOL><INDENT>metadata_path = posixpath.join(entry, METADATA_FILENAME)<EOL>pydist = finder.find(metadata_path)<EOL>if not pydist:<EOL><INDENT>continue<EOL><DEDENT>metadata = Metadata(fileobj=pydist.as_stream(),<EOL>scheme='<STR_LIT>')<EOL>logger.debug('<STR_LIT>', r.path)<EOL>seen.add(r.path)<EOL>yield new_dist_class(r.path, metadata=metadata,<EOL>env=self)<EOL><DEDENT>elif self._include_egg and entry.endswith(('<STR_LIT>',<EOL>'<STR_LIT>')):<EOL><INDENT>logger.debug('<STR_LIT>', r.path)<EOL>seen.add(r.path)<EOL>yield old_dist_class(r.path, self)<EOL><DEDENT><DEDENT><DEDENT>

Yield .dist-info and/or .egg(-info) distributions.


gen_dist = not self._cache.generated<EOL>gen_egg = self._include_egg and not self._cache_egg.generated<EOL>if gen_dist or gen_egg:<EOL><INDENT>for dist in self._yield_distributions():<EOL><INDENT>if isinstance(dist, InstalledDistribution):<EOL><INDENT>self._cache.add(dist)<EOL><DEDENT>else:<EOL><INDENT>self._cache_egg.add(dist)<EOL><DEDENT><DEDENT>if gen_dist:<EOL><INDENT>self._cache.generated = True<EOL><DEDENT>if gen_egg:<EOL><INDENT>self._cache_egg.generated = True<EOL><DEDENT><DEDENT>

Scan the path for distributions and populate the cache with
those that are found.


@classmethod<EOL><INDENT>def distinfo_dirname(cls, name, version):<DEDENT>

name = name.replace('<STR_LIT:->', '<STR_LIT:_>')<EOL>return '<STR_LIT:->'.join([name, version]) + DISTINFO_EXT<EOL>

The *name* and *version* parameters are converted into their
filename-escaped form, i.e. any ``'-'`` characters are replaced
with ``'_'`` other than the one in ``'dist-info'`` and the one
separating the name from the version number.

:parameter name: is converted to a standard distribution name by replacing
                 any runs of non- alphanumeric characters with a single
                 ``'-'``.
:type name: string
:parameter version: is converted to a standard version string. Spaces
                    become dots, and all other non-alphanumeric characters
                    (except dots) become dashes, with runs of multiple
                    dashes condensed to a single dash.
:type version: string
:returns: directory name
:rtype: string


if not self._cache_enabled:<EOL><INDENT>for dist in self._yield_distributions():<EOL><INDENT>yield dist<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._generate_cache()<EOL>for dist in self._cache.path.values():<EOL><INDENT>yield dist<EOL><DEDENT>if self._include_egg:<EOL><INDENT>for dist in self._cache_egg.path.values():<EOL><INDENT>yield dist<EOL><DEDENT><DEDENT><DEDENT>

Provides an iterator that looks for distributions and returns
:class:`InstalledDistribution` or
:class:`EggInfoDistribution` instances for each one of them.

:rtype: iterator of :class:`InstalledDistribution` and
        :class:`EggInfoDistribution` instances


result = None<EOL>name = name.lower()<EOL>if not self._cache_enabled:<EOL><INDENT>for dist in self._yield_distributions():<EOL><INDENT>if dist.key == name:<EOL><INDENT>result = dist<EOL>break<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self._generate_cache()<EOL>if name in self._cache.name:<EOL><INDENT>result = self._cache.name[name][<NUM_LIT:0>]<EOL><DEDENT>elif self._include_egg and name in self._cache_egg.name:<EOL><INDENT>result = self._cache_egg.name[name][<NUM_LIT:0>]<EOL><DEDENT><DEDENT>return result<EOL>

Looks for a named distribution on the path.

This function only returns the first result found, as no more than one
value is expected. If nothing is found, ``None`` is returned.

:rtype: :class:`InstalledDistribution`, :class:`EggInfoDistribution`
        or ``None``


def provides_distribution(self, name, version=None):

matcher = None<EOL>if not version is None:<EOL><INDENT>try:<EOL><INDENT>matcher = self._scheme.matcher('<STR_LIT>' % (name, version))<EOL><DEDENT>except ValueError:<EOL><INDENT>raise DistlibException('<STR_LIT>' %<EOL>(name, version))<EOL><DEDENT><DEDENT>for dist in self.get_distributions():<EOL><INDENT>provided = dist.provides<EOL>for p in provided:<EOL><INDENT>p_name, p_ver = parse_name_and_version(p)<EOL>if matcher is None:<EOL><INDENT>if p_name == name:<EOL><INDENT>yield dist<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if p_name == name and matcher.match(p_ver):<EOL><INDENT>yield dist<EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>

Iterates over all distributions to find which distributions provide *name*.
If a *version* is provided, it will be used to filter the results.

This function only returns the first result found, since no more than
one values are expected. If the directory is not found, returns ``None``.

:parameter version: a version specifier that indicates the version
                    required, conforming to the format in ``PEP-345``

:type name: string
:type version: string


def get_file_path(self, name, relative_path):

dist = self.get_distribution(name)<EOL>if dist is None:<EOL><INDENT>raise LookupError('<STR_LIT>' % name)<EOL><DEDENT>return dist.get_resource_path(relative_path)<EOL>


def get_exported_entries(self, category, name=None):

for dist in self.get_distributions():<EOL><INDENT>r = dist.exports<EOL>if category in r:<EOL><INDENT>d = r[category]<EOL>if name is not None:<EOL><INDENT>if name in d:<EOL><INDENT>yield d[name]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for v in d.values():<EOL><INDENT>yield v<EOL><DEDENT><DEDENT><DEDENT><DEDENT>

Return all of the exported entries in a particular category.

:param category: The category to search for entries.
:param name: If specified, only entries with that name are returned.


self.metadata = metadata<EOL>self.name = metadata.name<EOL>self.key = self.name.lower()    <EOL>self.version = metadata.version<EOL>self.locator = None<EOL>self.digest = None<EOL>self.extras = None      <EOL>self.context = None     <EOL>self.download_urls = set()<EOL>self.digests = {}<EOL>

Initialise an instance.
:param metadata: The instance of :class:`Metadata` describing this
distribution.


return self.metadata.source_url<EOL>

The source archive download URL for this distribution.


return '<STR_LIT>' % (self.name, self.version)<EOL>

A utility property which displays the name and version in parentheses.


plist = self.metadata.provides<EOL>s = '<STR_LIT>' % (self.name, self.version)<EOL>if s not in plist:<EOL><INDENT>plist.append(s)<EOL><DEDENT>return plist<EOL>

A set of distribution names and versions provided by this distribution.
:return: A set of "name (version)" strings.


<EOL>r = parse_requirement(req)<EOL>scheme = get_scheme(self.metadata.scheme)<EOL>try:<EOL><INDENT>matcher = scheme.matcher(r.requirement)<EOL><DEDENT>except UnsupportedVersionError:<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>req)<EOL>name = req.split()[<NUM_LIT:0>]<EOL>matcher = scheme.matcher(name)<EOL><DEDENT>name = matcher.key   <EOL>result = False<EOL>for p in self.provides:<EOL><INDENT>p_name, p_ver = parse_name_and_version(p)<EOL>if p_name != name:<EOL><INDENT>continue<EOL><DEDENT>try:<EOL><INDENT>result = matcher.match(p_ver)<EOL>break<EOL><DEDENT>except UnsupportedVersionError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return result<EOL>

Say if this instance matches (fulfills) a requirement.
:param req: The requirement to match.
:rtype req: str
:return: True if it matches, else False.


if self.source_url:<EOL><INDENT>suffix = '<STR_LIT>' % self.source_url<EOL><DEDENT>else:<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT>return '<STR_LIT>' % (self.name, self.version, suffix)<EOL>

Return a textual representation of this instance,


if type(other) is not type(self):<EOL><INDENT>result = False<EOL><DEDENT>else:<EOL><INDENT>result = (self.name == other.name and<EOL>self.version == other.version and<EOL>self.source_url == other.source_url)<EOL><DEDENT>return result<EOL>

See if this distribution is the same as another.
:param other: The distribution to compare with. To be equal to one
              another. distributions must have the same type, name,
              version and source_url.
:return: True if it is the same, else False.


return hash(self.name) + hash(self.version) + hash(self.source_url)<EOL>

Compute hash in a way which matches the equality test.


def __init__(self, metadata, path, env=None):

super(BaseInstalledDistribution, self).__init__(metadata)<EOL>self.path = path<EOL>self.dist_path = env<EOL>

Initialise an instance.
:param metadata: An instance of :class:`Metadata` which describes the
                 distribution. This will normally have been initialised
                 from a metadata file in the ``path``.
:param path:     The path of the ``.dist-info`` or ``.egg-info``
                 directory for the distribution.
:param env:      This is normally the :class:`DistributionPath`
                 instance where this distribution was found.


if hasher is None:<EOL><INDENT>hasher = self.hasher<EOL><DEDENT>if hasher is None:<EOL><INDENT>hasher = hashlib.md5<EOL>prefix = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>hasher = getattr(hashlib, hasher)<EOL>prefix = '<STR_LIT>' % self.hasher<EOL><DEDENT>digest = hasher(data).digest()<EOL>digest = base64.urlsafe_b64encode(digest).rstrip(b'<STR_LIT:=>').decode('<STR_LIT:ascii>')<EOL>return '<STR_LIT>' % (prefix, digest)<EOL>

Get the hash of some data, using a particular hash algorithm, if
specified.

:param data: The data to be hashed.
:type data: bytes
:param hasher: The name of a hash implementation, supported by hashlib,
               or ``None``. Examples of valid values are ``'sha1'``,
               ``'sha224'``, ``'sha384'``, '``sha256'``, ``'md5'`` and
               ``'sha512'``. If no hasher is specified, the ``hasher``
               attribute of the :class:`InstalledDistribution` instance
               is used. If the hasher is determined to be ``None``, MD5
               is used as the hashing algorithm.
:returns: The hash of the data. If a hasher was explicitly specified,
          the returned hash will be prefixed with the specified hasher
          followed by '='.
:rtype: str


results = []<EOL>r = self.get_distinfo_resource('<STR_LIT>')<EOL>with contextlib.closing(r.as_stream()) as stream:<EOL><INDENT>with CSVReader(stream=stream) as record_reader:<EOL><INDENT>for row in record_reader:<EOL><INDENT>missing = [None for i in range(len(row), <NUM_LIT:3>)]<EOL>path, checksum, size = row + missing<EOL>results.append((path, checksum, size))<EOL><DEDENT><DEDENT><DEDENT>return results<EOL>

Get the list of installed files for the distribution
:return: A list of tuples of path, hash and size. Note that hash and
         size might be ``None`` for some entries. The path is exactly
         as stored in the file (which is as in PEP 376).


result = {}<EOL>r = self.get_distinfo_resource(EXPORTS_FILENAME)<EOL>if r:<EOL><INDENT>result = self.read_exports()<EOL><DEDENT>return result<EOL>

Return the information exported by this distribution.
:return: A dictionary of exports, mapping an export category to a dict
         of :class:`ExportEntry` instances describing the individual
         export entries, and keyed by name.


result = {}<EOL>r = self.get_distinfo_resource(EXPORTS_FILENAME)<EOL>if r:<EOL><INDENT>with contextlib.closing(r.as_stream()) as stream:<EOL><INDENT>result = read_exports(stream)<EOL><DEDENT><DEDENT>return result<EOL>

Read exports data from a file in .ini format.

:return: A dictionary of exports, mapping an export category to a list
         of :class:`ExportEntry` instances describing the individual
         export entries.


rf = self.get_distinfo_file(EXPORTS_FILENAME)<EOL>with open(rf, '<STR_LIT:w>') as f:<EOL><INDENT>write_exports(exports, f)<EOL><DEDENT>

Write a dictionary of exports to a file in .ini format.
:param exports: A dictionary of exports, mapping an export category to
                a list of :class:`ExportEntry` instances describing the
                individual export entries.


r = self.get_distinfo_resource('<STR_LIT>')<EOL>with contextlib.closing(r.as_stream()) as stream:<EOL><INDENT>with CSVReader(stream=stream) as resources_reader:<EOL><INDENT>for relative, destination in resources_reader:<EOL><INDENT>if relative == relative_path:<EOL><INDENT>return destination<EOL><DEDENT><DEDENT><DEDENT><DEDENT>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>' % relative_path)<EOL>

NOTE: This API may change in the future.

Return the absolute path to a resource file with the given relative
path.

:param relative_path: The path, relative to .dist-info, of the resource
                      of interest.
:return: The absolute path where the resource is to be found.


for result in self._get_records():<EOL><INDENT>yield result<EOL><DEDENT>

Iterates over the ``RECORD`` entries and returns a tuple
``(path, hash, size)`` for each line.

:returns: iterator of (path, hash, size)


def write_installed_files(self, paths, prefix, dry_run=False):

prefix = os.path.join(prefix, '<STR_LIT>')<EOL>base = os.path.dirname(self.path)<EOL>base_under_prefix = base.startswith(prefix)<EOL>base = os.path.join(base, '<STR_LIT>')<EOL>record_path = self.get_distinfo_file('<STR_LIT>')<EOL>logger.info('<STR_LIT>', record_path)<EOL>if dry_run:<EOL><INDENT>return None<EOL><DEDENT>with CSVWriter(record_path) as writer:<EOL><INDENT>for path in paths:<EOL><INDENT>if os.path.isdir(path) or path.endswith(('<STR_LIT>', '<STR_LIT>')):<EOL><INDENT>hash_value = size = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>size = '<STR_LIT>' % os.path.getsize(path)<EOL>with open(path, '<STR_LIT:rb>') as fp:<EOL><INDENT>hash_value = self.get_hash(fp.read())<EOL><DEDENT><DEDENT>if path.startswith(base) or (base_under_prefix and<EOL>path.startswith(prefix)):<EOL><INDENT>path = os.path.relpath(path, base)<EOL><DEDENT>writer.writerow((path, hash_value, size))<EOL><DEDENT>if record_path.startswith(base):<EOL><INDENT>record_path = os.path.relpath(record_path, base)<EOL><DEDENT>writer.writerow((record_path, '<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>return record_path<EOL>

Writes the ``RECORD`` file, using the ``paths`` iterable passed in. Any
existing ``RECORD`` file is silently overwritten.

prefix is used to determine when to write absolute paths.


mismatches = []<EOL>base = os.path.dirname(self.path)<EOL>record_path = self.get_distinfo_file('<STR_LIT>')<EOL>for path, hash_value, size in self.list_installed_files():<EOL><INDENT>if not os.path.isabs(path):<EOL><INDENT>path = os.path.join(base, path)<EOL><DEDENT>if path == record_path:<EOL><INDENT>continue<EOL><DEDENT>if not os.path.exists(path):<EOL><INDENT>mismatches.append((path, '<STR_LIT>', True, False))<EOL><DEDENT>elif os.path.isfile(path):<EOL><INDENT>actual_size = str(os.path.getsize(path))<EOL>if size and actual_size != size:<EOL><INDENT>mismatches.append((path, '<STR_LIT:size>', size, actual_size))<EOL><DEDENT>elif hash_value:<EOL><INDENT>if '<STR_LIT:=>' in hash_value:<EOL><INDENT>hasher = hash_value.split('<STR_LIT:=>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>hasher = None<EOL><DEDENT>with open(path, '<STR_LIT:rb>') as f:<EOL><INDENT>actual_hash = self.get_hash(f.read(), hasher)<EOL>if actual_hash != hash_value:<EOL><INDENT>mismatches.append((path, '<STR_LIT>', hash_value, actual_hash))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return mismatches<EOL>

Checks that the hashes and sizes of the files in ``RECORD`` are
matched by the files themselves. Returns a (possibly empty) list of
mismatches. Each entry in the mismatch list will be a tuple consisting
of the path, 'exists', 'size' or 'hash' according to what didn't match
(existence is checked first, then size, then hash), the expected
value and the actual value.


result = {}<EOL>shared_path = os.path.join(self.path, '<STR_LIT>')<EOL>if os.path.isfile(shared_path):<EOL><INDENT>with codecs.open(shared_path, '<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>lines = f.read().splitlines()<EOL><DEDENT>for line in lines:<EOL><INDENT>key, value = line.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL>if key == '<STR_LIT>':<EOL><INDENT>result.setdefault(key, []).append(value)<EOL><DEDENT>else:<EOL><INDENT>result[key] = value<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>

A dictionary of shared locations whose keys are in the set 'prefix',
'purelib', 'platlib', 'scripts', 'headers', 'data' and 'namespace'.
The corresponding value is the absolute path of that category for
this distribution, and takes into account any paths selected by the
user at installation time (e.g. via command-line arguments). In the
case of the 'namespace' key, this would be a list of absolute paths
for the roots of namespace packages in this distribution.

The first time this property is accessed, the relevant information is
read from the SHARED file in the .dist-info directory.


def write_shared_locations(self, paths, dry_run=False):

shared_path = os.path.join(self.path, '<STR_LIT>')<EOL>logger.info('<STR_LIT>', shared_path)<EOL>if dry_run:<EOL><INDENT>return None<EOL><DEDENT>lines = []<EOL>for key in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:data>'):<EOL><INDENT>path = paths[key]<EOL>if os.path.isdir(paths[key]):<EOL><INDENT>lines.append('<STR_LIT>' % (key,  path))<EOL><DEDENT><DEDENT>for ns in paths.get('<STR_LIT>', ()):<EOL><INDENT>lines.append('<STR_LIT>' % ns)<EOL><DEDENT>with codecs.open(shared_path, '<STR_LIT:w>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>f.write('<STR_LIT:\n>'.join(lines))<EOL><DEDENT>return shared_path<EOL>

Write shared location information to the SHARED file in .dist-info.
:param paths: A dictionary as described in the documentation for
:meth:`shared_locations`.
:param dry_run: If True, the action is logged but no file is actually
                written.
:return: The path of the file written to.


<EOL>if path.find(os.sep) >= <NUM_LIT:0>:<EOL><INDENT>distinfo_dirname, path = path.split(os.sep)[-<NUM_LIT:2>:]<EOL>if distinfo_dirname != self.path.split(os.sep)[-<NUM_LIT:1>]:<EOL><INDENT>raise DistlibException(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % (path, self.name, self.version))<EOL><DEDENT><DEDENT>if path not in DIST_FILES:<EOL><INDENT>raise DistlibException('<STR_LIT>'<EOL>'<STR_LIT>' % (path, self.path))<EOL><DEDENT>return os.path.join(self.path, path)<EOL>

Returns a path located under the ``.dist-info`` directory. Returns a
string representing the path.

:parameter path: a ``'/'``-separated path relative to the
                 ``.dist-info`` directory or an absolute path;
                 If *path* is an absolute path and doesn't start
                 with the ``.dist-info`` directory path,
                 a :class:`DistlibException` is raised
:type path: str
:rtype: str


base = os.path.dirname(self.path)<EOL>for path, checksum, size in self._get_records():<EOL><INDENT>if not os.path.isabs(path):<EOL><INDENT>path = os.path.join(base, path)<EOL><DEDENT>if path.startswith(self.path):<EOL><INDENT>yield path<EOL><DEDENT><DEDENT>

Iterates over the ``RECORD`` entries and returns paths for each line if
the path is pointing to a file located in the ``.dist-info`` directory
or one of its subdirectories.

:returns: iterator of paths


mismatches = []<EOL>record_path = os.path.join(self.path, '<STR_LIT>')<EOL>if os.path.exists(record_path):<EOL><INDENT>for path, _, _ in self.list_installed_files():<EOL><INDENT>if path == record_path:<EOL><INDENT>continue<EOL><DEDENT>if not os.path.exists(path):<EOL><INDENT>mismatches.append((path, '<STR_LIT>', True, False))<EOL><DEDENT><DEDENT><DEDENT>return mismatches<EOL>


def _md5(path):<EOL><INDENT>f = open(path, '<STR_LIT:rb>')<EOL>try:<EOL><INDENT>content = f.read()<EOL><DEDENT>finally:<EOL><INDENT>f.close()<EOL><DEDENT>return hashlib.md5(content).hexdigest()<EOL><DEDENT>def _size(path):<EOL><INDENT>return os.stat(path).st_size<EOL><DEDENT>record_path = os.path.join(self.path, '<STR_LIT>')<EOL>result = []<EOL>if os.path.exists(record_path):<EOL><INDENT>with codecs.open(record_path, '<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>for line in f:<EOL><INDENT>line = line.strip()<EOL>p = os.path.normpath(os.path.join(self.path, line))<EOL>if not os.path.exists(p):<EOL><INDENT>logger.warning('<STR_LIT>', p)<EOL>if p.endswith(('<STR_LIT>', '<STR_LIT>')):<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if not os.path.isdir(p):<EOL><INDENT>result.append((p, _md5(p), _size(p)))<EOL><DEDENT><DEDENT><DEDENT>result.append((record_path, None, None))<EOL><DEDENT>return result<EOL>

Iterates over the ``installed-files.txt`` entries and returns a tuple
``(path, hash, size)`` for each line.

:returns: a list of (path, hash, size)


record_path = os.path.join(self.path, '<STR_LIT>')<EOL>skip = True<EOL>with codecs.open(record_path, '<STR_LIT:r>', encoding='<STR_LIT:utf-8>') as f:<EOL><INDENT>for line in f:<EOL><INDENT>line = line.strip()<EOL>if line == '<STR_LIT>':<EOL><INDENT>skip = False<EOL>continue<EOL><DEDENT>if not skip:<EOL><INDENT>p = os.path.normpath(os.path.join(self.path, line))<EOL>if p.startswith(self.path):<EOL><INDENT>if absolute:<EOL><INDENT>yield p<EOL><DEDENT>else:<EOL><INDENT>yield line<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>

Iterates over the ``installed-files.txt`` entries and returns paths for
each line if the path is pointing to a file located in the
``.egg-info`` directory or one of its subdirectories.

:parameter absolute: If *absolute* is ``True``, each returned path is
                  transformed into a local absolute path. Otherwise the
                  raw value from ``installed-files.txt`` is returned.
:type absolute: boolean
:returns: iterator of paths


self.adjacency_list[distribution] = []<EOL>self.reverse_list[distribution] = []<EOL>

Add the *distribution* to the graph.

        :type distribution: :class:`distutils2.database.InstalledDistribution`
                            or :class:`distutils2.database.EggInfoDistribution`


self.adjacency_list[x].append((y, label))<EOL>if x not in self.reverse_list[y]:<EOL><INDENT>self.reverse_list[y].append(x)<EOL><DEDENT>

Add an edge from distribution *x* to distribution *y* with the given
        *label*.

        :type x: :class:`distutils2.database.InstalledDistribution` or
                 :class:`distutils2.database.EggInfoDistribution`
        :type y: :class:`distutils2.database.InstalledDistribution` or
                 :class:`distutils2.database.EggInfoDistribution`
        :type label: ``str`` or ``None``


def add_missing(self, distribution, requirement):

logger.debug('<STR_LIT>', distribution, requirement)<EOL>self.missing.setdefault(distribution, []).append(requirement)<EOL>

Add a missing *requirement* for the given *distribution*.

:type distribution: :class:`distutils2.database.InstalledDistribution`
                    or :class:`distutils2.database.EggInfoDistribution`
:type requirement: ``str``


def repr_node(self, dist, level=<NUM_LIT:1>):

output = [self._repr_dist(dist)]<EOL>for other, label in self.adjacency_list[dist]:<EOL><INDENT>dist = self._repr_dist(other)<EOL>if label is not None:<EOL><INDENT>dist = '<STR_LIT>' % (dist, label)<EOL><DEDENT>output.append('<STR_LIT:U+0020>' * level + str(dist))<EOL>suboutput = self.repr_node(other, level + <NUM_LIT:1>)<EOL>subs = suboutput.split('<STR_LIT:\n>')<EOL>output.extend(subs[<NUM_LIT:1>:])<EOL><DEDENT>return '<STR_LIT:\n>'.join(output)<EOL>


def to_dot(self, f, skip_disconnected=True):

disconnected = []<EOL>f.write("<STR_LIT>")<EOL>for dist, adjs in self.adjacency_list.items():<EOL><INDENT>if len(adjs) == <NUM_LIT:0> and not skip_disconnected:<EOL><INDENT>disconnected.append(dist)<EOL><DEDENT>for other, label in adjs:<EOL><INDENT>if not label is None:<EOL><INDENT>f.write('<STR_LIT>' %<EOL>(dist.name, other.name, label))<EOL><DEDENT>else:<EOL><INDENT>f.write('<STR_LIT>' % (dist.name, other.name))<EOL><DEDENT><DEDENT><DEDENT>if not skip_disconnected and len(disconnected) > <NUM_LIT:0>:<EOL><INDENT>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>f.write('<STR_LIT>')<EOL>for dist in disconnected:<EOL><INDENT>f.write('<STR_LIT>' % dist.name)<EOL>f.write('<STR_LIT:\n>')<EOL><DEDENT>f.write('<STR_LIT>')<EOL><DEDENT>f.write('<STR_LIT>')<EOL>

Writes a DOT output for the graph to the provided file *f*.

        If *skip_disconnected* is set to ``True``, then all distributions
        that are not dependent on any other distribution are skipped.

        :type f: has to support ``file``-like operations
        :type skip_disconnected: ``bool``


result = []<EOL>alist = {}<EOL>for k, v in self.adjacency_list.items():<EOL><INDENT>alist[k] = v[:]<EOL><DEDENT>while True:<EOL><INDENT>to_remove = []<EOL>for k, v in list(alist.items())[:]:<EOL><INDENT>if not v:<EOL><INDENT>to_remove.append(k)<EOL>del alist[k]<EOL><DEDENT><DEDENT>if not to_remove:<EOL><INDENT>break<EOL><DEDENT>for k, v in alist.items():<EOL><INDENT>alist[k] = [(d, r) for d, r in v if d not in to_remove]<EOL><DEDENT>logger.debug('<STR_LIT>',<EOL>['<STR_LIT>' % (d.name, d.version) for d in to_remove])<EOL>result.extend(to_remove)<EOL><DEDENT>return result, list(alist.keys())<EOL>

Perform a topological sort of the graph.
:return: A tuple, the first element of which is a topologically sorted
         list of distributions, and the second element of which is a
         list of distributions that cannot be sorted because they have
         circular dependencies and so form a cycle.


output = []<EOL>for dist, adjs in self.adjacency_list.items():<EOL><INDENT>output.append(self.repr_node(dist))<EOL><DEDENT>return '<STR_LIT:\n>'.join(output)<EOL>


self.base = os.path.abspath(os.path.normpath(base or os.getcwd()))<EOL>self.prefix = self.base + os.sep<EOL>self.allfiles = None<EOL>self.files = set()<EOL>

Initialise an instance.

:param base: The base directory to explore under.


from stat import S_ISREG, S_ISDIR, S_ISLNK<EOL>self.allfiles = allfiles = []<EOL>root = self.base<EOL>stack = [root]<EOL>pop = stack.pop<EOL>push = stack.append<EOL>while stack:<EOL><INDENT>root = pop()<EOL>names = os.listdir(root)<EOL>for name in names:<EOL><INDENT>fullname = os.path.join(root, name)<EOL>stat = os.stat(fullname)<EOL>mode = stat.st_mode<EOL>if S_ISREG(mode):<EOL><INDENT>allfiles.append(fsdecode(fullname))<EOL><DEDENT>elif S_ISDIR(mode) and not S_ISLNK(mode):<EOL><INDENT>push(fullname)<EOL><DEDENT><DEDENT><DEDENT>

Find all files under the base and set ``allfiles`` to the absolute
        pathnames of files found.


if not item.startswith(self.prefix):<EOL><INDENT>item = os.path.join(self.base, item)<EOL><DEDENT>self.files.add(os.path.normpath(item))<EOL>

Add a file to the manifest.

:param item: The pathname to add. This can be relative to the base.


for item in items:<EOL><INDENT>self.add(item)<EOL><DEDENT>

Add a list of files to the manifest.

:param items: The pathnames to add. These can be relative to the base.


def add_dir(dirs, d):<EOL><INDENT>dirs.add(d)<EOL>logger.debug('<STR_LIT>', d)<EOL>if d != self.base:<EOL><INDENT>parent, _ = os.path.split(d)<EOL>assert parent not in ('<STR_LIT>', '<STR_LIT:/>')<EOL>add_dir(dirs, parent)<EOL><DEDENT><DEDENT>result = set(self.files)    <EOL>if wantdirs:<EOL><INDENT>dirs = set()<EOL>for f in result:<EOL><INDENT>add_dir(dirs, os.path.dirname(f))<EOL><DEDENT>result |= dirs<EOL><DEDENT>return [os.path.join(*path_tuple) for path_tuple in<EOL>sorted(os.path.split(path) for path in result)]<EOL>


self.files = set()<EOL>self.allfiles = []<EOL>


<EOL>action, patterns, thedir, dirpattern = self._parse_directive(directive)<EOL>if action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>if not self._include_pattern(pattern, anchor=True):<EOL><INDENT>logger.warning('<STR_LIT>', pattern)<EOL><DEDENT><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>found = self._exclude_pattern(pattern, anchor=True)<EOL><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>if not self._include_pattern(pattern, anchor=False):<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>', pattern)<EOL><DEDENT><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>found = self._exclude_pattern(pattern, anchor=False)<EOL><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>if not self._include_pattern(pattern, prefix=thedir):<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>', pattern, thedir)<EOL><DEDENT><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>for pattern in patterns:<EOL><INDENT>found = self._exclude_pattern(pattern, prefix=thedir)<EOL><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>if not self._include_pattern(None, prefix=dirpattern):<EOL><INDENT>logger.warning('<STR_LIT>',<EOL>dirpattern)<EOL><DEDENT><DEDENT>elif action == '<STR_LIT>':<EOL><INDENT>if not self._exclude_pattern(None, prefix=dirpattern):<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>', dirpattern)<EOL><DEDENT><DEDENT>else:   <EOL><INDENT>raise DistlibException(<EOL>'<STR_LIT>' % action)<EOL><DEDENT>

Process a directive which either adds some files from ``allfiles`` to
``files``, or removes some files from ``files``.

:param directive: The directive to process. This should be in a format
             compatible with distutils ``MANIFEST.in`` files:

             http://docs.python.org/distutils/sourcedist.html#commands


words = directive.split()<EOL>if len(words) == <NUM_LIT:1> and words[<NUM_LIT:0>] not in ('<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>words.insert(<NUM_LIT:0>, '<STR_LIT>')<EOL><DEDENT>action = words[<NUM_LIT:0>]<EOL>patterns = thedir = dir_pattern = None<EOL>if action in ('<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if len(words) < <NUM_LIT:2>:<EOL><INDENT>raise DistlibException(<EOL>'<STR_LIT>' % action)<EOL><DEDENT>patterns = [convert_path(word) for word in words[<NUM_LIT:1>:]]<EOL><DEDENT>elif action in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if len(words) < <NUM_LIT:3>:<EOL><INDENT>raise DistlibException(<EOL>'<STR_LIT>' % action)<EOL><DEDENT>thedir = convert_path(words[<NUM_LIT:1>])<EOL>patterns = [convert_path(word) for word in words[<NUM_LIT:2>:]]<EOL><DEDENT>elif action in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if len(words) != <NUM_LIT:2>:<EOL><INDENT>raise DistlibException(<EOL>'<STR_LIT>' % action)<EOL><DEDENT>dir_pattern = convert_path(words[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>raise DistlibException('<STR_LIT>' % action)<EOL><DEDENT>return action, patterns, thedir, dir_pattern<EOL>

Validate a directive.
:param directive: The directive to validate.
:return: A tuple of action, patterns, thedir, dir_patterns


def _include_pattern(self, pattern, anchor=True, prefix=None,<EOL>is_regex=False):

<EOL>found = False<EOL>pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex)<EOL>if self.allfiles is None:<EOL><INDENT>self.findall()<EOL><DEDENT>for name in self.allfiles:<EOL><INDENT>if pattern_re.search(name):<EOL><INDENT>self.files.add(name)<EOL>found = True<EOL><DEDENT><DEDENT>return found<EOL>

Select strings (presumably filenames) from 'self.files' that
        match 'pattern', a Unix-style wildcard (glob) pattern.

        Patterns are not quite the same as implemented by the 'fnmatch'
        module: '*' and '?'  match non-special characters, where "special"
        is platform-dependent: slash on Unix; colon, slash, and backslash on
        DOS/Windows; and colon on Mac OS.

        If 'anchor' is true (the default), then the pattern match is more
        stringent: "*.py" will match "foo.py" but not "foo/bar.py".  If
        'anchor' is false, both of these will match.

        If 'prefix' is supplied, then only filenames starting with 'prefix'
        (itself a pattern) and ending with 'pattern', with anything in between
        them, will match.  'anchor' is ignored in this case.

        If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and
        'pattern' is assumed to be either a string containing a regex or a
        regex object -- no translation is done, the regex is just compiled
        and used as-is.

        Selected strings will be added to self.files.

        Return True if files are found.


def _exclude_pattern(self, pattern, anchor=True, prefix=None,<EOL>is_regex=False):

found = False<EOL>pattern_re = self._translate_pattern(pattern, anchor, prefix, is_regex)<EOL>for f in list(self.files):<EOL><INDENT>if pattern_re.search(f):<EOL><INDENT>self.files.remove(f)<EOL>found = True<EOL><DEDENT><DEDENT>return found<EOL>

Remove strings (presumably filenames) from 'files' that match
        'pattern'.

        Other parameters are the same as for 'include_pattern()', above.
        The list 'self.files' is modified in place. Return True if files are
        found.

        This API is public to allow e.g. exclusion of SCM subdirs, e.g. when
        packaging source distributions


def _translate_pattern(self, pattern, anchor=True, prefix=None,<EOL>is_regex=False):

if is_regex:<EOL><INDENT>if isinstance(pattern, str):<EOL><INDENT>return re.compile(pattern)<EOL><DEDENT>else:<EOL><INDENT>return pattern<EOL><DEDENT><DEDENT>if pattern:<EOL><INDENT>pattern_re = self._glob_to_re(pattern)<EOL><DEDENT>else:<EOL><INDENT>pattern_re = '<STR_LIT>'<EOL><DEDENT>base = re.escape(os.path.join(self.base, '<STR_LIT>'))<EOL>if prefix is not None:<EOL><INDENT>empty_pattern = self._glob_to_re('<STR_LIT>')<EOL>prefix_re = self._glob_to_re(prefix)[:-len(empty_pattern)]<EOL>sep = os.sep<EOL>if os.sep == '<STR_LIT:\\>':<EOL><INDENT>sep = r'<STR_LIT:\\>'<EOL><DEDENT>pattern_re = '<STR_LIT>' + base + sep.join((prefix_re,<EOL>'<STR_LIT>' + pattern_re))<EOL><DEDENT>else:                               <EOL><INDENT>if anchor:<EOL><INDENT>pattern_re = '<STR_LIT>' + base + pattern_re<EOL><DEDENT><DEDENT>return re.compile(pattern_re)<EOL>

Translate a shell-like wildcard pattern to a compiled regular
        expression.

        Return the compiled regex.  If 'is_regex' true,
        then 'pattern' is directly compiled to a regex (if it's a string)
        or just returned as-is (assumes it's a regex object).


pattern_re = fnmatch.translate(pattern)<EOL>sep = os.sep<EOL>if os.sep == '<STR_LIT:\\>':<EOL><INDENT>sep = r'<STR_LIT>'<EOL><DEDENT>escaped = r'<STR_LIT>' % sep<EOL>pattern_re = re.sub(r'<STR_LIT>', escaped, pattern_re)<EOL>return pattern_re<EOL>

Translate a shell-like glob pattern to a regular expression.

        Return a string containing the regex.  Differs from
        'fnmatch.translate()' in that '*' does not match "special characters"
        (which are platform-specific).


def make(self, specification, options=None):

filenames = []<EOL>entry = get_export_entry(specification)<EOL>if entry is None:<EOL><INDENT>self._copy_script(specification, filenames)<EOL><DEDENT>else:<EOL><INDENT>self._make_script(entry, filenames, options=options)<EOL><DEDENT>return filenames<EOL>

Make a script.

:param specification: The specification, which is either a valid export
                      entry specification (to make a script from a
                      callable) or a filename (to make a script by
                      copying from a source location).
:param options: A dictionary of options controlling script generation.
:return: A list of all absolute pathnames written to.


def make_multiple(self, specifications, options=None):

filenames = []<EOL>for specification in specifications:<EOL><INDENT>filenames.extend(self.make(specification, options))<EOL><DEDENT>return filenames<EOL>

Take a list of specifications and make scripts from them,
:param specifications: A list of specifications.
:return: A list of all absolute pathnames written to,


def copyfileobj(fsrc, fdst, length=<NUM_LIT:16>*<NUM_LIT>):

while <NUM_LIT:1>:<EOL><INDENT>buf = fsrc.read(length)<EOL>if not buf:<EOL><INDENT>break<EOL><DEDENT>fdst.write(buf)<EOL><DEDENT>

copy data from file-like object fsrc to file-like object fdst


if _samefile(src, dst):<EOL><INDENT>raise Error("<STR_LIT>" % (src, dst))<EOL><DEDENT>for fn in [src, dst]:<EOL><INDENT>try:<EOL><INDENT>st = os.stat(fn)<EOL><DEDENT>except OSError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if stat.S_ISFIFO(st.st_mode):<EOL><INDENT>raise SpecialFileError("<STR_LIT>" % fn)<EOL><DEDENT><DEDENT><DEDENT>with open(src, '<STR_LIT:rb>') as fsrc:<EOL><INDENT>with open(dst, '<STR_LIT:wb>') as fdst:<EOL><INDENT>copyfileobj(fsrc, fdst)<EOL><DEDENT><DEDENT>


if hasattr(os, '<STR_LIT>'):<EOL><INDENT>st = os.stat(src)<EOL>mode = stat.S_IMODE(st.st_mode)<EOL>os.chmod(dst, mode)<EOL><DEDENT>


st = os.stat(src)<EOL>mode = stat.S_IMODE(st.st_mode)<EOL>if hasattr(os, '<STR_LIT>'):<EOL><INDENT>os.utime(dst, (st.st_atime, st.st_mtime))<EOL><DEDENT>if hasattr(os, '<STR_LIT>'):<EOL><INDENT>os.chmod(dst, mode)<EOL><DEDENT>if hasattr(os, '<STR_LIT>') and hasattr(st, '<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>os.chflags(dst, st.st_flags)<EOL><DEDENT>except OSError as why:<EOL><INDENT>if (not hasattr(errno, '<STR_LIT>') or<EOL>why.errno != errno.EOPNOTSUPP):<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>

Copy all stat info (mode bits, atime, mtime, flags) from src to dst


if os.path.isdir(dst):<EOL><INDENT>dst = os.path.join(dst, os.path.basename(src))<EOL><DEDENT>copyfile(src, dst)<EOL>copymode(src, dst)<EOL>

Copy data and mode bits ("cp src dst").

    The destination may be a directory.


if os.path.isdir(dst):<EOL><INDENT>dst = os.path.join(dst, os.path.basename(src))<EOL><DEDENT>copyfile(src, dst)<EOL>copystat(src, dst)<EOL>

Copy data and all stat info ("cp -p src dst").

    The destination may be a directory.


def _ignore_patterns(path, names):<EOL><INDENT>ignored_names = []<EOL>for pattern in patterns:<EOL><INDENT>ignored_names.extend(fnmatch.filter(names, pattern))<EOL><DEDENT>return set(ignored_names)<EOL><DEDENT>return _ignore_patterns<EOL>

Function that can be used as copytree() ignore parameter.

    Patterns is a sequence of glob-style patterns
    that are used to exclude files


def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,<EOL>ignore_dangling_symlinks=False):

names = os.listdir(src)<EOL>if ignore is not None:<EOL><INDENT>ignored_names = ignore(src, names)<EOL><DEDENT>else:<EOL><INDENT>ignored_names = set()<EOL><DEDENT>os.makedirs(dst)<EOL>errors = []<EOL>for name in names:<EOL><INDENT>if name in ignored_names:<EOL><INDENT>continue<EOL><DEDENT>srcname = os.path.join(src, name)<EOL>dstname = os.path.join(dst, name)<EOL>try:<EOL><INDENT>if os.path.islink(srcname):<EOL><INDENT>linkto = os.readlink(srcname)<EOL>if symlinks:<EOL><INDENT>os.symlink(linkto, dstname)<EOL><DEDENT>else:<EOL><INDENT>if not os.path.exists(linkto) and ignore_dangling_symlinks:<EOL><INDENT>continue<EOL><DEDENT>copy_function(srcname, dstname)<EOL><DEDENT><DEDENT>elif os.path.isdir(srcname):<EOL><INDENT>copytree(srcname, dstname, symlinks, ignore, copy_function)<EOL><DEDENT>else:<EOL><INDENT>copy_function(srcname, dstname)<EOL><DEDENT><DEDENT>except Error as err:<EOL><INDENT>errors.extend(err.args[<NUM_LIT:0>])<EOL><DEDENT>except EnvironmentError as why:<EOL><INDENT>errors.append((srcname, dstname, str(why)))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>copystat(src, dst)<EOL><DEDENT>except OSError as why:<EOL><INDENT>if WindowsError is not None and isinstance(why, WindowsError):<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>errors.extend((src, dst, str(why)))<EOL><DEDENT><DEDENT>if errors:<EOL><INDENT>raise Error(errors)<EOL><DEDENT>

Recursively copy a directory tree.

    The destination directory must not already exist.
    If exception(s) occur, an Error is raised with a list of reasons.

    If the optional symlinks flag is true, symbolic links in the
    source tree result in symbolic links in the destination tree; if
    it is false, the contents of the files pointed to by symbolic
    links are copied. If the file pointed by the symlink doesn't
    exist, an exception will be added in the list of errors raised in
    an Error exception at the end of the copy process.

    You can set the optional ignore_dangling_symlinks flag to true if you
    want to silence this exception. Notice that this has no effect on
    platforms that don't support os.symlink.

    The optional ignore argument is a callable. If given, it
    is called with the `src` parameter, which is the directory
    being visited by copytree(), and `names` which is the list of
    `src` contents, as returned by os.listdir():

        callable(src, names) -> ignored_names

    Since copytree() is called recursively, the callable will be
    called once for each directory that is copied. It returns a
    list of names relative to the `src` directory that should
    not be copied.

    The optional copy_function argument is a callable that will be used
    to copy each file. It will be called with the source path and the
    destination path as arguments. By default, copy2() is used, but any
    function that supports the same signature (like copy()) can be used.


def rmtree(path, ignore_errors=False, onerror=None):

if ignore_errors:<EOL><INDENT>def onerror(*args):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>elif onerror is None:<EOL><INDENT>def onerror(*args):<EOL><INDENT>raise<EOL><DEDENT><DEDENT>try:<EOL><INDENT>if os.path.islink(path):<EOL><INDENT>raise OSError("<STR_LIT>")<EOL><DEDENT><DEDENT>except OSError:<EOL><INDENT>onerror(os.path.islink, path, sys.exc_info())<EOL>return<EOL><DEDENT>names = []<EOL>try:<EOL><INDENT>names = os.listdir(path)<EOL><DEDENT>except os.error:<EOL><INDENT>onerror(os.listdir, path, sys.exc_info())<EOL><DEDENT>for name in names:<EOL><INDENT>fullname = os.path.join(path, name)<EOL>try:<EOL><INDENT>mode = os.lstat(fullname).st_mode<EOL><DEDENT>except os.error:<EOL><INDENT>mode = <NUM_LIT:0><EOL><DEDENT>if stat.S_ISDIR(mode):<EOL><INDENT>rmtree(fullname, ignore_errors, onerror)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>os.remove(fullname)<EOL><DEDENT>except os.error:<EOL><INDENT>onerror(os.remove, fullname, sys.exc_info())<EOL><DEDENT><DEDENT><DEDENT>try:<EOL><INDENT>os.rmdir(path)<EOL><DEDENT>except os.error:<EOL><INDENT>onerror(os.rmdir, path, sys.exc_info())<EOL><DEDENT>

Recursively delete a directory tree.

    If ignore_errors is set, errors are ignored; otherwise, if onerror
    is set, it is called to handle the error with arguments (func,
    path, exc_info) where func is os.listdir, os.remove, or os.rmdir;
    path is the argument to that function that caused it to fail; and
    exc_info is a tuple returned by sys.exc_info().  If ignore_errors
    is false and onerror is None, an exception is raised.


real_dst = dst<EOL>if os.path.isdir(dst):<EOL><INDENT>if _samefile(src, dst):<EOL><INDENT>os.rename(src, dst)<EOL>return<EOL><DEDENT>real_dst = os.path.join(dst, _basename(src))<EOL>if os.path.exists(real_dst):<EOL><INDENT>raise Error("<STR_LIT>" % real_dst)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>os.rename(src, real_dst)<EOL><DEDENT>except OSError:<EOL><INDENT>if os.path.isdir(src):<EOL><INDENT>if _destinsrc(src, dst):<EOL><INDENT>raise Error("<STR_LIT>" % (src, dst))<EOL><DEDENT>copytree(src, real_dst, symlinks=True)<EOL>rmtree(src)<EOL><DEDENT>else:<EOL><INDENT>copy2(src, real_dst)<EOL>os.unlink(src)<EOL><DEDENT><DEDENT>

Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command.

    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.

    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.

    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.


if getgrnam is None or name is None:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>result = getgrnam(name)<EOL><DEDENT>except KeyError:<EOL><INDENT>result = None<EOL><DEDENT>if result is not None:<EOL><INDENT>return result[<NUM_LIT:2>]<EOL><DEDENT>return None<EOL>


if getpwnam is None or name is None:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>result = getpwnam(name)<EOL><DEDENT>except KeyError:<EOL><INDENT>result = None<EOL><DEDENT>if result is not None:<EOL><INDENT>return result[<NUM_LIT:2>]<EOL><DEDENT>return None<EOL>


def _make_tarball(base_name, base_dir, compress="<STR_LIT>", verbose=<NUM_LIT:0>, dry_run=<NUM_LIT:0>,<EOL>owner=None, group=None, logger=None):

tar_compression = {'<STR_LIT>': '<STR_LIT>', None: '<STR_LIT>'}<EOL>compress_ext = {'<STR_LIT>': '<STR_LIT>'}<EOL>if _BZ2_SUPPORTED:<EOL><INDENT>tar_compression['<STR_LIT>'] = '<STR_LIT>'<EOL>compress_ext['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>if compress is not None and compress not in compress_ext:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>".format(compress))<EOL><DEDENT>archive_name = base_name + '<STR_LIT>' + compress_ext.get(compress, '<STR_LIT>')<EOL>archive_dir = os.path.dirname(archive_name)<EOL>if not os.path.exists(archive_dir):<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.info("<STR_LIT>", archive_dir)<EOL><DEDENT>if not dry_run:<EOL><INDENT>os.makedirs(archive_dir)<EOL><DEDENT><DEDENT>if logger is not None:<EOL><INDENT>logger.info('<STR_LIT>')<EOL><DEDENT>uid = _get_uid(owner)<EOL>gid = _get_gid(group)<EOL>def _set_uid_gid(tarinfo):<EOL><INDENT>if gid is not None:<EOL><INDENT>tarinfo.gid = gid<EOL>tarinfo.gname = group<EOL><DEDENT>if uid is not None:<EOL><INDENT>tarinfo.uid = uid<EOL>tarinfo.uname = owner<EOL><DEDENT>return tarinfo<EOL><DEDENT>if not dry_run:<EOL><INDENT>tar = tarfile.open(archive_name, '<STR_LIT>' % tar_compression[compress])<EOL>try:<EOL><INDENT>tar.add(base_dir, filter=_set_uid_gid)<EOL><DEDENT>finally:<EOL><INDENT>tar.close()<EOL><DEDENT><DEDENT>return archive_name<EOL>

Create a (possibly compressed) tar file from all the files under
    'base_dir'.

    'compress' must be "gzip" (the default), "bzip2", or None.

    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.

    The output tar file will be named 'base_name' +  ".tar", possibly plus
    the appropriate compression extension (".gz", or ".bz2").

    Returns the output filename.


def _make_zipfile(base_name, base_dir, verbose=<NUM_LIT:0>, dry_run=<NUM_LIT:0>, logger=None):

zip_filename = base_name + "<STR_LIT>"<EOL>archive_dir = os.path.dirname(base_name)<EOL>if not os.path.exists(archive_dir):<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.info("<STR_LIT>", archive_dir)<EOL><DEDENT>if not dry_run:<EOL><INDENT>os.makedirs(archive_dir)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>import zipfile<EOL><DEDENT>except ImportError:<EOL><INDENT>zipfile = None<EOL><DEDENT>if zipfile is None:<EOL><INDENT>_call_external_zip(base_dir, zip_filename, verbose, dry_run)<EOL><DEDENT>else:<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.info("<STR_LIT>",<EOL>zip_filename, base_dir)<EOL><DEDENT>if not dry_run:<EOL><INDENT>zip = zipfile.ZipFile(zip_filename, "<STR_LIT:w>",<EOL>compression=zipfile.ZIP_DEFLATED)<EOL>for dirpath, dirnames, filenames in os.walk(base_dir):<EOL><INDENT>for name in filenames:<EOL><INDENT>path = os.path.normpath(os.path.join(dirpath, name))<EOL>if os.path.isfile(path):<EOL><INDENT>zip.write(path, path)<EOL>if logger is not None:<EOL><INDENT>logger.info("<STR_LIT>", path)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>zip.close()<EOL><DEDENT><DEDENT>return zip_filename<EOL>

Create a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Uses either the
    "zipfile" Python module (if available) or the InfoZIP "zip" utility
    (if installed and found on the default search path).  If neither tool is
    available, raises ExecError.  Returns the name of the output zip
    file.


formats = [(name, registry[<NUM_LIT:2>]) for name, registry in<EOL>_ARCHIVE_FORMATS.items()]<EOL>formats.sort()<EOL>return formats<EOL>

Returns a list of supported formats for archiving and unarchiving.

    Each element of the returned sequence is a tuple (name, description)


def register_archive_format(name, function, extra_args=None, description='<STR_LIT>'):

if extra_args is None:<EOL><INDENT>extra_args = []<EOL><DEDENT>if not isinstance(function, collections.Callable):<EOL><INDENT>raise TypeError('<STR_LIT>' % function)<EOL><DEDENT>if not isinstance(extra_args, (tuple, list)):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>for element in extra_args:<EOL><INDENT>if not isinstance(element, (tuple, list)) or len(element) !=<NUM_LIT:2>:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT><DEDENT>_ARCHIVE_FORMATS[name] = (function, extra_args, description)<EOL>

Registers an archive format.

    name is the name of the format. function is the callable that will be
    used to create archives. If provided, extra_args is a sequence of
    (name, value) tuples that will be passed as arguments to the callable.
    description can be provided to describe the format, and will be returned
    by the get_archive_formats() function.


def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=<NUM_LIT:0>,<EOL>dry_run=<NUM_LIT:0>, owner=None, group=None, logger=None):

save_cwd = os.getcwd()<EOL>if root_dir is not None:<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.debug("<STR_LIT>", root_dir)<EOL><DEDENT>base_name = os.path.abspath(base_name)<EOL>if not dry_run:<EOL><INDENT>os.chdir(root_dir)<EOL><DEDENT><DEDENT>if base_dir is None:<EOL><INDENT>base_dir = os.curdir<EOL><DEDENT>kwargs = {'<STR_LIT>': dry_run, '<STR_LIT>': logger}<EOL>try:<EOL><INDENT>format_info = _ARCHIVE_FORMATS[format]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError("<STR_LIT>" % format)<EOL><DEDENT>func = format_info[<NUM_LIT:0>]<EOL>for arg, val in format_info[<NUM_LIT:1>]:<EOL><INDENT>kwargs[arg] = val<EOL><DEDENT>if format != '<STR_LIT>':<EOL><INDENT>kwargs['<STR_LIT>'] = owner<EOL>kwargs['<STR_LIT>'] = group<EOL><DEDENT>try:<EOL><INDENT>filename = func(base_name, base_dir, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>if root_dir is not None:<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.debug("<STR_LIT>", save_cwd)<EOL><DEDENT>os.chdir(save_cwd)<EOL><DEDENT><DEDENT>return filename<EOL>

Create an archive file (eg. zip or tar).

    'base_name' is the name of the file to create, minus any format-specific
    extension; 'format' is the archive format: one of "zip", "tar", "bztar"
    or "gztar".

    'root_dir' is a directory that will be the root directory of the
    archive; ie. we typically chdir into 'root_dir' before creating the
    archive.  'base_dir' is the directory where we start archiving from;
    ie. 'base_dir' will be the common prefix of all files and
    directories in the archive.  'root_dir' and 'base_dir' both default
    to the current directory.  Returns the name of the archive file.

    'owner' and 'group' are used when creating a tar archive. By default,
    uses the current owner and group.


formats = [(name, info[<NUM_LIT:0>], info[<NUM_LIT:3>]) for name, info in<EOL>_UNPACK_FORMATS.items()]<EOL>formats.sort()<EOL>return formats<EOL>

Returns a list of supported formats for unpacking.

    Each element of the returned sequence is a tuple
    (name, extensions, description)


def _check_unpack_options(extensions, function, extra_args):

<EOL>existing_extensions = {}<EOL>for name, info in _UNPACK_FORMATS.items():<EOL><INDENT>for ext in info[<NUM_LIT:0>]:<EOL><INDENT>existing_extensions[ext] = name<EOL><DEDENT><DEDENT>for extension in extensions:<EOL><INDENT>if extension in existing_extensions:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise RegistryError(msg % (extension,<EOL>existing_extensions[extension]))<EOL><DEDENT><DEDENT>if not isinstance(function, collections.Callable):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>

Checks what gets registered as an unpacker.


def register_unpack_format(name, extensions, function, extra_args=None,<EOL>description='<STR_LIT>'):

if extra_args is None:<EOL><INDENT>extra_args = []<EOL><DEDENT>_check_unpack_options(extensions, function, extra_args)<EOL>_UNPACK_FORMATS[name] = extensions, function, extra_args, description<EOL>

Registers an unpack format.

    `name` is the name of the format. `extensions` is a list of extensions
    corresponding to the format.

    `function` is the callable that will be
    used to unpack archives. The callable will receive archives to unpack.
    If it's unable to handle an archive, it needs to raise a ReadError
    exception.

    If provided, `extra_args` is a sequence of
    (name, value) tuples that will be passed as arguments to the callable.
    description can be provided to describe the format, and will be returned
    by the get_unpack_formats() function.


del _UNPACK_FORMATS[name]<EOL>

Removes the pack format from the registery.


dirname = os.path.dirname(path)<EOL>if not os.path.isdir(dirname):<EOL><INDENT>os.makedirs(dirname)<EOL><DEDENT>

Ensure that the parent directory of `path` exists


try:<EOL><INDENT>import zipfile<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ReadError('<STR_LIT>')<EOL><DEDENT>if not zipfile.is_zipfile(filename):<EOL><INDENT>raise ReadError("<STR_LIT>" % filename)<EOL><DEDENT>zip = zipfile.ZipFile(filename)<EOL>try:<EOL><INDENT>for info in zip.infolist():<EOL><INDENT>name = info.filename<EOL>if name.startswith('<STR_LIT:/>') or '<STR_LIT:..>' in name:<EOL><INDENT>continue<EOL><DEDENT>target = os.path.join(extract_dir, *name.split('<STR_LIT:/>'))<EOL>if not target:<EOL><INDENT>continue<EOL><DEDENT>_ensure_directory(target)<EOL>if not name.endswith('<STR_LIT:/>'):<EOL><INDENT>data = zip.read(info.filename)<EOL>f = open(target, '<STR_LIT:wb>')<EOL>try:<EOL><INDENT>f.write(data)<EOL><DEDENT>finally:<EOL><INDENT>f.close()<EOL>del data<EOL><DEDENT><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>zip.close()<EOL><DEDENT>


try:<EOL><INDENT>tarobj = tarfile.open(filename)<EOL><DEDENT>except tarfile.TarError:<EOL><INDENT>raise ReadError(<EOL>"<STR_LIT>" % filename)<EOL><DEDENT>try:<EOL><INDENT>tarobj.extractall(extract_dir)<EOL><DEDENT>finally:<EOL><INDENT>tarobj.close()<EOL><DEDENT>

Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`


def unpack_archive(filename, extract_dir=None, format=None):

if extract_dir is None:<EOL><INDENT>extract_dir = os.getcwd()<EOL><DEDENT>if format is not None:<EOL><INDENT>try:<EOL><INDENT>format_info = _UNPACK_FORMATS[format]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError("<STR_LIT>".format(format))<EOL><DEDENT>func = format_info[<NUM_LIT:1>]<EOL>func(filename, extract_dir, **dict(format_info[<NUM_LIT:2>]))<EOL><DEDENT>else:<EOL><INDENT>format = _find_unpack_format(filename)<EOL>if format is None:<EOL><INDENT>raise ReadError("<STR_LIT>".format(filename))<EOL><DEDENT>func = _UNPACK_FORMATS[format][<NUM_LIT:1>]<EOL>kwargs = dict(_UNPACK_FORMATS[format][<NUM_LIT:2>])<EOL>func(filename, extract_dir, **kwargs)<EOL><DEDENT>

Unpack an archive.

    `filename` is the name of the archive.

    `extract_dir` is the name of the target directory, where the archive
    is unpacked. If not provided, the current working directory is used.

    `format` is the archive format: one of "zip", "tar", or "gztar". Or any
    other registered format. If not provided, unpack_archive will use the
    filename extension and see if an unpacker was registered for that
    extension.

    In case none is found, a ValueError is raised.


def _replacer(matchobj):<EOL><INDENT>name = matchobj.group(<NUM_LIT:1>)<EOL>if name in local_vars:<EOL><INDENT>return local_vars[name]<EOL><DEDENT>elif name in os.environ:<EOL><INDENT>return os.environ[name]<EOL><DEDENT>return matchobj.group(<NUM_LIT:0>)<EOL><DEDENT>return _VAR_REPL.sub(_replacer, path)<EOL>

In the string `path`, replace tokens like {some.thing} with the
    corresponding value from the map `local_vars`.

    If there is no corresponding value, leave the token unchanged.


<EOL>_variable_rx = re.compile("<STR_LIT>")<EOL>_findvar1_rx = re.compile(r"<STR_LIT>")<EOL>_findvar2_rx = re.compile(r"<STR_LIT>")<EOL>if vars is None:<EOL><INDENT>vars = {}<EOL><DEDENT>done = {}<EOL>notdone = {}<EOL>with codecs.open(filename, encoding='<STR_LIT:utf-8>', errors="<STR_LIT>") as f:<EOL><INDENT>lines = f.readlines()<EOL><DEDENT>for line in lines:<EOL><INDENT>if line.startswith('<STR_LIT:#>') or line.strip() == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>m = _variable_rx.match(line)<EOL>if m:<EOL><INDENT>n, v = m.group(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>v = v.strip()<EOL>tmpv = v.replace('<STR_LIT>', '<STR_LIT>')<EOL>if "<STR_LIT:$>" in tmpv:<EOL><INDENT>notdone[n] = v<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>v = int(v)<EOL><DEDENT>except ValueError:<EOL><INDENT>done[n] = v.replace('<STR_LIT>', '<STR_LIT:$>')<EOL><DEDENT>else:<EOL><INDENT>done[n] = v<EOL><DEDENT><DEDENT><DEDENT><DEDENT>variables = list(notdone.keys())<EOL>renamed_variables = ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>while len(variables) > <NUM_LIT:0>:<EOL><INDENT>for name in tuple(variables):<EOL><INDENT>value = notdone[name]<EOL>m = _findvar1_rx.search(value) or _findvar2_rx.search(value)<EOL>if m is not None:<EOL><INDENT>n = m.group(<NUM_LIT:1>)<EOL>found = True<EOL>if n in done:<EOL><INDENT>item = str(done[n])<EOL><DEDENT>elif n in notdone:<EOL><INDENT>found = False<EOL><DEDENT>elif n in os.environ:<EOL><INDENT>item = os.environ[n]<EOL><DEDENT>elif n in renamed_variables:<EOL><INDENT>if (name.startswith('<STR_LIT>') and<EOL>name[<NUM_LIT:3>:] in renamed_variables):<EOL><INDENT>item = "<STR_LIT>"<EOL><DEDENT>elif '<STR_LIT>' + n in notdone:<EOL><INDENT>found = False<EOL><DEDENT>else:<EOL><INDENT>item = str(done['<STR_LIT>' + n])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>done[n] = item = "<STR_LIT>"<EOL><DEDENT>if found:<EOL><INDENT>after = value[m.end():]<EOL>value = value[:m.start()] + item + after<EOL>if "<STR_LIT:$>" in after:<EOL><INDENT>notdone[name] = value<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>value = int(value)<EOL><DEDENT>except ValueError:<EOL><INDENT>done[name] = value.strip()<EOL><DEDENT>else:<EOL><INDENT>done[name] = value<EOL><DEDENT>variables.remove(name)<EOL>if (name.startswith('<STR_LIT>') and<EOL>name[<NUM_LIT:3>:] in renamed_variables):<EOL><INDENT>name = name[<NUM_LIT:3>:]<EOL>if name not in done:<EOL><INDENT>done[name] = value<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>done[name] = value<EOL>variables.remove(name)<EOL><DEDENT><DEDENT><DEDENT>for k, v in done.items():<EOL><INDENT>if isinstance(v, str):<EOL><INDENT>done[k] = v.strip()<EOL><DEDENT><DEDENT>vars.update(done)<EOL>return vars<EOL>

Parse a Makefile-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.


if _PYTHON_BUILD:<EOL><INDENT>return os.path.join(_PROJECT_BASE, "<STR_LIT>")<EOL><DEDENT>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>config_dir_name = '<STR_LIT>' % (_PY_VERSION_SHORT, sys.abiflags)<EOL><DEDENT>else:<EOL><INDENT>config_dir_name = '<STR_LIT>'<EOL><DEDENT>return os.path.join(get_path('<STR_LIT>'), config_dir_name, '<STR_LIT>')<EOL>


<EOL>makefile = get_makefile_filename()<EOL>try:<EOL><INDENT>_parse_makefile(makefile, vars)<EOL><DEDENT>except IOError as e:<EOL><INDENT>msg = "<STR_LIT>" % makefile<EOL>if hasattr(e, "<STR_LIT>"):<EOL><INDENT>msg = msg + "<STR_LIT>" % e.strerror<EOL><DEDENT>raise IOError(msg)<EOL><DEDENT>config_h = get_config_h_filename()<EOL>try:<EOL><INDENT>with open(config_h) as f:<EOL><INDENT>parse_config_h(f, vars)<EOL><DEDENT><DEDENT>except IOError as e:<EOL><INDENT>msg = "<STR_LIT>" % config_h<EOL>if hasattr(e, "<STR_LIT>"):<EOL><INDENT>msg = msg + "<STR_LIT>" % e.strerror<EOL><DEDENT>raise IOError(msg)<EOL><DEDENT>if _PYTHON_BUILD:<EOL><INDENT>vars['<STR_LIT>'] = vars['<STR_LIT>']<EOL><DEDENT>

Initialize the module as appropriate for POSIX systems.


<EOL>vars['<STR_LIT>'] = get_path('<STR_LIT>')<EOL>vars['<STR_LIT>'] = get_path('<STR_LIT>')<EOL>vars['<STR_LIT>'] = get_path('<STR_LIT>')<EOL>vars['<STR_LIT>'] = '<STR_LIT>'<EOL>vars['<STR_LIT>'] = '<STR_LIT>'<EOL>vars['<STR_LIT>'] = _PY_VERSION_SHORT_NO_DOT<EOL>vars['<STR_LIT>'] = os.path.dirname(_safe_realpath(sys.executable))<EOL>

Initialize the module as appropriate for NT


if vars is None:<EOL><INDENT>vars = {}<EOL><DEDENT>define_rx = re.compile("<STR_LIT>")<EOL>undef_rx = re.compile("<STR_LIT>")<EOL>while True:<EOL><INDENT>line = fp.readline()<EOL>if not line:<EOL><INDENT>break<EOL><DEDENT>m = define_rx.match(line)<EOL>if m:<EOL><INDENT>n, v = m.group(<NUM_LIT:1>, <NUM_LIT:2>)<EOL>try:<EOL><INDENT>v = int(v)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT>vars[n] = v<EOL><DEDENT>else:<EOL><INDENT>m = undef_rx.match(line)<EOL>if m:<EOL><INDENT>vars[m.group(<NUM_LIT:1>)] = <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>return vars<EOL>

Parse a config.h-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.


if _PYTHON_BUILD:<EOL><INDENT>if os.name == "<STR_LIT>":<EOL><INDENT>inc_dir = os.path.join(_PROJECT_BASE, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>inc_dir = _PROJECT_BASE<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inc_dir = get_path('<STR_LIT>')<EOL><DEDENT>return os.path.join(inc_dir, '<STR_LIT>')<EOL>


return tuple(sorted(_SCHEMES.sections()))<EOL>

Return a tuple containing the schemes names.


<EOL>return _SCHEMES.options('<STR_LIT>')<EOL>

Return a tuple containing the paths names.


def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):

_ensure_cfg_read()<EOL>if expand:<EOL><INDENT>return _expand_vars(scheme, vars)<EOL><DEDENT>else:<EOL><INDENT>return dict(_SCHEMES.items(scheme))<EOL><DEDENT>

Return a mapping containing an install scheme.

    ``scheme`` is the install scheme name. If not provided, it will
    return the default scheme for the current platform.


def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):

return get_paths(scheme, vars, expand)[name]<EOL>

Return a path corresponding to the scheme.

    ``scheme`` is the install scheme name.


global _CONFIG_VARS<EOL>if _CONFIG_VARS is None:<EOL><INDENT>_CONFIG_VARS = {}<EOL>_CONFIG_VARS['<STR_LIT>'] = _PREFIX<EOL>_CONFIG_VARS['<STR_LIT>'] = _EXEC_PREFIX<EOL>_CONFIG_VARS['<STR_LIT>'] = _PY_VERSION<EOL>_CONFIG_VARS['<STR_LIT>'] = _PY_VERSION_SHORT<EOL>_CONFIG_VARS['<STR_LIT>'] = _PY_VERSION[<NUM_LIT:0>] + _PY_VERSION[<NUM_LIT:2>]<EOL>_CONFIG_VARS['<STR_LIT>'] = _PREFIX<EOL>_CONFIG_VARS['<STR_LIT>'] = _EXEC_PREFIX<EOL>_CONFIG_VARS['<STR_LIT>'] = _PROJECT_BASE<EOL>try:<EOL><INDENT>_CONFIG_VARS['<STR_LIT>'] = sys.abiflags<EOL><DEDENT>except AttributeError:<EOL><INDENT>_CONFIG_VARS['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>if os.name in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>_init_non_posix(_CONFIG_VARS)<EOL><DEDENT>if os.name == '<STR_LIT>':<EOL><INDENT>_init_posix(_CONFIG_VARS)<EOL><DEDENT>if sys.version >= '<STR_LIT>':<EOL><INDENT>_CONFIG_VARS['<STR_LIT>'] = _getuserbase()<EOL><DEDENT>if '<STR_LIT>' not in _CONFIG_VARS:<EOL><INDENT>_CONFIG_VARS['<STR_LIT>'] = _PROJECT_BASE<EOL><DEDENT>else:<EOL><INDENT>_CONFIG_VARS['<STR_LIT>'] = _safe_realpath(_CONFIG_VARS['<STR_LIT>'])<EOL><DEDENT>if _PYTHON_BUILD and os.name == "<STR_LIT>":<EOL><INDENT>base = _PROJECT_BASE<EOL>try:<EOL><INDENT>cwd = os.getcwd()<EOL><DEDENT>except OSError:<EOL><INDENT>cwd = None<EOL><DEDENT>if (not os.path.isabs(_CONFIG_VARS['<STR_LIT>']) and<EOL>base != cwd):<EOL><INDENT>srcdir = os.path.join(base, _CONFIG_VARS['<STR_LIT>'])<EOL>_CONFIG_VARS['<STR_LIT>'] = os.path.normpath(srcdir)<EOL><DEDENT><DEDENT>if sys.platform == '<STR_LIT>':<EOL><INDENT>kernel_version = os.uname()[<NUM_LIT:2>]  <EOL>major_version = int(kernel_version.split('<STR_LIT:.>')[<NUM_LIT:0>])<EOL>if major_version < <NUM_LIT:8>:<EOL><INDENT>for key in ('<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>flags = _CONFIG_VARS[key]<EOL>flags = re.sub('<STR_LIT>', '<STR_LIT:U+0020>', flags)<EOL>flags = re.sub('<STR_LIT>', '<STR_LIT:U+0020>', flags)<EOL>_CONFIG_VARS[key] = flags<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if '<STR_LIT>' in os.environ:<EOL><INDENT>arch = os.environ['<STR_LIT>']<EOL>for key in ('<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>flags = _CONFIG_VARS[key]<EOL>flags = re.sub('<STR_LIT>', '<STR_LIT:U+0020>', flags)<EOL>flags = flags + '<STR_LIT:U+0020>' + arch<EOL>_CONFIG_VARS[key] = flags<EOL><DEDENT><DEDENT>CFLAGS = _CONFIG_VARS.get('<STR_LIT>', '<STR_LIT>')<EOL>m = re.search('<STR_LIT>', CFLAGS)<EOL>if m is not None:<EOL><INDENT>sdk = m.group(<NUM_LIT:1>)<EOL>if not os.path.exists(sdk):<EOL><INDENT>for key in ('<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>flags = _CONFIG_VARS[key]<EOL>flags = re.sub('<STR_LIT>', '<STR_LIT:U+0020>', flags)<EOL>_CONFIG_VARS[key] = flags<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if args:<EOL><INDENT>vals = []<EOL>for name in args:<EOL><INDENT>vals.append(_CONFIG_VARS.get(name))<EOL><DEDENT>return vals<EOL><DEDENT>else:<EOL><INDENT>return _CONFIG_VARS<EOL><DEDENT>

With no arguments, return a dictionary of all configuration
    variables relevant for the current platform.

    On Unix, this means every variable defined in Python's installed Makefile;
    On Windows and Mac OS it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.


return get_config_vars().get(name)<EOL>

Return the value of a single variable using the dictionary returned by
    'get_config_vars()'.

    Equivalent to get_config_vars().get(name)


if os.name == '<STR_LIT>':<EOL><INDENT>prefix = "<STR_LIT>"<EOL>i = sys.version.find(prefix)<EOL>if i == -<NUM_LIT:1>:<EOL><INDENT>return sys.platform<EOL><DEDENT>j = sys.version.find("<STR_LIT:)>", i)<EOL>look = sys.version[i+len(prefix):j].lower()<EOL>if look == '<STR_LIT>':<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if look == '<STR_LIT>':<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>return sys.platform<EOL><DEDENT>if os.name != "<STR_LIT>" or not hasattr(os, '<STR_LIT>'):<EOL><INDENT>return sys.platform<EOL><DEDENT>osname, host, release, version, machine = os.uname()<EOL>osname = osname.lower().replace('<STR_LIT:/>', '<STR_LIT>')<EOL>machine = machine.replace('<STR_LIT:U+0020>', '<STR_LIT:_>')<EOL>machine = machine.replace('<STR_LIT:/>', '<STR_LIT:->')<EOL>if osname[:<NUM_LIT:5>] == "<STR_LIT>":<EOL><INDENT>return  "<STR_LIT>" % (osname, machine)<EOL><DEDENT>elif osname[:<NUM_LIT:5>] == "<STR_LIT>":<EOL><INDENT>if release[<NUM_LIT:0>] >= "<STR_LIT:5>":           <EOL><INDENT>osname = "<STR_LIT>"<EOL>release = "<STR_LIT>" % (int(release[<NUM_LIT:0>]) - <NUM_LIT:3>, release[<NUM_LIT:2>:])<EOL><DEDENT><DEDENT>elif osname[:<NUM_LIT:4>] == "<STR_LIT>":              <EOL><INDENT>return "<STR_LIT>" % (osname, release)<EOL><DEDENT>elif osname[:<NUM_LIT:3>] == "<STR_LIT>":<EOL><INDENT>return "<STR_LIT>" % (osname, version, release)<EOL><DEDENT>elif osname[:<NUM_LIT:6>] == "<STR_LIT>":<EOL><INDENT>osname = "<STR_LIT>"<EOL>rel_re = re.compile(r'<STR_LIT>')<EOL>m = rel_re.match(release)<EOL>if m:<EOL><INDENT>release = m.group()<EOL><DEDENT><DEDENT>elif osname[:<NUM_LIT:6>] == "<STR_LIT>":<EOL><INDENT>cfgvars = get_config_vars()<EOL>macver = cfgvars.get('<STR_LIT>')<EOL>if True:<EOL><INDENT>macrelease = macver<EOL>try:<EOL><INDENT>f = open('<STR_LIT>')<EOL><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>m = re.search(r'<STR_LIT>'<EOL>r'<STR_LIT>', f.read())<EOL><DEDENT>finally:<EOL><INDENT>f.close()<EOL><DEDENT>if m is not None:<EOL><INDENT>macrelease = '<STR_LIT:.>'.join(m.group(<NUM_LIT:1>).split('<STR_LIT:.>')[:<NUM_LIT:2>])<EOL><DEDENT><DEDENT><DEDENT>if not macver:<EOL><INDENT>macver = macrelease<EOL><DEDENT>if macver:<EOL><INDENT>release = macver<EOL>osname = "<STR_LIT>"<EOL>if ((macrelease + '<STR_LIT:.>') >= '<STR_LIT>' and<EOL>'<STR_LIT>' in get_config_vars().get('<STR_LIT>', '<STR_LIT>').strip()):<EOL><INDENT>machine = '<STR_LIT>'<EOL>cflags = get_config_vars().get('<STR_LIT>')<EOL>archs = re.findall('<STR_LIT>', cflags)<EOL>archs = tuple(sorted(set(archs)))<EOL>if len(archs) == <NUM_LIT:1>:<EOL><INDENT>machine = archs[<NUM_LIT:0>]<EOL><DEDENT>elif archs == ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>elif archs == ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>elif archs == ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>elif archs == ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>elif archs == ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>" % (archs,))<EOL><DEDENT><DEDENT>elif machine == '<STR_LIT>':<EOL><INDENT>if sys.maxsize >= <NUM_LIT:2>**<NUM_LIT:32>:<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT><DEDENT>elif machine in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>if sys.maxsize >= <NUM_LIT:2>**<NUM_LIT:32>:<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>machine = '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return "<STR_LIT>" % (osname, release, machine)<EOL>

Return a string that identifies the current platform.

    This is used mainly to distinguish platform-specific build directories and
    platform-specific built distributions.  Typically includes the OS name
    and version and the architecture (as supplied by 'os.uname()'),
    although the exact information included depends on the OS; eg. for IRIX
    the architecture isn't particularly important (IRIX only runs on SGI
    hardware), but for Linux the kernel version isn't particularly
    important.

    Examples of returned values:
       linux-i586
       linux-alpha (?)
       solaris-2.6-sun4u
       irix-5.3
       irix64-6.2

    Windows will return one of:
       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
       win-ia64 (64bit Windows on Itanium)
       win32 (all others - specifically, sys.platform is returned)

    For other non-POSIX platforms, currently just returns 'sys.platform'.


print('<STR_LIT>' % get_platform())<EOL>print('<STR_LIT>' % get_python_version())<EOL>print('<STR_LIT>' % _get_default_scheme())<EOL>print()<EOL>_print_dict('<STR_LIT>', get_paths())<EOL>print()<EOL>_print_dict('<STR_LIT>', get_config_vars())<EOL>

Display all information sysconfig detains.


s = s.encode(encoding, errors)<EOL>return s[:length] + (length - len(s)) * NUL<EOL>

Convert a string to a null-terminated bytes object.


p = s.find(b"<STR_LIT>")<EOL>if p != -<NUM_LIT:1>:<EOL><INDENT>s = s[:p]<EOL><DEDENT>return s.decode(encoding, errors)<EOL>

Convert a null-terminated bytes object to a string.


<EOL>if s[<NUM_LIT:0>] != chr(<NUM_LIT>):<EOL><INDENT>try:<EOL><INDENT>n = int(nts(s, "<STR_LIT:ascii>", "<STR_LIT:strict>") or "<STR_LIT:0>", <NUM_LIT:8>)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise InvalidHeaderError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>n = <NUM_LIT:0><EOL>for i in range(len(s) - <NUM_LIT:1>):<EOL><INDENT>n <<= <NUM_LIT:8><EOL>n += ord(s[i + <NUM_LIT:1>])<EOL><DEDENT><DEDENT>return n<EOL>

Convert a number field to a python number.


def itn(n, digits=<NUM_LIT:8>, format=DEFAULT_FORMAT):

<EOL>if <NUM_LIT:0> <= n < <NUM_LIT:8> ** (digits - <NUM_LIT:1>):<EOL><INDENT>s = ("<STR_LIT>" % (digits - <NUM_LIT:1>, n)).encode("<STR_LIT:ascii>") + NUL<EOL><DEDENT>else:<EOL><INDENT>if format != GNU_FORMAT or n >= <NUM_LIT> ** (digits - <NUM_LIT:1>):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if n < <NUM_LIT:0>:<EOL><INDENT>n = struct.unpack("<STR_LIT:L>", struct.pack("<STR_LIT:l>", n))[<NUM_LIT:0>]<EOL><DEDENT>s = bytearray()<EOL>for i in range(digits - <NUM_LIT:1>):<EOL><INDENT>s.insert(<NUM_LIT:0>, n & <NUM_LIT>)<EOL>n >>= <NUM_LIT:8><EOL><DEDENT>s.insert(<NUM_LIT:0>, <NUM_LIT>)<EOL><DEDENT>return s<EOL>

Convert a python number to a number field.


unsigned_chksum = <NUM_LIT> + sum(struct.unpack("<STR_LIT>", buf[:<NUM_LIT>]) + struct.unpack("<STR_LIT>", buf[<NUM_LIT>:<NUM_LIT>]))<EOL>signed_chksum = <NUM_LIT> + sum(struct.unpack("<STR_LIT>", buf[:<NUM_LIT>]) + struct.unpack("<STR_LIT>", buf[<NUM_LIT>:<NUM_LIT>]))<EOL>return unsigned_chksum, signed_chksum<EOL>

Calculate the checksum for a member's header by summing up all
       characters except for the chksum field which is treated as if
       it was filled with spaces. According to the GNU tar sources,
       some tars (Sun and NeXT) calculate chksum with signed char,
       which will be different if there are chars in the buffer with
       the high bit set. So we calculate two checksums, unsigned and
       signed.


if length == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if length is None:<EOL><INDENT>while True:<EOL><INDENT>buf = src.read(<NUM_LIT:16>*<NUM_LIT>)<EOL>if not buf:<EOL><INDENT>break<EOL><DEDENT>dst.write(buf)<EOL><DEDENT>return<EOL><DEDENT>BUFSIZE = <NUM_LIT:16> * <NUM_LIT><EOL>blocks, remainder = divmod(length, BUFSIZE)<EOL>for b in range(blocks):<EOL><INDENT>buf = src.read(BUFSIZE)<EOL>if len(buf) < BUFSIZE:<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>dst.write(buf)<EOL><DEDENT>if remainder != <NUM_LIT:0>:<EOL><INDENT>buf = src.read(remainder)<EOL>if len(buf) < remainder:<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>dst.write(buf)<EOL><DEDENT>return<EOL>

Copy length bytes from fileobj src to fileobj dst.
       If length is None, copy the entire content.


perm = []<EOL>for table in filemode_table:<EOL><INDENT>for bit, char in table:<EOL><INDENT>if mode & bit == bit:<EOL><INDENT>perm.append(char)<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>perm.append("<STR_LIT:->")<EOL><DEDENT><DEDENT>return "<STR_LIT>".join(perm)<EOL>

Convert a file's mode to a string of the form
       -rwxrwxrwx.
       Used by TarFile.list()


try:<EOL><INDENT>t = open(name)<EOL>t.close()<EOL>return True<EOL><DEDENT>except TarError:<EOL><INDENT>return False<EOL><DEDENT>

Return True if name points to a tar archive that we
       are able to handle, else return False.


def __init__(self, name, mode, comptype, fileobj, bufsize):

self._extfileobj = True<EOL>if fileobj is None:<EOL><INDENT>fileobj = _LowLevelFile(name, mode)<EOL>self._extfileobj = False<EOL><DEDENT>if comptype == '<STR_LIT:*>':<EOL><INDENT>fileobj = _StreamProxy(fileobj)<EOL>comptype = fileobj.getcomptype()<EOL><DEDENT>self.name     = name or "<STR_LIT>"<EOL>self.mode     = mode<EOL>self.comptype = comptype<EOL>self.fileobj  = fileobj<EOL>self.bufsize  = bufsize<EOL>self.buf      = b"<STR_LIT>"<EOL>self.pos      = <NUM_LIT:0><EOL>self.closed   = False<EOL>try:<EOL><INDENT>if comptype == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>import zlib<EOL><DEDENT>except ImportError:<EOL><INDENT>raise CompressionError("<STR_LIT>")<EOL><DEDENT>self.zlib = zlib<EOL>self.crc = zlib.crc32(b"<STR_LIT>")<EOL>if mode == "<STR_LIT:r>":<EOL><INDENT>self._init_read_gz()<EOL><DEDENT>else:<EOL><INDENT>self._init_write_gz()<EOL><DEDENT><DEDENT>if comptype == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>import bz2<EOL><DEDENT>except ImportError:<EOL><INDENT>raise CompressionError("<STR_LIT>")<EOL><DEDENT>if mode == "<STR_LIT:r>":<EOL><INDENT>self.dbuf = b"<STR_LIT>"<EOL>self.cmp = bz2.BZ2Decompressor()<EOL><DEDENT>else:<EOL><INDENT>self.cmp = bz2.BZ2Compressor()<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>if not self._extfileobj:<EOL><INDENT>self.fileobj.close()<EOL><DEDENT>self.closed = True<EOL>raise<EOL><DEDENT>


self.cmp = self.zlib.compressobj(<NUM_LIT:9>, self.zlib.DEFLATED,<EOL>-self.zlib.MAX_WBITS,<EOL>self.zlib.DEF_MEM_LEVEL,<EOL><NUM_LIT:0>)<EOL>timestamp = struct.pack("<STR_LIT>", int(time.time()))<EOL>self.__write(b"<STR_LIT>" + timestamp + b"<STR_LIT>")<EOL>if self.name.endswith("<STR_LIT>"):<EOL><INDENT>self.name = self.name[:-<NUM_LIT:3>]<EOL><DEDENT>self.__write(self.name.encode("<STR_LIT>", "<STR_LIT:replace>") + NUL)<EOL>

Initialize for writing with gzip compression.


if self.comptype == "<STR_LIT>":<EOL><INDENT>self.crc = self.zlib.crc32(s, self.crc)<EOL><DEDENT>self.pos += len(s)<EOL>if self.comptype != "<STR_LIT>":<EOL><INDENT>s = self.cmp.compress(s)<EOL><DEDENT>self.__write(s)<EOL>


self.buf += s<EOL>while len(self.buf) > self.bufsize:<EOL><INDENT>self.fileobj.write(self.buf[:self.bufsize])<EOL>self.buf = self.buf[self.bufsize:]<EOL><DEDENT>

Write string s to the stream if a whole new block
           is ready to be written.


if self.closed:<EOL><INDENT>return<EOL><DEDENT>if self.mode == "<STR_LIT:w>" and self.comptype != "<STR_LIT>":<EOL><INDENT>self.buf += self.cmp.flush()<EOL><DEDENT>if self.mode == "<STR_LIT:w>" and self.buf:<EOL><INDENT>self.fileobj.write(self.buf)<EOL>self.buf = b"<STR_LIT>"<EOL>if self.comptype == "<STR_LIT>":<EOL><INDENT>self.fileobj.write(struct.pack("<STR_LIT>", self.crc & <NUM_LIT>))<EOL>self.fileobj.write(struct.pack("<STR_LIT>", self.pos & <NUM_LIT>))<EOL><DEDENT><DEDENT>if not self._extfileobj:<EOL><INDENT>self.fileobj.close()<EOL><DEDENT>self.closed = True<EOL>

Close the _Stream object. No operation should be
           done on it afterwards.


self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)<EOL>self.dbuf = b"<STR_LIT>"<EOL>if self.__read(<NUM_LIT:2>) != b"<STR_LIT>":<EOL><INDENT>raise ReadError("<STR_LIT>")<EOL><DEDENT>if self.__read(<NUM_LIT:1>) != b"<STR_LIT>":<EOL><INDENT>raise CompressionError("<STR_LIT>")<EOL><DEDENT>flag = ord(self.__read(<NUM_LIT:1>))<EOL>self.__read(<NUM_LIT:6>)<EOL>if flag & <NUM_LIT:4>:<EOL><INDENT>xlen = ord(self.__read(<NUM_LIT:1>)) + <NUM_LIT> * ord(self.__read(<NUM_LIT:1>))<EOL>self.read(xlen)<EOL><DEDENT>if flag & <NUM_LIT:8>:<EOL><INDENT>while True:<EOL><INDENT>s = self.__read(<NUM_LIT:1>)<EOL>if not s or s == NUL:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>if flag & <NUM_LIT:16>:<EOL><INDENT>while True:<EOL><INDENT>s = self.__read(<NUM_LIT:1>)<EOL>if not s or s == NUL:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>if flag & <NUM_LIT:2>:<EOL><INDENT>self.__read(<NUM_LIT:2>)<EOL><DEDENT>

Initialize for reading a gzip compressed fileobj.


return self.pos<EOL>

Return the stream's file pointer position.


if pos - self.pos >= <NUM_LIT:0>:<EOL><INDENT>blocks, remainder = divmod(pos - self.pos, self.bufsize)<EOL>for i in range(blocks):<EOL><INDENT>self.read(self.bufsize)<EOL><DEDENT>self.read(remainder)<EOL><DEDENT>else:<EOL><INDENT>raise StreamError("<STR_LIT>")<EOL><DEDENT>return self.pos<EOL>

Set the stream's file pointer to pos. Negative seeking
           is forbidden.


if size is None:<EOL><INDENT>t = []<EOL>while True:<EOL><INDENT>buf = self._read(self.bufsize)<EOL>if not buf:<EOL><INDENT>break<EOL><DEDENT>t.append(buf)<EOL><DEDENT>buf = "<STR_LIT>".join(t)<EOL><DEDENT>else:<EOL><INDENT>buf = self._read(size)<EOL><DEDENT>self.pos += len(buf)<EOL>return buf<EOL>

Return the next size number of bytes from the stream.
           If size is not defined, return all bytes of the stream
           up to EOF.


if self.comptype == "<STR_LIT>":<EOL><INDENT>return self.__read(size)<EOL><DEDENT>c = len(self.dbuf)<EOL>while c < size:<EOL><INDENT>buf = self.__read(self.bufsize)<EOL>if not buf:<EOL><INDENT>break<EOL><DEDENT>try:<EOL><INDENT>buf = self.cmp.decompress(buf)<EOL><DEDENT>except IOError:<EOL><INDENT>raise ReadError("<STR_LIT>")<EOL><DEDENT>self.dbuf += buf<EOL>c += len(buf)<EOL><DEDENT>buf = self.dbuf[:size]<EOL>self.dbuf = self.dbuf[size:]<EOL>return buf<EOL>


c = len(self.buf)<EOL>while c < size:<EOL><INDENT>buf = self.fileobj.read(self.bufsize)<EOL>if not buf:<EOL><INDENT>break<EOL><DEDENT>self.buf += buf<EOL>c += len(buf)<EOL><DEDENT>buf = self.buf[:size]<EOL>self.buf = self.buf[size:]<EOL>return buf<EOL>

Return size bytes from stream. If internal buffer is empty,
           read another block from the stream.


return self.position<EOL>


self.position = position<EOL>


if size is None:<EOL><INDENT>size = self.size - self.position<EOL><DEDENT>else:<EOL><INDENT>size = min(size, self.size - self.position)<EOL><DEDENT>buf = b"<STR_LIT>"<EOL>while size > <NUM_LIT:0>:<EOL><INDENT>while True:<EOL><INDENT>data, start, stop, offset = self.map[self.map_index]<EOL>if start <= self.position < stop:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>self.map_index += <NUM_LIT:1><EOL>if self.map_index == len(self.map):<EOL><INDENT>self.map_index = <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>length = min(size, stop - self.position)<EOL>if data:<EOL><INDENT>self.fileobj.seek(offset + (self.position - start))<EOL>buf += self.fileobj.read(length)<EOL><DEDENT>else:<EOL><INDENT>buf += NUL * length<EOL><DEDENT>size -= length<EOL>self.position += length<EOL><DEDENT>return buf<EOL>


if self.closed:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>buf = b"<STR_LIT>"<EOL>if self.buffer:<EOL><INDENT>if size is None:<EOL><INDENT>buf = self.buffer<EOL>self.buffer = b"<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>buf = self.buffer[:size]<EOL>self.buffer = self.buffer[size:]<EOL><DEDENT><DEDENT>if size is None:<EOL><INDENT>buf += self.fileobj.read()<EOL><DEDENT>else:<EOL><INDENT>buf += self.fileobj.read(size - len(buf))<EOL><DEDENT>self.position += len(buf)<EOL>return buf<EOL>

Read at most size bytes from the file. If size is not
           present or None, read all data until EOF is reached.


if self.closed:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>pos = self.buffer.find(b"<STR_LIT:\n>") + <NUM_LIT:1><EOL>if pos == <NUM_LIT:0>:<EOL><INDENT>while True:<EOL><INDENT>buf = self.fileobj.read(self.blocksize)<EOL>self.buffer += buf<EOL>if not buf or b"<STR_LIT:\n>" in buf:<EOL><INDENT>pos = self.buffer.find(b"<STR_LIT:\n>") + <NUM_LIT:1><EOL>if pos == <NUM_LIT:0>:<EOL><INDENT>pos = len(self.buffer)<EOL><DEDENT>break<EOL><DEDENT><DEDENT><DEDENT>if size != -<NUM_LIT:1>:<EOL><INDENT>pos = min(size, pos)<EOL><DEDENT>buf = self.buffer[:pos]<EOL>self.buffer = self.buffer[pos:]<EOL>self.position += len(buf)<EOL>return buf<EOL>

Read one entire line from the file. If size is present
           and non-negative, return a string with at most that
           size, which may be an incomplete line.


result = []<EOL>while True:<EOL><INDENT>line = self.readline()<EOL>if not line: break<EOL>result.append(line)<EOL><DEDENT>return result<EOL>


if self.closed:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return self.position<EOL>


def seek(self, pos, whence=os.SEEK_SET):

if self.closed:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if whence == os.SEEK_SET:<EOL><INDENT>self.position = min(max(pos, <NUM_LIT:0>), self.size)<EOL><DEDENT>elif whence == os.SEEK_CUR:<EOL><INDENT>if pos < <NUM_LIT:0>:<EOL><INDENT>self.position = max(self.position + pos, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>self.position = min(self.position + pos, self.size)<EOL><DEDENT><DEDENT>elif whence == os.SEEK_END:<EOL><INDENT>self.position = max(min(self.size + pos, self.size), <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.buffer = b"<STR_LIT>"<EOL>self.fileobj.seek(self.position)<EOL>


self.closed = True<EOL>


while True:<EOL><INDENT>line = self.readline()<EOL>if not line:<EOL><INDENT>break<EOL><DEDENT>yield line<EOL><DEDENT>


self.name = name        <EOL>self.mode = <NUM_LIT>       <EOL>self.uid = <NUM_LIT:0>            <EOL>self.gid = <NUM_LIT:0>            <EOL>self.size = <NUM_LIT:0>           <EOL>self.mtime = <NUM_LIT:0>          <EOL>self.chksum = <NUM_LIT:0>         <EOL>self.type = REGTYPE     <EOL>self.linkname = "<STR_LIT>"      <EOL>self.uname = "<STR_LIT>"         <EOL>self.gname = "<STR_LIT>"         <EOL>self.devmajor = <NUM_LIT:0>       <EOL>self.devminor = <NUM_LIT:0>       <EOL>self.offset = <NUM_LIT:0>         <EOL>self.offset_data = <NUM_LIT:0>    <EOL>self.sparse = None      <EOL>self.pax_headers = {}<EOL>

Construct a TarInfo object. name is the optional name
           of the member.


info = {<EOL>"<STR_LIT:name>":     self.name,<EOL>"<STR_LIT>":     self.mode & <NUM_LIT>,<EOL>"<STR_LIT>":      self.uid,<EOL>"<STR_LIT>":      self.gid,<EOL>"<STR_LIT:size>":     self.size,<EOL>"<STR_LIT>":    self.mtime,<EOL>"<STR_LIT>":   self.chksum,<EOL>"<STR_LIT:type>":     self.type,<EOL>"<STR_LIT>": self.linkname,<EOL>"<STR_LIT>":    self.uname,<EOL>"<STR_LIT>":    self.gname,<EOL>"<STR_LIT>": self.devmajor,<EOL>"<STR_LIT>": self.devminor<EOL>}<EOL>if info["<STR_LIT:type>"] == DIRTYPE and not info["<STR_LIT:name>"].endswith("<STR_LIT:/>"):<EOL><INDENT>info["<STR_LIT:name>"] += "<STR_LIT:/>"<EOL><DEDENT>return info<EOL>

Return the TarInfo's attributes as a dictionary.


def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="<STR_LIT>"):

info = self.get_info()<EOL>if format == USTAR_FORMAT:<EOL><INDENT>return self.create_ustar_header(info, encoding, errors)<EOL><DEDENT>elif format == GNU_FORMAT:<EOL><INDENT>return self.create_gnu_header(info, encoding, errors)<EOL><DEDENT>elif format == PAX_FORMAT:<EOL><INDENT>return self.create_pax_header(info, encoding)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>

Return a tar header as a string of 512 byte blocks.


def create_ustar_header(self, info, encoding, errors):

info["<STR_LIT>"] = POSIX_MAGIC<EOL>if len(info["<STR_LIT>"]) > LENGTH_LINK:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if len(info["<STR_LIT:name>"]) > LENGTH_NAME:<EOL><INDENT>info["<STR_LIT>"], info["<STR_LIT:name>"] = self._posix_split_name(info["<STR_LIT:name>"])<EOL><DEDENT>return self._create_header(info, USTAR_FORMAT, encoding, errors)<EOL>

Return the object as a ustar header block.


def create_gnu_header(self, info, encoding, errors):

info["<STR_LIT>"] = GNU_MAGIC<EOL>buf = b"<STR_LIT>"<EOL>if len(info["<STR_LIT>"]) > LENGTH_LINK:<EOL><INDENT>buf += self._create_gnu_long_header(info["<STR_LIT>"], GNUTYPE_LONGLINK, encoding, errors)<EOL><DEDENT>if len(info["<STR_LIT:name>"]) > LENGTH_NAME:<EOL><INDENT>buf += self._create_gnu_long_header(info["<STR_LIT:name>"], GNUTYPE_LONGNAME, encoding, errors)<EOL><DEDENT>return buf + self._create_header(info, GNU_FORMAT, encoding, errors)<EOL>

Return the object as a GNU header block sequence.