[kernel] r18488 - dists/trunk/linux-2.6/debian/lib/python/debian_linux
Bastian Blank
waldi at alioth.debian.org
Wed Jan 11 16:52:31 UTC 2012
Author: waldi
Date: Wed Jan 11 16:52:29 2012
New Revision: 18488
Log:
debian/lib/python: PEP8 and other style fixes.
Modified:
dists/trunk/linux-2.6/debian/lib/python/debian_linux/abi.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/config.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/firmware.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/kconfig.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/patches.py
dists/trunk/linux-2.6/debian/lib/python/debian_linux/utils.py
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/abi.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/abi.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/abi.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -10,9 +10,12 @@
# Symbols are resolved to modules by depmod at installation/
# upgrade time, not compile time, so moving a symbol between
# modules is not an ABI change. Compare everything else.
- if self.name != other.name: return False
- if self.version != other.version: return False
- if self.export != other.export: return False
+ if self.name != other.name:
+ return False
+ if self.version != other.version:
+ return False
+ if self.export != other.export:
+ return False
return True
@@ -22,6 +25,7 @@
return ret
return not ret
+
class Symbols(dict):
def __init__(self, file=None):
if file:
@@ -36,4 +40,5 @@
symbols = self.values()
symbols.sort(key=lambda i: i.name)
for s in symbols:
- file.write("%s %s %s %s\n" % (s.version, s.name, s.module, s.export))
+ file.write("%s %s %s %s\n" %
+ (s.version, s.name, s.module, s.export))
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/config.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/config.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/config.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,4 +1,8 @@
-import os, os.path, re, sys, textwrap
+import os
+import os.path
+import re
+import sys
+import textwrap
__all__ = [
'ConfigCoreDump',
@@ -6,6 +10,7 @@
'ConfigParser',
]
+
class SchemaItemBoolean(object):
def __call__(self, i):
i = i.strip().lower()
@@ -15,8 +20,9 @@
return False
raise Error
+
class SchemaItemList(object):
- def __init__(self, type = "\s+"):
+ def __init__(self, type="\s+"):
self.type = type
def __call__(self, i):
@@ -25,6 +31,7 @@
return []
return [j.strip() for j in re.split(self.type, i)]
+
class ConfigCore(dict):
def get_merge(self, section, arch, featureset, flavour, key, default=None):
temp = []
@@ -55,7 +62,7 @@
return ret or default
- def merge(self, section, arch = None, featureset = None, flavour = None):
+ def merge(self, section, arch=None, featureset=None, flavour=None):
ret = {}
ret.update(self.get((section,), {}))
if featureset:
@@ -81,8 +88,9 @@
fp.write('%s: %r\n' % (item, items[item]))
fp.write('\n')
+
class ConfigCoreDump(ConfigCore):
- def __init__(self, config = None, fp = None):
+ def __init__(self, config=None, fp=None):
super(ConfigCoreDump, self).__init__(self)
if config is not None:
self.update(config)
@@ -98,6 +106,7 @@
data[key] = value_real
self[section_real] = data
+
class ConfigCoreHierarchy(ConfigCore):
config_name = "defines"
@@ -134,7 +143,7 @@
}
}
- def __init__(self, dirs = []):
+ def __init__(self, dirs=[]):
super(ConfigCoreHierarchy, self).__init__()
self._dirs = dirs
self._read_base()
@@ -143,8 +152,8 @@
config = ConfigParser(self.schemas)
config.read(self.get_files("%s/%s" % (arch, self.config_name)))
- featuresets = config['base',].get('featuresets', [])
- flavours = config['base',].get('flavours', [])
+ featuresets = config['base', ].get('featuresets', [])
+ flavours = config['base', ].get('flavours', [])
for section in iter(config):
if section[0] in featuresets:
@@ -172,7 +181,7 @@
config = ConfigParser(self.schemas)
config.read(self.get_files("%s/%s/%s" % (arch, featureset, self.config_name)))
- flavours = config['base',].get('flavours', [])
+ flavours = config['base', ].get('flavours', [])
for section in iter(config):
real = (section[-1], arch, featureset) + section[:-1]
@@ -184,8 +193,8 @@
config = ConfigParser(self.schemas)
config.read(self.get_files(self.config_name))
- arches = config['base',]['arches']
- featuresets = config['base',].get('featuresets', [])
+ arches = config['base', ]['arches']
+ featuresets = config['base', ].get('featuresets', [])
for section in iter(config):
if section[0].startswith('featureset-'):
@@ -212,6 +221,7 @@
def get_files(self, name):
return [os.path.join(i, name) for i in self._dirs if i]
+
class ConfigParser(object):
__slots__ = '_config', 'schemas'
@@ -260,7 +270,8 @@
for key in data.keys():
try:
data[key] = schema[key](data[key])
- except KeyError: pass
+ except KeyError:
+ pass
super(ConfigParser.SectionSchema, self).__init__(data)
if __name__ == '__main__':
@@ -276,4 +287,3 @@
for item in items:
print "%s: %s" % (item, items[item])
print
-
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/debian.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,4 +1,8 @@
-import itertools, os.path, re, utils
+import itertools
+import os.path
+import re
+import utils
+
class Changelog(list):
_rules = r"""
@@ -26,7 +30,7 @@
def __init__(self, distribution, source, version):
self.distribution, self.source, self.version = distribution, source, version
- def __init__(self, dir = '', version = None):
+ def __init__(self, dir='', version=None):
if version is None:
version = Version
f = file(os.path.join(dir, "debian/changelog"))
@@ -45,6 +49,7 @@
v = Version(match.group('version'))
self.append(self.Entry(match.group('distribution'), match.group('source'), v))
+
class Version(object):
_version_rules = ur"""
^
@@ -68,7 +73,7 @@
def __init__(self, version):
match = self._version_re.match(version)
if match is None:
- raise RuntimeError, "Invalid debian version"
+ raise RuntimeError("Invalid debian version")
self.epoch = None
if match.group("epoch") is not None:
self.epoch = int(match.group("epoch"))
@@ -93,9 +98,10 @@
@property
def debian(self):
from warnings import warn
- warn("debian argument was replaced by revision", DeprecationWarning, stacklevel = 2)
+ warn("debian argument was replaced by revision", DeprecationWarning, stacklevel=2)
return self.revision
+
class VersionLinux(Version):
_version_linux_rules = ur"""
^
@@ -137,7 +143,7 @@
super(VersionLinux, self).__init__(version)
match = self._version_linux_re.match(version)
if match is None:
- raise RuntimeError, "Invalid debian linux version"
+ raise RuntimeError("Invalid debian linux version")
d = match.groupdict()
self.linux_modifier = d['modifier']
self.linux_version = d['version']
@@ -148,9 +154,10 @@
self.linux_dfsg = d['dfsg']
self.linux_revision_experimental = match.group('revision_experimental') and True
self.linux_revision_other = match.group('revision_other') and True
-
+
+
class PackageFieldList(list):
- def __init__(self, value = None):
+ def __init__(self, value=None):
self.extend(value)
def __str__(self):
@@ -166,10 +173,11 @@
else:
super(PackageFieldList, self).extend(value)
+
class PackageDescription(object):
__slots__ = "short", "long"
- def __init__(self, value = None):
+ def __init__(self, value=None):
self.short = []
self.long = []
if value is not None:
@@ -178,7 +186,7 @@
self.append_short(short)
def __str__(self):
- wrap = utils.TextWrapper(width = 74, fix_sentence_endings = True).wrap
+ wrap = utils.TextWrapper(width=74, fix_sentence_endings=True).wrap
short = ', '.join(self.short)
long_pars = []
for i in self.long:
@@ -203,6 +211,7 @@
else:
raise TypeError
+
class PackageRelation(list):
def __init__(self, value=None, override_arches=None):
if value:
@@ -221,7 +230,7 @@
if isinstance(value, basestring):
value = PackageRelationGroup(value, override_arches)
elif not isinstance(value, PackageRelationGroup):
- raise ValueError, "got %s" % type(value)
+ raise ValueError("got %s" % type(value))
j = self._search_value(value)
if j:
j._update_arches(value)
@@ -232,10 +241,11 @@
if isinstance(value, basestring):
value = [j.strip() for j in re.split(',', value.strip())]
elif not isinstance(value, (list, tuple)):
- raise ValueError, "got %s" % type(value)
+ raise ValueError("got %s" % type(value))
for i in value:
self.append(i, override_arches)
+
class PackageRelationGroup(list):
def __init__(self, value=None, override_arches=None):
if value:
@@ -272,15 +282,38 @@
for i in value:
self.append(i, override_arches)
+
class PackageRelationEntry(object):
__slots__ = "name", "operator", "version", "arches"
_re = re.compile(r'^(\S+)(?: \((<<|<=|=|!=|>=|>>)\s*([^)]+)\))?(?: \[([^]]+)\])?$')
class _operator(object):
- OP_LT = 1; OP_LE = 2; OP_EQ = 3; OP_NE = 4; OP_GE = 5; OP_GT = 6
- operators = { '<<': OP_LT, '<=': OP_LE, '=': OP_EQ, '!=': OP_NE, '>=': OP_GE, '>>': OP_GT }
- operators_neg = { OP_LT: OP_GE, OP_LE: OP_GT, OP_EQ: OP_NE, OP_NE: OP_EQ, OP_GE: OP_LT, OP_GT: OP_LE }
+ OP_LT = 1
+ OP_LE = 2
+ OP_EQ = 3
+ OP_NE = 4
+ OP_GE = 5
+ OP_GT = 6
+
+ operators = {
+ '<<': OP_LT,
+ '<=': OP_LE,
+ '=': OP_EQ,
+ '!=': OP_NE,
+ '>=': OP_GE,
+ '>>': OP_GT,
+ }
+
+ operators_neg = {
+ OP_LT: OP_GE,
+ OP_LE: OP_GT,
+ OP_EQ: OP_NE,
+ OP_NE: OP_EQ,
+ OP_GE: OP_LT,
+ OP_GT: OP_LE,
+ }
+
operators_text = dict([(b, a) for a, b in operators.iteritems()])
__slots__ = '_op',
@@ -314,7 +347,7 @@
def parse(self, value):
match = self._re.match(value)
if match is None:
- raise RuntimeError, "Can't parse dependency %s" % value
+ raise RuntimeError("Can't parse dependency %s" % value)
match = match.groups()
self.name = match[0]
if match[1] is not None:
@@ -327,6 +360,7 @@
else:
self.arches = []
+
class Package(dict):
_fields = utils.SortedDict((
('Package', str),
@@ -355,13 +389,14 @@
cls = self._fields[key]
if not isinstance(value, cls):
value = cls(value)
- except KeyError: pass
+ except KeyError:
+ pass
super(Package, self).__setitem__(key, value)
def iterkeys(self):
keys = set(self.keys())
for i in self._fields.iterkeys():
- if self.has_key(i):
+ if i in self:
keys.remove(i)
yield i
for i in keys:
@@ -374,4 +409,3 @@
def itervalues(self):
for i in self.iterkeys():
yield self[i]
-
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/firmware.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/firmware.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/firmware.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,5 +1,6 @@
import re
+
class FirmwareFile(object):
def __init__(self, binary, desc=None, source=None, version=None):
self.binary = binary
@@ -7,12 +8,14 @@
self.source = source
self.version = version
+
class FirmwareSection(object):
def __init__(self, driver, files, licence):
self.driver = driver
self.files = files
self.licence = licence
+
class FirmwareWhence(list):
def __init__(self, file):
self.read(file)
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/gencontrol.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,6 +1,7 @@
from debian import *
from utils import SortedDict
+
class PackagesList(SortedDict):
def append(self, package):
self[package['Package']] = package
@@ -9,12 +10,13 @@
for package in packages:
self[package['Package']] = package
+
class Makefile(object):
def __init__(self):
self.rules = {}
self.add('.NOTPARALLEL')
- def add(self, name, deps = None, cmds = None):
+ def add(self, name, deps=None, cmds=None):
if name in self.rules:
self.rules[name].add(deps, cmds)
else:
@@ -31,12 +33,12 @@
self.rules[i].write(out)
class Rule(object):
- def __init__(self, name, deps = None, cmds = None):
+ def __init__(self, name, deps=None, cmds=None):
self.name = name
self.deps, self.cmds = set(), []
self.add(deps, cmds)
- def add(self, deps = None, cmds = None):
+ def add(self, deps=None, cmds=None):
if deps is not None:
self.deps.update(deps)
if cmds is not None:
@@ -59,6 +61,7 @@
else:
out.write('%s:%s\n' % (self.name, deps_string))
+
class MakeFlags(dict):
def __repr__(self):
repr = super(flags, self).__repr__()
@@ -70,12 +73,13 @@
def copy(self):
return self.__class__(super(MakeFlags, self).copy())
+
class Gencontrol(object):
makefile_targets = ('binary-arch', 'build', 'setup', 'source')
- def __init__(self, config, templates, version = Version):
+ def __init__(self, config, templates, version=Version):
self.config, self.templates = config, templates
- self.changelog = Changelog(version = version)
+ self.changelog = Changelog(version=version)
def __call__(self):
packages = PackagesList()
@@ -93,7 +97,7 @@
packages['source'] = self.process_package(source)
def do_main(self, packages, makefile):
- config_entry = self.config['base',]
+ config_entry = self.config['base', ]
vars = self.vars.copy()
makeflags = MakeFlags()
@@ -108,13 +112,13 @@
pass
def do_main_makefile(self, makefile, makeflags, extra):
- makefile.add('binary-indep', cmds = ["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags])
+ makefile.add('binary-indep', cmds=["$(MAKE) -f debian/rules.real binary-indep %s" % makeflags])
def do_main_packages(self, packages, vars, makeflags, extra):
pass
def do_main_recurse(self, packages, makefile, vars, makeflags, extra):
- for arch in iter(self.config['base',]['arches']):
+ for arch in iter(self.config['base', ]['arches']):
self.do_arch(packages, makefile, arch, vars.copy(), makeflags.copy(), extra)
def do_extra(self, packages, makefile):
@@ -136,11 +140,11 @@
cmds = []
for i in extra_arches[arch]:
tmp = []
- if i.has_key('X-Version-Overwrite-Epoch'):
+ if 'X-Version-Overwrite-Epoch' in i:
tmp.append("-v1:%s" % self.version['source'])
cmds.append("$(MAKE) -f debian/rules.real install-dummy DH_OPTIONS='-p%s' GENCONTROL_ARGS='%s'" % (i['Package'], ' '.join(tmp)))
- makefile.add('binary-arch_%s' % arch ['binary-arch_%s_extra' % arch])
- makefile.add("binary-arch_%s_extra" % arch, cmds = cmds)
+ makefile.add('binary-arch_%s' % arch['binary-arch_%s_extra' % arch])
+ makefile.add("binary-arch_%s_extra" % arch, cmds=cmds)
def do_arch(self, packages, makefile, arch, vars, makeflags, extra):
vars['arch'] = arch
@@ -218,7 +222,7 @@
('kernel-arch', 'KERNEL_ARCH'),
('localversion', 'LOCALVERSION'),
):
- if vars.has_key(i[0]):
+ if i[0] in vars:
makeflags[i[1]] = vars[i[0]]
def do_flavour_makefile(self, makefile, arch, featureset, flavour, makeflags, extra):
@@ -269,8 +273,10 @@
def substitute(self, s, vars):
if isinstance(s, (list, tuple)):
return [self.substitute(i, vars) for i in s]
+
def subst(match):
return vars[match.group(1)]
+
return re.sub(r'@([-_a-z]+)@', subst, s)
def write(self, packages, makefile):
@@ -295,5 +301,3 @@
for key, value in entry.iteritems():
f.write("%s: %s\n" % (key, value))
f.write('\n')
-
-
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/kconfig.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/kconfig.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/kconfig.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -6,6 +6,7 @@
"KconfigFile",
)
+
class EntryString(object):
__slots__ = "name", "value"
@@ -16,6 +17,7 @@
def __str__(self):
return "CONFIG_%s=%s" % (self.name, self.value)
+
class EntryTristate(object):
__slots__ = "name", "value"
@@ -23,7 +25,7 @@
VALUE_YES = 1
VALUE_MOD = 2
- def __init__(self, name, value = None):
+ def __init__(self, name, value=None):
self.name = name
if value == 'n' or value is None:
self.value = self.VALUE_NO
@@ -41,6 +43,7 @@
elif self.value == self.VALUE_MOD:
return "%s=m" % conf
+
class KconfigFile(SortedDict):
def __str__(self):
ret = []
@@ -54,7 +57,7 @@
if line.startswith("CONFIG_"):
i = line.find('=')
option = line[7:i]
- value = line[i+1:]
+ value = line[i + 1:]
self.set(option, value)
elif line.startswith("# CONFIG_"):
option = line[9:-11]
@@ -62,7 +65,7 @@
elif line.startswith("#") or not line:
pass
else:
- raise RuntimeError, "Can't recognize %s" % line
+ raise RuntimeError("Can't recognize %s" % line)
def set(self, key, value):
if value in ('y', 'm', 'n'):
@@ -74,4 +77,3 @@
def str_iter(self):
for key, value in self.iteritems():
yield str(value)
-
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/patches.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/patches.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/patches.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,10 +1,13 @@
-import glob, os, shutil
+import glob
+import os
+import shutil
+
class Operation(object):
def __init__(self, name, data):
self.name, self.data = name, data
- def __call__(self, dir = '.', reverse = False):
+ def __call__(self, dir='.', reverse=False):
try:
if not reverse:
self.do(dir)
@@ -28,6 +31,7 @@
def do_reverse(self, dir):
raise NotImplementedError
+
class OperationPatch(Operation):
def __init__(self, name, fopen, data):
super(OperationPatch, self).__init__(name, data)
@@ -46,18 +50,21 @@
def patch_pop(self, dir):
self._call(dir, '-R')
+
class OperationPatchPush(OperationPatch):
operation = '+'
do = OperationPatch.patch_push
do_reverse = OperationPatch.patch_pop
+
class OperationPatchPop(OperationPatch):
operation = '-'
do = OperationPatch.patch_pop
do_reverse = OperationPatch.patch_push
+
class SubOperation(Operation):
def _log(self, result):
if result:
@@ -66,6 +73,7 @@
s = "FAIL"
print """ %-10s %-4s %s""" % ('(%s)' % self.operation, s, self.name)
+
class SubOperationFilesRemove(SubOperation):
operation = "remove"
@@ -77,6 +85,7 @@
else:
os.unlink(n)
+
class SubOperationFilesUnifdef(SubOperation):
operation = "unifdef"
@@ -94,6 +103,7 @@
f1.write(data)
f1.close()
+
class OperationFiles(Operation):
operation = 'X'
@@ -126,7 +136,8 @@
def do(self, dir):
for i in self.ops:
- i(dir = dir)
+ i(dir=dir)
+
class PatchSeries(list):
operations = {
@@ -166,20 +177,21 @@
self.append(self.operations[operation](filename, fopen, data))
- def __call__(self, cond = bool, dir = '.', reverse = False):
+ def __call__(self, cond=bool, dir='.', reverse=False):
if not reverse:
l = self
else:
l = self[::-1]
for i in l:
if cond(i):
- i(dir = dir, reverse = reverse)
+ i(dir=dir, reverse=reverse)
def __repr__(self):
return '<%s object for %s>' % (self.__class__.__name__, self.name)
+
class PatchSeriesList(list):
- def __call__(self, cond = bool, reverse = False):
+ def __call__(self, cond=bool, reverse=False):
if not reverse:
l = self
else:
@@ -189,7 +201,7 @@
print "--> Try to unapply %s." % i.name
else:
print "--> Try to apply %s." % i.name
- i(cond = cond, reverse = reverse)
+ i(cond=cond, reverse=reverse)
if reverse:
print "--> %s fully unapplied." % i.name
else:
@@ -205,4 +217,3 @@
except IOError:
pass
return ret
-
Modified: dists/trunk/linux-2.6/debian/lib/python/debian_linux/utils.py
==============================================================================
--- dists/trunk/linux-2.6/debian/lib/python/debian_linux/utils.py Wed Jan 11 16:33:07 2012 (r18487)
+++ dists/trunk/linux-2.6/debian/lib/python/debian_linux/utils.py Wed Jan 11 16:52:29 2012 (r18488)
@@ -1,13 +1,16 @@
from __future__ import absolute_import
-import re, os, textwrap
+import os
+import re
+import textwrap
_marker = object
+
class SortedDict(dict):
__slots__ = '_list',
- def __init__(self, entries = None):
+ def __init__(self, entries=None):
super(SortedDict, self).__init__()
self._list = []
if entries is not None:
@@ -35,8 +38,9 @@
for i in iter(self._list):
yield self[i]
+
class Templates(object):
- def __init__(self, dirs = ["debian/templates"]):
+ def __init__(self, dirs=["debian/templates"]):
self.dirs = dirs
self._cache = {}
@@ -67,6 +71,7 @@
return default
return value
+
def read_control(f):
from .debian import Package
@@ -96,7 +101,7 @@
if i < 0:
raise ValueError("Not a header, not a continuation: ``%s''" % line)
last = line[:i]
- lines = [line[i+1:].lstrip()]
+ lines = [line[i + 1:].lstrip()]
if last:
e[last] = '\n'.join(lines)
if e:
@@ -104,8 +109,8 @@
return entries
+
class TextWrapper(textwrap.TextWrapper):
wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
-
More information about the Kernel-svn-changes
mailing list