[Pkg-python-debian-commits] r61 trunk: Merge in my deb822_in_debian_bundle branch

John Wright john at movingsucks.org
Thu Jul 12 21:04:56 UTC 2007


------------------------------------------------------------
revno: 61
committer: John Wright <john at movingsucks.org>
branch nick: trunk
timestamp: Thu 2007-07-12 15:04:56 -0600
message:
  Merge in my deb822_in_debian_bundle branch
added:
  HISTORY.deb822
  deb822.py
modified:
  README.deb822
  debian/changelog
  debian/control
  debian/docs
  debian/rules
  debian_bundle/deb822.py
  debian_bundle/test_deb822.py
  setup.py.in
    ------------------------------------------------------------
    revno: 55.1.2
    merged: john at movingsucks.org-20070701221635-s109zhfa87r71z1q
    committer: John Wright <john at movingsucks.org>
    branch nick: deb822_in_debian_bundle
    timestamp: Sun 2007-07-01 16:16:35 -0600
    message:
      Wrap a long line in debian/changelog
    ------------------------------------------------------------
    revno: 55.1.1
    merged: john at movingsucks.org-20070701221545-73fp8wq0py89tx35
    committer: John Wright <john at movingsucks.org>
    branch nick: deb822_in_debian_bundle
    timestamp: Sun 2007-07-01 16:15:45 -0600
    message:
      * debian_bundle/deb822.py, debian_bundle/test_deb822.py, deb822.py:
        - Import latest version of deb822, and create a "dummy" top-level module
          for compatibility
      * debian/rules:
        - No longer delete deb822 files
      * debian/control:
        - Add Provides, Conflicts, and Replaces fields for python-deb822
        - When describing features, mention which modules they are implemented in
      * HISTORY.deb822, debian/docs:
        - Install old changelog for deb822 as /usr/share/doc/python-debian/HISTORY.deb822
