Commit fa9d3308 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

PEP 8 + PyFlakes + PyLint fixes

parent e28c6295
"""Contains the Package class and related helper classes and functions."""
from jinja2 import Template
import os
"""Contains the Package class and related helper classes and functions."""
pkginfo_template = Template("""
PKGINFO_TEMPLATE = Template("""
# Generated by APK Kit for Adélie Linux
# {{ builduser }}@{{ buildhost }} {{ builddate }}
pkgname = {{ package.name }}
......@@ -44,8 +43,8 @@ class Package:
:param int size:
(Recommended) The installed size of the package. You almost always
want to set this to something other than 0 if you don't want unhappy
users. :)
want to set this to something other than 0 if you don't want
unhappy users. :)
:param str url:
(Optional) The URL of the homepage for the package.
......@@ -57,7 +56,7 @@ class Package:
(Optional) One or more packages that are required to be installed
to use this package.
"""
self._pkgname = name
self._pkgver = str(version)
self._pkgdesc = description or name
......@@ -124,14 +123,14 @@ class Package:
.. note:: To write a file, see the :py:meth:`.write_pkginfo` helper
method.
"""
return pkginfo_template.render(builduser=os.environ.get('USER', '?'),
return PKGINFO_TEMPLATE.render(builduser=os.environ.get('USER', '?'),
buildhost=os.uname().nodename,
package=self)
@classmethod
def from_pkginfo(cls, buf):
"""Create a new :py:class:`Package` object from an existing PKGINFO.
:param buf:
The buffer to read from (whether file, StringIO, etc).
......@@ -152,8 +151,7 @@ class Package:
params['depends'] = list()
for line in buf.readlines():
# XXX TODO make this better
if type(line) != str:
if not isinstance(line, str):
line = line.decode('utf-8')
# Skip comments.
......
"""I/O classes and helpers for APK files."""
from apkkit.base.package import Package
import gzip # Not used, but we need to raise ImportError if gzip isn't built.
# Not used, but we need to raise ImportError if gzip isn't built.
import gzip # pylint: disable=unused-import
import tarfile
class APKFile:
"""Represents an APK file on disk (or in memory)."""
def __init__(self, filename, mode='r'):
self.tar = tarfile.open(filename, mode)
self.package = Package.from_pkginfo(self.tar.extractfile('.PKGINFO'))
@classmethod
def create(cls, package, datadir, sign=True, signfile=None, data_hash=True,
hash_method='sha1'):
"""Create an APK file in memory from a package and data directory.
:param package:
A :py:class:`Package` instance that describes the package.
:param datadir:
The path to the directory containing the package's data.
:param bool sign:
Whether to sign the package (default True).
:param signfile:
The path to the GPG key to sign the package with.
:param bool data_hash:
Whether to hash the data (default True).
:param str hash_method:
The hash method to use for hashing the data - default is sha1 to
maintain compatibility with upstream apk-tools.
"""
raise NotImplementedError
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment