Python packages naming
Upstream project name library or standalone program pkgname catalog name
foo standalone CSWfoo foo
foo library CSWpy-foo py_foo
pyfoo standalone CSWpyfoo pyfoo
pyfoo library CSWpy-foo py_foo
foopy standalone CSWfoopy foopy
foopy library CSWpy-foopy py_foopy

Python implementation and a unit test for the above table:

import unittest
import re
 
def PythonName(project_name, project_type):
    if project_type == "standalone":
        return project_name, "CSW%s" % project_name
    project_name = re.sub(r"^py", "", project_name, 1)
    return "py_%s" % project_name, "CSWpy-%s" % project_name
 
class PythonNameUnitTest(unittest.TestCase):
 
    TEST_NAMES = {
            ("foo",   "standalone"): ("foo",     "CSWfoo"),
            ("foo",   "library"):    ("py_foo",  "CSWpy-foo"),
            ("pyfoo", "standalone"): ("pyfoo",   "CSWpyfoo"),
            ("pyfoo", "library"):    ("py_foo",  "CSWpy-foo"),
            ("foopy", "standalone"): ("foopy",   "CSWfoopy"),
            ("foopy", "library"):    ("py_foopy",  "CSWpy-foopy"),
            ("thon",  "standalone"): ("thon",    "CSWthon"),
            ("thon",  "library"):    ("py_thon", "CSWpy-thon"),
            ("pypy",  "library"):    ("py_py",   "CSWpy-py"),
    }
 
    def testPythonName(self):
        for name in self.TEST_NAMES:
            self.assertEquals(self.TEST_NAMES[name], PythonName(*name))
 
if __name__ == '__main__':
    unittest.main()

Links that may be of interest:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License