This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/names.py

27 lines
675 B
Python
Raw Normal View History

import urllib
2013-09-23 16:37:40 +00:00
from functools import wraps
def parse_namespace_repository(repository):
parts = repository.rstrip('/').split('/', 1)
if len(parts) < 2:
namespace = 'library'
repository = parts[0]
else:
(namespace, repository) = parts
repository = urllib.quote_plus(repository)
return (namespace, repository)
2013-09-23 16:37:40 +00:00
def parse_repository_name(f):
@wraps(f)
def wrapper(repository, *args, **kwargs):
(namespace, repository) = parse_namespace_repository(repository)
return f(namespace, repository, *args, **kwargs)
return wrapper
2013-11-20 21:13:03 +00:00
def format_robot_username(parent_username, robot_shortname):
return '%s+%s' % (parent_username, robot_shortname)