def __new__(cls, origin_url, create_repo=False, pkg_name=None,
repo_props=EmptyDict, trans_id=None, noexecute=False, xport=None,
pub=None, progtrack=None):
scheme, netloc, path, params, query, fragment = \
urlparse(origin_url, "http", allow_fragments=0)
scheme = scheme.lower()
if noexecute:
scheme = "null"
if scheme != "null" and (not xport or not pub):
raise TransactionError("Caller must supply transport "
"and publisher.")
if scheme not in cls.__schemes:
raise TransactionRepositoryURLError(origin_url,
scheme=scheme)
if scheme.startswith("http") and not netloc:
raise TransactionRepositoryURLError(origin_url,
netloc=None)
if scheme.startswith("file"):
if netloc:
raise TransactionRepositoryURLError(origin_url,
msg="'{0}' contains host information, which "
"is not supported for filesystem "
"operations.".format(netloc))
# as we're urlunparsing below, we need to ensure that
# the path starts with only one '/' character, if any
# are present
if path.startswith("/"):
path = "/" + path.lstrip("/")
elif not path:
raise TransactionRepositoryURLError(origin_url)
# Rebuild the url with the sanitized components.
origin_url = urlunparse((scheme, netloc, path, params,
query, fragment))
return cls.__schemes[scheme](origin_url,
create_repo=create_repo, pkg_name=pkg_name,
repo_props=repo_props, trans_id=trans_id, xport=xport,
pub=pub, progtrack=progtrack)
评论列表
文章目录