def _find_distribution(self, module): path = get_module_path(module) if path == self.trac_path: return pkg_resources.Distribution(project_name = 'Trac', version = TRAC_VERSION, location = path) for dist in pkg_resources.find_distributions(path, only = True): return dist else: # This is a plain Python source file, not an egg return pkg_resources.Distribution(project_name = module.__name__, version = '', location = module.__file__)
def _find_distribution(self, module): path = get_module_path(module) if path == self.trac_path: return pkg_resources.Distribution(project_name='Trac', version=TRAC_VERSION, location=path) for dist in pkg_resources.find_distributions(path, only=True): return dist else: # This is a plain Python source file, not an egg return pkg_resources.Distribution(project_name=module.__name__, version='', location=module.__file__)
def find_distribution(module): name = module.__name__ path = get_module_path(module) sources = path_sources.get(path) if sources is None: sources = path_sources[path] = get_sources(path) dist = sources.get(name.replace('.', '/') + '.py') if dist is None: dist = sources.get(name.replace('.', '/') + '/__init__.py') if dist is None: # This is a plain Python source file, not an egg dist = pkg_resources.Distribution(project_name=name, version='', location=module.__file__) return dist
def test_get_module_path(self): self.assertEqual(util.get_module_path(trac), util.get_module_path(util))
def __init__(self): self.trac_path = get_module_path(sys.modules['trac.core'])