Package gbp :: Package pkg

[hide private]
[frames] | no frames]

# Package pkg

Common functionality of the Debian/RPM package helpers

Submodules | [hide private]

- gbp.pkg.pristinetar: Handle checkin and checkout of archives from the pristine-tar branch

Classes | [hide private]

| PkgPolicy Common helpers for packaging policy.
| UpstreamSource Upstream source.

Functions | [hide private]

`tuple` of `str`

    >>> parse_archive_filename("abc.tar.gz")
    ('abc', 'tar', 'gzip')
    >>> parse_archive_filename("abc.tar.bz2")
    ('abc', 'tar', 'bzip2')
    >>> parse_archive_filename("abc.def.tbz2")
    ('abc.def', 'tar', 'bzip2')
    >>> parse_archive_filename("abc.def.tar.xz")
    ('abc.def', 'tar', 'xz')
    >>> parse_archive_filename("abc.zip")
    ('abc', 'zip', None)
    >>> parse_archive_filename("abc.lzma")
    ('abc', None, 'lzma')
    >>> parse_archive_filename("abc.tar.foo")
    ('abc.tar.foo', None, None)
    >>> parse_archive_filename("abc")
    ('abc', None, None)

parse_archive_filename(filename) Given an filename return the basename (i.e. |

Variables | [hide private]

| compressor_opts = ``{``'``bzip2``'``:` `[``'````'``,` `'``bz2``'``]``,` `'``gzip``'``:` `[``'``-n``'``,` `'``gz``'``]``,``...``
| compressor_aliases = ``{``'``bz2``'``:` `'``bzip2``'``,` `'``gz``'``:` `'``gzip``'``}``
| archive_formats = ``[``'``tar``'``,` `'``zip``'``]``
| archive_ext_aliases = ``{``'``tbz2``'``:` `(``'``tar``'``,` `'``bzip2``'``)``,` `'``tgz``'``:` `(``'``tar``'``...``
| __package__ = ``'``gbp.pkg``'``

Function Details | [hide private]

### parse_archive_filename(filename)

Given an filename return the basename (i.e. filename without the archive and compression extensions), archive format and compression method used.

Parameters:
  - `filename` (string) - the name of the file
Returns: `tuple` of `str`

    >>> parse_archive_filename("abc.tar.gz")
    ('abc', 'tar', 'gzip')
    >>> parse_archive_filename("abc.tar.bz2")
    ('abc', 'tar', 'bzip2')
    >>> parse_archive_filename("abc.def.tbz2")
    ('abc.def', 'tar', 'bzip2')
    >>> parse_archive_filename("abc.def.tar.xz")
    ('abc.def', 'tar', 'xz')
    >>> parse_archive_filename("abc.zip")
    ('abc', 'zip', None)
    >>> parse_archive_filename("abc.lzma")
    ('abc', None, 'lzma')
    >>> parse_archive_filename("abc.tar.foo")
    ('abc.tar.foo', None, None)
    >>> parse_archive_filename("abc")
    ('abc', None, None)

  tuple containing basename, archive format and compression method

Variables Details | [hide private]

### compressor_opts

Value:

      {'bzip2': ['', 'bz2'],
       'gzip': ['-n', 'gz'],
       'lzma': ['', 'lzma'],
       'xz': ['', 'xz']}

### archive_ext_aliases

Value:

      {'tbz2': ('tar', 'bzip2'),
       'tgz': ('tar', 'gzip'),
       'tlz': ('tar', 'lzma'),
       'txz': ('tar', 'xz')}