Address comments on code review
This commit is contained in:
parent
7c45aca405
commit
8d3ce44682
12 changed files with 150 additions and 33 deletions
|
@ -34,6 +34,27 @@ def parse_robot_username(robot_username):
|
|||
return robot_username.split('+', 2)
|
||||
|
||||
|
||||
def parse_urn(urn):
|
||||
""" Parses a URN, returning a pair that contains a list of URN
|
||||
namespace parts, followed by the URN's unique ID.
|
||||
"""
|
||||
if not urn.startswith('urn:'):
|
||||
return None
|
||||
|
||||
parts = urn[len('urn:'):].split(':')
|
||||
return (parts[0:len(parts) - 1], parts[len(parts) - 1])
|
||||
|
||||
|
||||
def parse_single_urn(urn):
|
||||
""" Parses a URN, returning a pair that contains the first
|
||||
namespace part, followed by the URN's unique ID.
|
||||
"""
|
||||
result = parse_urn(urn)
|
||||
if result is None or not len(result[0]):
|
||||
return None
|
||||
|
||||
return (result[0][0], result[1])
|
||||
|
||||
uuid_generator = lambda: str(uuid4())
|
||||
|
||||
|
||||
|
|
Reference in a new issue