[apt-proxy-devel] r609 - in people/halls/rework: apt_proxy apt_proxy/test

Chris Halls halls at costa.debian.org
Mon Jul 24 14:08:15 UTC 2006


Author: halls
Date: Mon Jul 24 14:08:13 2006
New Revision: 609

Modified:
   people/halls/rework/apt_proxy/cache.py
   people/halls/rework/apt_proxy/fetchers.py
   people/halls/rework/apt_proxy/test/test_cache.py
   people/halls/rework/apt_proxy/test/test_fetchers.py
   people/halls/rework/debian/changelog
   people/halls/rework/debian/control

Log:
* Swap maintainer/uploader fields
* Add filetype tests
* Always fix cache file
* Add pkgdiff file types


Modified: people/halls/rework/apt_proxy/cache.py
==============================================================================
--- people/halls/rework/apt_proxy/cache.py	(original)
+++ people/halls/rework/apt_proxy/cache.py	Mon Jul 24 14:08:13 2006
@@ -415,22 +415,27 @@
     FileType(re.compile(r"\.u?deb$"), "application/dpkg", 0),
     FileType(re.compile(r"\.tar\.gz$"), "application/x-gtar", 0),
     FileType(re.compile(r"\.dsc$"),"text/plain", 0),
-    FileType(re.compile(r"\.diff\.gz$"), "application/x-gzip", 0),
-    FileType(re.compile(r"\.gz$"), "application/x-gzip", 1),
+    FileType(re.compile(r"\.diff\.gz$"), "x-gzip", 0),
     FileType(re.compile(r"\.bin$"), "application/octet-stream", 0),
     FileType(re.compile(r"\.tgz$"), "application/x-gtar", 0),
-    FileType(re.compile(r"\.txt$"), "application/plain-text", 1),
-    FileType(re.compile(r"\.html$"), "application/text-html", 1),
+    FileType(re.compile(r"\.txt$"), "text/plain", 1),
+    FileType(re.compile(r"\.html$"), "text/html", 1),
 
