[PATCH 1/6] Clean up some style issues
John Wright
jsw at debian.org
Wed Jul 29 13:35:27 UTC 2009
From: John Wright <john at johnwright.org>
This commit mainly splits long lines into lines fewer than 79
characters. There are also a few minor whitespace style changes, and
some docstring clarification. No actual code changes here.
---
debian_bundle/deb822.py | 48 ++++++++++++++++++++++++++++++----------------
1 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/debian_bundle/deb822.py b/debian_bundle/deb822.py
index fb1ed7c..485a948 100644
--- a/debian_bundle/deb822.py
+++ b/debian_bundle/deb822.py
@@ -124,9 +124,10 @@ class Deb822Dict(object, UserDict.DictMixin):
if _parsed is not None:
self.__parsed = _parsed
if _fields is None:
- self.__keys.extend([ _strI(k) for k in self.__parsed.keys() ])
+ self.__keys.extend([_strI(k) for k in self.__parsed.keys()])
else:
- self.__keys.extend([ _strI(f) for f in _fields if self.__parsed.has_key(f) ])
+ self.__keys.extend([_strI(f) for f in _fields
+ if self.__parsed.has_key(f)])
### BEGIN DictMixin methods
@@ -438,7 +439,8 @@ class Deb822(Deb822Dict):
lines = []
gpg_post_lines = []
state = 'SAFE'
- gpgre = re.compile(r'^-----(?P<action>BEGIN|END) PGP (?P<what>[^-]+)-----$')
+ gpgre = re.compile(r'^-----(?P<action>BEGIN|END) PGP '
+ '(?P<what>[^-]+)-----$')
blank_line = re.compile('^$')
first_line = True
@@ -497,8 +499,9 @@ class Deb822(Deb822Dict):
def get_gpg_info(self):
"""Return a GpgInfo object with GPG signature information
- This method will raise ValueError if the signature is not available
- (e.g. the original text cannot be found)"""
+ Raise ValueError if the signature is not available (e.g. the original
+ text cannot be found)
+ """
# raw_text is saved (as a string) only for Changes and Dsc (see
# _gpg_multivalued.__init__) which is small compared to Packages or
@@ -519,8 +522,10 @@ class GpgInfo(dict):
This class is really a dictionary containing parsed output from gnupg plus
some methods to make sense of the data.
+
Keys are keywords and values are arguments suitably splitted.
- See /usr/share/doc/gnupg/DETAILS.gz"""
+ See /usr/share/doc/gnupg/DETAILS.gz
+ """
# keys with format "key keyid uid"
uidkeys = ('GOODSIG', 'EXPSIG', 'EXPKEYSIG', 'REVKEYSIG', 'BADSIG')
@@ -540,7 +545,9 @@ class GpgInfo(dict):
"""Create a new GpgInfo object from gpg(v) --status-fd output (out) and
optionally collect stderr as well (err).
- Both out and err can be lines in newline-terminated sequence or regular strings."""
+ Both out and err can be lines in newline-terminated sequence or regular
+ strings.
+ """
n = GpgInfo()
@@ -574,25 +581,30 @@ class GpgInfo(dict):
# XXX how to handle sequences of lines? file() returns \n-terminated
@staticmethod
- def from_sequence(sequence, keyrings=['/usr/share/keyrings/debian-keyring.gpg'],
- executable=["/usr/bin/gpgv"]):
+ def from_sequence(sequence,
+ keyrings=['/usr/share/keyrings/debian-keyring.gpg'],
+ executable=["/usr/bin/gpgv"]):
"""Create a new GpgInfo object from the given sequence.
- Sequence is a sequence of lines or a string
- executable is a list of args for subprocess.Popen, the first element being the gpg executable"""
+ :param sequence: a sequence of lines or a string
+ :param executable: a list of args for subprocess.Popen, the first
+ element being the gpg executable.
+ """
# XXX check for gpg as well and use --verify accordingly?
args = executable
#args.extend(["--status-fd", "1", "--no-default-keyring"])
args.extend(["--status-fd", "1"])
import os
- [args.extend(["--keyring", k]) for k in keyrings if os.path.isfile(k) and os.access(k, os.R_OK)]
+ [args.extend(["--keyring", k]) for k in keyrings
+ if os.path.isfile(k) and os.access(k, os.R_OK)]
if "--keyring" not in args:
raise IOError, "cannot access none of given keyrings"
import subprocess
- p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(args, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# XXX what to do with exit code?
if isinstance(sequence, basestring):
@@ -604,9 +616,9 @@ class GpgInfo(dict):
@staticmethod
def from_file(target, *args):
- """Create a new GpgInfo object from the given file, calls from_sequence(file(target), *args)"""
+ """Create a new GpgInfo object from the given file"""
return from_sequence(file(target), *args)
-
+
###
class PkgRelation(object):
@@ -620,8 +632,10 @@ class PkgRelation(object):
# XXX *NOT* a real dependency parser, and that is not even a goal here, we
# just parse as much as we need to split the various parts composing a
# dependency, checking their correctness wrt policy is out of scope
- __dep_RE = re.compile( \
- r'^\s*(?P<name>[a-zA-Z0-9.+\-]{2,})(\s*\(\s*(?P<relop>[>=<]+)\s*(?P<version>[0-9a-zA-Z:\-+~.]+)\s*\))?(\s*\[(?P<archs>[\s!\w\-]+)\])?\s*$')
+ __dep_RE = re.compile(
+ r'^\s*(?P<name>[a-zA-Z0-9.+\-]{2,})'
+ '(\s*\(\s*(?P<relop>[>=<]+)\s*(?P<version>[0-9a-zA-Z:\-+~.]+)\s*\))?'
+ '(\s*\[(?P<archs>[\s!\w\-]+)\])?\s*$')
__comma_sep_RE = re.compile(r'\s*,\s*')
__pipe_sep_RE = re.compile(r'\s*\|\s*')
__blank_sep_RE = re.compile(r'\s*')
--
1.6.3.3
More information about the pkg-python-debian-discuss
mailing list