aboutsummaryrefslogtreecommitdiffstats
path: root/debian/lib/python/debian_linux/utils.py
diff options
context:
space:
mode:
authorBastian Blank <waldi@debian.org>2007-06-17 10:34:22 +0000
committerBastian Blank <waldi@debian.org>2007-06-17 10:34:22 +0000
commitbb11d129398e6dea016b3000302d52b46158b902 (patch)
tree55923668d4aa250747bd929f11b8906c2578ab6c /debian/lib/python/debian_linux/utils.py
parent977cda078b7fb258bb62bc8d37bd7b671ea00537 (diff)
downloadkernel_replicant_linux-bb11d129398e6dea016b3000302d52b46158b902.tar.gz
kernel_replicant_linux-bb11d129398e6dea016b3000302d52b46158b902.tar.bz2
kernel_replicant_linux-bb11d129398e6dea016b3000302d52b46158b902.zip
debian/bin/gencontrol.py, debian/lib/python/debian_linux: Coding style cleanup.
svn path=/dists/trunk/linux-2.6/; revision=8981
Diffstat (limited to 'debian/lib/python/debian_linux/utils.py')
-rw-r--r--debian/lib/python/debian_linux/utils.py61
1 files changed, 9 insertions, 52 deletions
diff --git a/debian/lib/python/debian_linux/utils.py b/debian/lib/python/debian_linux/utils.py
index 8fb7b5351b05..f41233c5c558 100644
--- a/debian/lib/python/debian_linux/utils.py
+++ b/debian/lib/python/debian_linux/utils.py
@@ -1,21 +1,21 @@
import debian, re, textwrap
-class sorted_dict(dict):
+class SortedDict(dict):
__slots__ = '_list',
def __init__(self, entries = None):
- super(sorted_dict, self).__init__()
+ super(SortedDict, self).__init__()
self._list = []
if entries is not None:
for key, value in entries:
self[key] = value
def __delitem__(self, key):
- super(sorted_dict, self).__delitem__(key)
+ super(SortedDict, self).__delitem__(key)
self._list.remove(key)
def __setitem__(self, key, value):
- super(sorted_dict, self).__setitem__(key, value)
+ super(SortedDict, self).__setitem__(key, value)
if key not in self._list:
self._list.append(key)
@@ -31,50 +31,7 @@ class sorted_dict(dict):
for i in iter(self._list):
yield self[i]
-class field_list(list):
- TYPE_WHITESPACE = object()
- TYPE_COMMATA = object()
-
- def __init__(self, value = None, type = TYPE_WHITESPACE):
- self.type = type
- if isinstance(value, field_list):
- self.type = value.type
- self.extend(value)
- elif isinstance(value, (list, tuple)):
- self.extend(value)
- else:
- self._extend(value)
-
- def __str__(self):
- if self.type is self.TYPE_WHITESPACE:
- type = ' '
- elif self.type is self.TYPE_COMMATA:
- type = ', '
- return type.join(self)
-
- def _extend(self, value):
- if self.type is self.TYPE_WHITESPACE:
- type = '\s'
- elif self.type is self.TYPE_COMMATA:
- type = ','
- if value is not None:
- self.extend([j.strip() for j in re.split(type, value.strip())])
-
- def extend(self, value):
- if isinstance(value, str):
- self._extend(value)
- else:
- super(field_list, self).extend(value)
-
-class field_list_commata(field_list):
- def __init__(self, value = None):
- super(field_list_commata, self).__init__(value, field_list.TYPE_COMMATA)
-
-class field_string(str):
- def __str__(self):
- return '\n '.join(self.split('\n'))
-
-class templates(dict):
+class Templates(dict):
def __init__(self, dir = "debian/templates"):
self.dir = dir
@@ -94,15 +51,15 @@ class templates(dict):
f = file("%s/%s.in" % (self.dir, name))
if prefix == 'control':
- return self._read_control(f)
+ return self._readControl(f)
return f.read()
- def _read_control(self, f):
+ def _readControl(self, f):
entries = []
while True:
- e = debian.package()
+ e = debian.Package()
last = None
lines = []
while True:
@@ -133,7 +90,7 @@ class templates(dict):
return entries
-class wrap(textwrap.TextWrapper):
+class TextWrapper(textwrap.TextWrapper):
wordsep_re = re.compile(
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash