[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - dependencies.py:1.3 locationmap.py:1.8

Fred L. Drake, Jr. fred at zope.com
Mon Mar 29 11:51:29 EST 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv7071

Modified Files:
	dependencies.py locationmap.py 
Log Message:
- make the dependencies support play the same typing dance as everything else
- check package: dependencies and locations for legal pakcage names


=== Packages/zpkgtools/zpkgtools/dependencies.py 1.2 => 1.3 ===
--- Packages/zpkgtools/zpkgtools/dependencies.py:1.2	Wed Mar 17 11:42:24 2004
+++ Packages/zpkgtools/zpkgtools/dependencies.py	Mon Mar 29 11:50:58 2004
@@ -13,39 +13,19 @@
 ##############################################################################
 """Support for handling dependency information."""
 
-import re
 import sets
 
-
-_ident = "[a-zA-Z_][a-zA-Z_0-9]*"
-_module_match = re.compile(r"%s(\.%s)*$" % (_ident, _ident)).match
-
-
-def isModuleName(string):
-    return _module_match(string) is not None
+from zpkgtools import locationmap
 
 
 def load(f):
-    deps = DependencyInfo()
-    deps.load(f)
+    deps = sets.Set()
+    while True:
+        line = f.readline().strip()
+        if not line:
+            return deps
+        if line[0] == "#":
+            continue
+        dep = locationmap.normalizeResourceId(line)
+        deps.add(dep)
     return deps
-
-
-class DependencyInfo(object):
-    """Dependency information."""
-
-    def __init__(self):
-        self.packages = sets.Set()
-        self.others = sets.Set()
-
-    def load(self, f):
-        while True:
-            line = f.readline().strip()
-            if not line:
-                return
-            if line[0] == "#":
-                continue
-            if isModuleName(line):
-                self.packages.add(line)
-            else:
-                self.others.add(line)


=== Packages/zpkgtools/zpkgtools/locationmap.py 1.7 => 1.8 ===
--- Packages/zpkgtools/zpkgtools/locationmap.py:1.7	Thu Mar 18 17:32:40 2004
+++ Packages/zpkgtools/zpkgtools/locationmap.py	Mon Mar 29 11:50:58 2004
@@ -16,6 +16,7 @@
 import logging
 import os.path
 import posixpath
+import re
 import sets
 import urllib
 import urllib2
@@ -159,4 +160,14 @@
     type, rest = urllib.splittype(resource)
     if not type:
         type = DEFAULT_TYPE
+    if type == "package":
+        if not isModuleName(rest):
+            raise ValueError("not a valid package name: %r" % rest)
     return "%s:%s" % (type, rest)
+
+
+_ident = "[a-zA-Z_][a-zA-Z_0-9]*"
+_module_match = re.compile(r"%s(\.%s)*$" % (_ident, _ident)).match
+
+def isModuleName(string):
+    return _module_match(string) is not None




More information about the Zope-CVS mailing list