From a55ea41bd33f45787161595733f527046289556d Mon Sep 17 00:00:00 2001 From: Rob Cakebread Date: Fri, 8 Aug 2008 04:44:43 +0000 Subject: [PATCH] Replace . in pkg name with a - git-svn-id: http://g-pypi.googlecode.com/svn/trunk@21 118783bc-b352-0410-bbc3-0f610f6f7ae8 --- g_pypi/enamer.py | 9 +++++++-- tests/test_enamer.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/g_pypi/enamer.py b/g_pypi/enamer.py index fc604a4..397c257 100644 --- a/g_pypi/enamer.py +++ b/g_pypi/enamer.py @@ -141,8 +141,7 @@ def is_good_filename(uri): def split_p(uri): """Try to split a URI into PN, PV""" p = get_filename(uri) - psplit = pkgsplit(p) - return psplit + return pkgsplit(p) def get_components(uri): """Split uri into pn and pv and new uri""" @@ -341,6 +340,12 @@ def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""): if not my_pn: my_pn = pn pn = pn.lower() + + if "." in pn: + my_pn = '${PN/./-}' + pn = pn.replace('.', '-') + my_p = "${MY_PN}-${PV}" + p = "%s-%s" % (pn, pv) #Check if we need to use MY_P based on src's uri diff --git a/tests/test_enamer.py b/tests/test_enamer.py index 928879a..f880d84 100644 --- a/tests/test_enamer.py +++ b/tests/test_enamer.py @@ -580,6 +580,38 @@ def test_get_vars22(): results = get_vars(uri, up_pn, up_pv) _get_vars(input_test, correct, results) +def test_get_vars23(): + """ + package name with a '.' in it, Zope packages have this often + + Problem: + We can't have a '.' in PN + + Solution: + We convert the . to a - + + Note: We also may need to use PYTHON_MODNAME='pkg.foo' + + Example: + zope.foo -> zope-foo + """ + up_pn = "pkg.foo" + up_pv = "1.0" + uri = "http://www.foo.com/pkg.foo-1.0.tbz2" + input_test = (uri, up_pn, up_pv) + correct = \ + {'pn': 'pkg-foo', + 'pv': '1.0', + 'p': 'pkg-foo-1.0', + 'my_pn': '${PN/./-}', + 'my_pv': '', + 'my_p': '${MY_PN}-${PV}', + 'my_p_raw': 'pkg.foo-1.0', + 'src_uri': 'http://www.foo.com/${MY_P}.tbz2', + } + results = get_vars(uri, up_pn, up_pv) + _get_vars(input_test, correct, results) + def _get_vars(input_test, correct, results): try: -- 2.26.2