-    FileType(re.compile(r"(^|/)(Packages|Release(\.gpg)?|Sources|Contents-.*)"
-                        r"(\.(gz|bz2))?$"), 
+    FileType(re.compile(r"(?:^|/)(?:Packages|Release(?:\.gpg)?|Sources|(?:Contents|Translation)-[a-z0-9]+)"
+                        r"(?:\.(?:gz|bz2))?$"),
              "text/plain", 1),
+    FileType(re.compile(r"(?:^|/)(?:Packages|Sources|Contents-[a-z0-9]+)\.diff/Index$"),
+             "text/plain", 1),
+    FileType(re.compile(r"(?:^|/)(?:Packages|Sources|Contents-[a-z0-9]+)\.diff/[a-z0-9.-]+"
+                        r"(?:\.(?:gz|bz2))?$"),
+             "text/plain", 0),
 
     FileType(re.compile(r"\.rpm$"), "application/rpm", 0),
 
-    FileType(re.compile(r"(^|/)(pkglist|release|srclist)(\.(\w|-)+)?"
-                        r"(\.(gz|bz2))?$"), 
+    FileType(re.compile(r"(?:^|/)(?:pkglist|release|srclist)(?:\.(?:\w|-)+)?"
+                        r"(?:\.(?:gz|bz2))?$"), 
              "text/plain", 1),
+    FileType(re.compile(r"\.gz$"), "x-gzip", 1)
     )
 
 

Modified: people/halls/rework/apt_proxy/fetchers.py
==============================================================================
--- people/halls/rework/apt_proxy/fetchers.py	(original)
+++ people/halls/rework/apt_proxy/fetchers.py	Mon Jul 24 14:08:13 2006
@@ -1071,6 +1071,7 @@
             self.timeoutCB.cancel()
             self.timeoutCB = None
         self.queue.append(cacheEntry)
+        print dir(cacheEntry.requests[0].transport)
         if self.activeFile is None:
             self.startNextDownload()
         else:

Modified: people/halls/rework/apt_proxy/test/test_cache.py
==============================================================================
--- people/halls/rework/apt_proxy/test/test_cache.py	(original)
+++ people/halls/rework/apt_proxy/test/test_cache.py	Mon Jul 24 14:08:13 2006
@@ -23,7 +23,7 @@
 
 from apt_proxy.apt_proxy_conf import apConfig
 from apt_proxy.test.test_apt_proxy import apTestHelper
-from apt_proxy.cache import CacheEntry
+from apt_proxy.cache import CacheEntry, findFileType
 from apt_proxy.apt_proxy import Factory
 from apt_proxy.misc import log
 from apt_proxy.fetchers import DownloadQueue
@@ -185,3 +185,38 @@
         self.entry.stat_file()
         self.assertApproximates(self.entry.file_mtime, close_time, 3)
         self.assertEquals(self.entry.file_size, 5)
+
+class FileTypeTest(unittest.TestCase):
+    def testUnknownFiletype(self):
+        self.assertEquals(findFileType('unknownfile.xxx'), None)
+
+    def testFileTypes(self):
+        # Test filname recognition
+        # First entry - filename to test
+        # Second entry - mime type
+        # Third entry - mutable (can this file be changed in the archive?)
+        tests = [ ('test.deb', 'application/dpkg', False),
+                  ('test2.udeb', 'application/dpkg', False),
+                  ('Release.dsc', 'text/plain', False),
+                  ('file.diff.gz', 'x-gzip', False),
+                  ('Packages.gz', 'text/plain', True),
+                  ('Packages.bz2', 'text/plain', True),
+                  ('Sources.bz2', 'text/plain', True),
+                  ('dists/sid/main/binary-i386/Packages.diff/Index', 'text/plain', True),
+                  ('dists/sid/main/binary-i386/Packages.diff/2006-06-05-1427.58.gz', 'text/plain', False),
+                  ('dists/sid/main/source/Sources.diff/Index', 'text/plain', True),
+                  ('dists/sid/main/source/Sources.diff/2006-06-05-1427.58.gz', 'text/plain', False),
+                  ('dists/sid/Contents-i386', 'text/plain', True),
+                  ('dists/sid/Contents-i386.gz', 'text/plain', True),
+                  ('dists/sid/Contents-i386.diff/Index', 'text/plain', True),
+                  ('dists/sid/Contents-i386.diff/2006-06-02-1349.52.gz', 'text/plain', False),
+                  ('dists/sid/main/i18n/Translation-de', 'text/plain', True),
+                  ('dists/sid/main/i18n/Translation-de.gz', 'text/plain', True),
+                  ('dists/sid/main/i18n/Translation-de.bz2', 'text/plain', True)
+                ]
+        for name,mimetype,mutable in tests:
+            log.debug('Testing filetype, name=%s mimetype=%s mutable=%s' % (name, mimetype, mutable))
+            result = findFileType(name)
+            self.assertNotEquals(result, None)
+            self.assertEquals(mimetype, result.contype)
+            self.assertEquals(mutable, result.mutable)

Modified: people/halls/rework/apt_proxy/test/test_fetchers.py
==============================================================================
--- people/halls/rework/apt_proxy/test/test_fetchers.py	(original)
+++ people/halls/rework/apt_proxy/test/test_fetchers.py	Mon Jul 24 14:08:13 2006
@@ -130,7 +130,7 @@
             self.error_code == code:
             self.deferred.callback()
         else:
-            self.deferred.errback()
+            self.deferred.errback(None)
     def server_mtime(self, time):
         if self.wait_for_mtime == True:
             self.deferred.callback(None)

Modified: people/halls/rework/debian/changelog
==============================================================================
--- people/halls/rework/debian/changelog	(original)
+++ people/halls/rework/debian/changelog	Mon Jul 24 14:08:13 2006
@@ -1,7 +1,5 @@
 apt-proxy (1.9.33+svn) unstable; urgency=low
 
-  (New changelog because these changes are for post 1.9.33)
-  [ Chris Halls ]
   * http_proxy can now be set in each [backend] section
   * Add support for username and password in http_proxy parameter.
     Thanks to Thomas Champagne for the patch (Closes: #323147)
@@ -13,9 +11,14 @@
     is installed, thanks Ben Hutchings for the patch (Closes: #312969)
   * Add more unit tests
   * Remove obsolete debian/TODO from source package
+  * Change maintainer to myself and add Otavio to Uploaders, at
+    Otavio's request
+  * Recognise apt package diff files (*.diff/Index). Thanks
+    Florian Weimer for the patch (Closes: #336433)
+  * Add debhelper to Build-Depends, needed for dh_clean in clean target
   * Update doc/TODO, removing fixed items
 
- -- Chris Halls <chris.halls at credativ.co.uk>  Thu,  1 Jun 2006 19:54:29 +0100
+ -- Chris Halls <halls at debian.org>  Mon, 19 Jun 2006 16:39:08 +0100
 
 apt-proxy (1.9.33) unstable; urgency=low
 

Modified: people/halls/rework/debian/control
==============================================================================
--- people/halls/rework/debian/control	(original)
+++ people/halls/rework/debian/control	Mon Jul 24 14:08:13 2006
@@ -1,9 +1,10 @@
 Source: apt-proxy
 Section: admin
 Priority: extra
-Maintainer: Otavio Salvador <otavio at debian.org>
-Uploaders: Chris Halls <halls at debian.org>
+Maintainer: Chris Halls <halls at debian.org>
+Uploaders: Otavio Salvador <otavio at debian.org>
 Standards-Version: 3.6.2
+Build-Depends: debhelper
 Build-Depends-Indep: debhelper (>= 4.1.13), po-debconf, help2man, python-twisted (>= 1.0.0), python, python-apt, po4a (>= 0.18.1)
 
 Package: apt-proxy



More information about the apt-proxy-devel mailing list