[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - package.py:1.8
Fred L. Drake, Jr.
fred at zope.com
Mon Apr 5 18:20:03 EDT 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv8152
Modified Files:
package.py
Log Message:
loadCollectionInfo(): new function for loaded package-info like information
for a non-package component
=== Packages/zpkgtools/zpkgtools/package.py 1.7 => 1.8 ===
--- Packages/zpkgtools/zpkgtools/package.py:1.7 Mon Apr 5 11:56:53 2004
+++ Packages/zpkgtools/zpkgtools/package.py Mon Apr 5 18:19:32 2004
@@ -43,9 +43,24 @@
def loadPackageInfo(pkgname, directory, reldir, file=None):
- if not file:
- file = PACKAGE_CONF
- path = os.path.join(directory, file)
+ pkginfo = read_package_info(directory, reldir, file)
+ pkginfo.extensions = [create_extension(ext, pkgname, reldir)
+ for ext in pkginfo.extension]
+ return pkginfo
+
+
+def loadCollectionInfo(directory, file=None):
+ pkginfo = read_package_info(directory, "", file)
+ if pkginfo.extension:
+ raise ValueError("extensions cannot be defined in collections")
+ pkginfo.extensions = []
+ return pkginfo
+
+
+def read_package_info(directory, reldir, filename):
+ if not filename:
+ filename = PACKAGE_CONF
+ path = os.path.join(directory, filename)
if os.path.exists(path):
path = os.path.realpath(path)
url = "file://" + urllib.pathname2url(path)
@@ -60,12 +75,9 @@
pkginfo = p.load()
finally:
f.close()
- pkginfo.extensions = [create_extension(ext, pkgname, reldir)
- for ext in pkginfo.extension]
- if reldir:
- pkginfo.documentation = expand_globs(directory, reldir,
- pkginfo.documentation)
- pkginfo.script = expand_globs(directory, reldir, pkginfo.script)
+ pkginfo.documentation = expand_globs(directory, reldir,
+ pkginfo.documentation)
+ pkginfo.script = expand_globs(directory, reldir, pkginfo.script)
return pkginfo
@@ -134,8 +146,10 @@
if not filenames:
raise ValueError(
"filename pattern %r doesn't match any files" % g)
- results += [posixpath.join(reldir, fn.replace(os.sep, "/"))
- for fn in filenames]
+ filenames = [fn.replace(os.sep, "/") for fn in filenames]
+ if reldir:
+ filenames = [posixpath.join(reldir, fn) for fn in filenames]
+ results += filenames
finally:
os.chdir(pwd)
return results
More information about the Zope-CVS
mailing list