[Zope-CVS] SVN: zpkgtools/trunk/zpkgtools/ deal with relative paths
in resource maps identified from the command line
Fred L. Drake, Jr.
fdrake at gmail.com
Thu Oct 28 00:48:35 EDT 2004
Log message for revision 28269:
deal with relative paths in resource maps identified from the command line
by relative paths; everything becomes a URL internally
Changed:
U zpkgtools/trunk/zpkgtools/app.py
U zpkgtools/trunk/zpkgtools/tests/test_app.py
-=-
Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py 2004-10-27 19:43:14 UTC (rev 28268)
+++ zpkgtools/trunk/zpkgtools/app.py 2004-10-28 04:48:35 UTC (rev 28269)
@@ -27,6 +27,7 @@
from zpkgsetup import package
from zpkgsetup import publication
from zpkgsetup import setup
+from zpkgsetup import urlutils
from zpkgtools import config
from zpkgtools import dependencies
@@ -50,7 +51,17 @@
self.logger = logging.getLogger(__name__)
self.options = options
cf = config.Configuration()
- cf.location_maps.extend(options.location_maps)
+ # The resource maps and loader tools assume that all resources
+ # are being addressed by URLs, so we need to make sure paths
+ # referenced on the command line are converted to URLs before
+ # loading anything.
+ location_maps = []
+ for map in options.location_maps:
+ if os.path.isfile(map):
+ map = os.path.abspath(map)
+ map = "file://" + urlutils.pathname2url(map)
+ location_maps.append(map)
+ cf.location_maps.extend(location_maps)
path = options.configfile
if path is None:
path = config.defaultConfigurationPath()
Modified: zpkgtools/trunk/zpkgtools/tests/test_app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_app.py 2004-10-27 19:43:14 UTC (rev 28268)
+++ zpkgtools/trunk/zpkgtools/tests/test_app.py 2004-10-28 04:48:35 UTC (rev 28269)
@@ -25,6 +25,7 @@
from zpkgsetup import package
from zpkgsetup import publication
+from zpkgsetup import urlutils
from zpkgsetup.tests import tempfileapi as tempfile
import zpkgtools
@@ -466,7 +467,31 @@
cls = context.get_distribution_class()
self.assert_(cls is mysupport.MyDistribution)
+ def test_relative_paths_in_cmdline_resource_maps(self):
+ """Make sure that paths passed to the -m option become URLs.
+ The resource maps and loader tools like to think of addresses
+ as URLs, so paths passed in on the command line need to become
+ URLs before being processed; this ensures that happens and
+ that relative paths inside a resource map are handled
+ correctly in that case (not just when referenced from a
+ configuration file).
+
+ """
+ orig_pwd = os.getcwd()
+ here = os.path.dirname(os.path.abspath(__file__))
+ mapfile = os.path.join("input", "packages.map")
+ args = ["-f", "-m", mapfile, "package"]
+ os.chdir(here)
+ try:
+ app = self.createApplication(args)
+ pkgurl = "file://%s/" % urlutils.pathname2url(
+ os.path.join(here, "input", "package"))
+ self.assertEqual(app.locations["package"], pkgurl)
+ finally:
+ os.chdir(orig_pwd)
+
+
class DelayedCleanupBuilderApplication(app.BuilderApplication):
def create_tarball(self):
More information about the Zope-CVS
mailing list