def _possible_names(cls, package: PackageInfo) -> List[str]:
names = list()
for url_str in package.get_urls():
url = urlparse(url_str)
host = url.netloc
if not host.endswith('github.com'):
continue
path = PurePosixPath(url.path)
parts = path.parts
if path.is_absolute():
parts = parts[1:]
if len(parts) >= 2:
# Get the first 2 path components without extensions
# this should handle:
# - owner/project
# - owner/project.git
# - owner/project/releases
name = PurePosixPath(parts[0])
# strip off .git if the project name contains it
# don't just strip off any ext because "." is valid
name_project = parts[1]
if name_project.endswith('.git'):
name_project = name_project[:-len('.git')]
name = name.joinpath(name_project)
names.append(str(name))
return names
评论列表
文章目录