-------------- next part --------------
=== added file 'HISTORY.deb822'
--- a/HISTORY.deb822	1970-01-01 00:00:00 +0000
+++ b/HISTORY.deb822	2007-07-01 22:15:45 +0000
@@ -0,0 +1,51 @@
+Following is the changelog for deb822 before it was merged into python-debian.
+
+deb822 (0.3) unstable; urgency=low
+
+  * deb822.py:
+    - Allow Deb822 objects to be initialized with a dict containing the initial
+      key-value pairs.
+    - _multivalued class:
+      + Make all the multivalued dicts Deb822Dict objects, so the keys are
+        case-preserving, but case-insensitive
+    - Add a Release class, which knows about Release-file multivalued fields.
+      Thanks to Alexandre Fayolle.  (Closes: 428540)
+    - Deb822Dict no longer directly subclasses dict.  All of the important
+      methods were already implemented with userdict.DictMixin; the dict
+      subclass was so that Python would see a Deb822Dict instance as a dict
+      instance.  Unfortunately, this causes confusion if you do something like
+        d = dict(Deb822Dict({'foo': 'bar'})
+      The "Pythonic" way to check for a dictionary interface is to check for
+      the 'items' attribute.
+  * test_deb822.py:
+    - Add a test case for deriving a Python dict from a Deb822Dict.
+  * debian/control:
+    - Add a XS-Vcs-Bzr field
+
+ -- John Wright <john at movingsucks.org>  Tue, 12 Jun 2007 17:37:05 -0600
+
+deb822 (0.2) unstable; urgency=low
+
+  * debian/rules:
+    - Tell setup.py not to compile the modules -- python-support does that at
+      install time
+  * README:
+    - Fix a typo
+  * debian/control:
+    - Improve the description
+    - Remove X[BS]-Python-Version fields, as per python-support README
+  * deb822.py:
+    - Add a get_pool_path() method to the Changes class which returns the path
+      in the pool you would expect to find the files listed in the .changes
+      file
+    - Fix a typo in Deb822Dict.__init__ where I was referring to fields, not
+      _fields
+  * Remove debian/pycompat, as per python-support README
+
+ -- John Wright <john at movingsucks.org>  Fri,  5 Jan 2007 17:40:54 -0700
+
+deb822 (0.1) unstable; urgency=low
+
+  * Initial packaging (Closes: 380173)
+
+ -- John Wright <john at movingsucks.org>  Wed, 15 Nov 2006 17:00:32 -0700

=== added file 'deb822.py'
--- a/deb822.py	1970-01-01 00:00:00 +0000
+++ b/deb822.py	2007-07-01 22:15:45 +0000
@@ -0,0 +1,5 @@
+from debian_bundle.deb822 import *
+
+# FIXME: Give a warning about path change.  Should we raise DeprecationWarning
+# (I vote no, since that will stop execution unless caught), or just print a
+# message to stderr?

=== modified file 'README.deb822'
--- a/README.deb822	2006-10-01 20:17:21 +0000
+++ b/README.deb822	2007-07-01 22:15:45 +0000
@@ -5,7 +5,7 @@
 Debian data formats, like Packages/Sources, .changes/.dsc, pdiff Index files,
 etc. The benefit is that deb822 knows about special fields that contain
 whitespace separated sub-fields, and provides named access to them. For
-example, the "Files" filed in Source packages, which has three subfields, or
+example, the "Files" field in Source packages, which has three subfields, or
 "Files" in .changes files, which has five. These are known as "multifields".
 
 deb822 has no external dependencies, but can use python-apt if available to
@@ -13,7 +13,7 @@
 over big Packages files.
 
 Key lookup in Deb822 objects and their multifields is case-insensitive, but the
-original case is always preserved, e.g. when printing the object. [XXX TODO]
+original case is always preserved, e.g. when printing the object.
 
 
 Classes

=== modified file 'debian/changelog'
--- a/debian/changelog	2007-07-12 10:23:45 +0000
+++ b/debian/changelog	2007-07-12 21:04:56 +0000
@@ -18,17 +18,26 @@
     - added grep-maintainer example to show the Packages parsing API
 
   [ John Wright ]
+  * debian_bundle/deb822.py, debian_bundle/test_deb822.py, deb822.py:
+    - Import latest version of deb822, and create a "dummy" top-level module
+      for compatibility
   * setup.py:
     - The version wasn't getting updated, so I've renamed it to setup.py.in,
       and added a __CHANGELOG_VERSION__ placeholder
   * debian/rules:
     - Generate generate setup.py from setup.py.in, filling in the version
       information from debian/changelog
+    - No longer delete deb822 files
   * debian/control:
     - The above generation depends on m4, so add that as a Build-Depends
     - Add myself as an uploader
+    - Add Provides, Conflicts, and Replaces fields for python-deb822
+    - When describing features, mention which modules they are implemented in
+  * HISTORY.deb822, debian/docs:
+    - Install old changelog for deb822 as
+      /usr/share/doc/python-debian/HISTORY.deb822
 
- -- Stefano Zacchiroli <zack at debian.org>  Thu, 12 Jul 2007 12:22:13 +0200
+ -- John Wright <john at movingsucks.org>  Thu, 12 Jul 2007 15:01:08 -0600
 
 python-debian (0.1.3) unstable; urgency=low
 

=== modified file 'debian/control'
--- a/debian/control	2007-07-01 04:00:27 +0000
+++ b/debian/control	2007-07-01 22:15:45 +0000
@@ -12,9 +12,15 @@
 Architecture: all
 Depends: ${python:Depends}
 Suggests: python-apt
+Provides: python-deb822
+Conflicts: python-deb822
+Replaces: python-deb822
 Description: python modules to work with Debian-related data formats
  This package provides python modules that abstract many formats of Debian 
  related files. Currently handled are:
-  * Debtags information.
-  * debian/changelog.
-  * Packages files.
+  * Debtags information (debian_bundle.debtags module)
+  * debian/changelog (debian_bundle.changelog module)
+  * Packages files, pdiffs (debian_bundle.debian_support module)
+  * Control files of single or multple RFC822-style paragraphs, e.g
+    debian/control, .changes, .dsc, Packages, Sources, Release, etc.
+    (debian_bundle.deb822 module)

=== modified file 'debian/docs'
--- a/debian/docs	2006-11-20 20:27:13 +0000
+++ b/debian/docs	2007-07-01 22:15:45 +0000
@@ -1,3 +1,5 @@
 README.changelog
 README.debtags
+README.deb822
 README
+HISTORY.deb822

=== modified file 'debian/rules'
--- a/debian/rules	2007-07-01 04:17:35 +0000
+++ b/debian/rules	2007-07-01 22:15:45 +0000
@@ -58,10 +58,6 @@
 	# but so far, he has no better place for it
 	#rm "$(CURDIR)/debian/python-debian/usr/share/doc/python-debian/examples/wxssearch"
 	rm "$(CURDIR)/debian/python-debian/usr/share/doc/python-debian/examples/debtags/wxssearch"
-	#TODO: there is a python-deb822 package so don't provide deb822.py for now,
-	# at lest until we discuss it.
-	rm "$(CURDIR)/debian/python-debian/usr/lib/python2.4/site-packages/debian_bundle/deb822.py"
-	rm "$(CURDIR)/debian/python-debian/usr/lib/python2.4/site-packages/debian_bundle/test_deb822.py"
 #	dh_install
 	dh_compress -Xexamples
 	dh_fixperms

=== modified file 'debian_bundle/deb822.py'
--- a/debian_bundle/deb822.py	2006-10-01 20:17:21 +0000
+++ b/debian_bundle/deb822.py	2007-07-01 22:15:45 +0000
@@ -30,9 +30,19 @@
 
 import re
 import StringIO
+import UserDict
 
-class Deb822Dict(dict):
-    """A dictionary suitable for storing RFC822-like data.
+class Deb822Dict(UserDict.DictMixin):
+    # Subclassing UserDict.DictMixin because we're overriding so much dict
+    # functionality that subclassing dict requires overriding many more than
+    # the four methods that DictMixin requires.
+    #
+    # HACK: I'm also subclassing dict, but all the methods we care about will
+    # already be provided by DictMixin.  This way, Deb822Dict is a "real"
+    # subclass of dict, i.e.
+    #     isinstance(Deb822Dict(), dict) == True
+    # but we get out of implementing lots of methods.
+    """A dictionary-like object suitable for storing RFC822-like data.
 
     Deb822Dict behaves like a normal dict, except:
         - key lookup is case-insensitive
@@ -49,6 +59,7 @@
     # See the end of the file for the definition of _strI
 
     def __init__(self, _dict=None, _parsed=None, _fields=None):
+        self.__dict = {}
         self.__keys = []
         self.__parsed = None
 
@@ -73,54 +84,53 @@
             if _fields is None:
                 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
+
     def __setitem__(self, key, value):
         key = _strI(key)
         if not key in self:
             self.__keys.append(key)
-        dict.__setitem__(self, key, value)
+        self.__dict[key] = value
         
     def __getitem__(self, key):
         key = _strI(key)
         try:
-            return dict.__getitem__(self, key)
+            return self.__dict[key]
         except KeyError:
-            if self.__parsed is not None:
+            if self.__parsed is not None and key in self.__keys:
                 return self.__parsed[key]
             else:
                 raise
     
     def __delitem__(self, key):
         key = _strI(key)
-        dict.__delitem__(self, key)
+        del self.__dict[key]
         self.__keys.remove(key)
+    
+    def keys(self):
+        return [str(key) for key in self.__keys]
+    
+    ### END DictMixin methods
 
-    def __contains__(self, key):
-        key = _strI(key)
-        return key in self.__keys
-    
     def __repr__(self):
         return '{%s}' % ', '.join(['%r: %r' % (k, v) for k, v in self.items()])
 
-    def keys(self):
-        return list(self.__keys)
-
-    def items(self):
-        return [(k, self[k]) for k in self.keys()]
-
-    def values(self):
-        return [self[k] for k in self.keys()]
-
-    def iterkeys(self):
-        return iter(self.__keys)
-    __iter__ = iterkeys
-
-    def iteritems(self):
-        for k in self.iterkeys():
-            yield (k, self[k])
-    
+    def __eq__(self, other):
+        mykeys = self.keys(); mykeys.sort()
+        otherkeys = other.keys(); otherkeys.sort()
+        if not mykeys == otherkeys:
+            return False
+
+        for key in mykeys:
+            if self[key] != other[key]:
+                return False
+
+        # If we got here, everything matched
+        return True
+
     def copy(self):
         copy = Deb822Dict(self)
         return copy
@@ -134,7 +144,8 @@
         """Create a new Deb822 instance.
 
         :param sequence: a string, or any any object that returns a line of
-            input each time, normally a file().
+            input each time, normally a file().  Alternately, sequence can
+            be a dict that contains the initial key-value pairs.
 
         :param fields: if given, it is interpreted as a list of fields that
             should be parsed (the rest will be discarded).
@@ -142,7 +153,12 @@
         :param _parsed: internal parameter.
         """
 
-        Deb822Dict.__init__(self, _parsed=_parsed, _fields=fields)
+        if hasattr(sequence, 'items'):
+            _dict = sequence
+            sequence = None
+        else:
+            _dict = None
+        Deb822Dict.__init__(self, _dict=_dict, _parsed=_parsed, _fields=fields)
 
         if sequence is not None:
             try:
@@ -396,11 +412,11 @@
                 self[field] = []
                 updater_method = self[field].append
             else:
-                self[field] = {}
+                self[field] = Deb822Dict()
                 updater_method = self[field].update
 
             for line in filter(None, contents.splitlines()):
-                updater_method(dict(zip(fields, line.split())))
+                updater_method(Deb822Dict(zip(fields, line.split())))
 
     def dump(self, fd=None):
         """Dump the contents in the original format
@@ -446,6 +462,30 @@
         "files": [ "md5sum", "size", "section", "priority", "name" ],
     }
 
+    def get_pool_path(self):
+        """Return the path in the pool where the files would be installed"""
+    
+        # This is based on the section listed for the first file.  While
+        # it is possible, I think, for a package to provide files in multiple
+        # sections, I haven't seen it in practice.  In any case, this should
+        # probably detect such a situation and complain, or return a list...
+        
+        s = self['files'][0]['section']
+
+        try:
+            section, subsection = s.split('/')
+        except ValueError:
+            # main is implicit
+            section = 'main'
+
+        if self['source'].startswith('lib'):
+            subdir = self['source'][:4]
+        else:
+            subdir = self['source'][0]
+
+        return 'pool/%s/%s/%s' % (section, subdir, self['source'])
+
+
 class PdiffIndex(_multivalued):
     _multivalued_fields = {
         "sha1-current": [ "SHA1", "size" ],
@@ -453,6 +493,14 @@
         "sha1-patches": [ "SHA1", "size", "date" ],
     }
 
+
+class Release(_multivalued):
+    _multivalued_fields = {
+        "md5sum": [ "md5sum", "size", "name" ],
+        "sha1": [ "sha1", "size", "name" ],
+        "sha256": [ "sha256", "size", "name" ],
+    }
+
 Sources = Dsc
 Packages = Deb822
 

=== modified file 'debian_bundle/test_deb822.py'
--- a/debian_bundle/test_deb822.py	2006-10-01 20:17:21 +0000
+++ b/debian_bundle/test_deb822.py	2007-07-01 22:15:45 +0000
@@ -186,6 +186,12 @@
 
         self.assertEqual(keys, keys2)
 
+    def test_derived_dict_equality(self):
+        d1 = self.make_dict()
+        d2 = dict(d1)
+
+        self.assertEqual(d1, d2)
+
 
 class TestDeb822(unittest.TestCase):
     def assertWellParsed(self, deb822_, dict_):

=== modified file 'setup.py.in'
--- a/setup.py.in	2007-07-01 04:00:27 +0000
+++ b/setup.py.in	2007-07-01 22:15:45 +0000
@@ -23,4 +23,5 @@
       description='Debian package related modules',
       url='http://packages.qa.debian.org/p/python-debian.html',
       packages=['debian_bundle'],
+      py_modules=['deb822'],
      )



More information about the pkg-python-debian-commits mailing list