def sanitize_name(name):
"""
Sanitize a given name such that it conforms to unix policy.
Args:
name: the name to sanitize.
Returns:
The sanitized form of name.
"""
if len(name) == 0:
raise Exception("Can not sanitize an empty field.")
sanitized_name = re.sub(r"[^a-z0-9\+-]", "-", name.lower())
if sanitized_name[0] in string.digits:
sanitized_name = "p" + sanitized_name
return sanitized_name
#I will never understand why the shutil functions act
#the way they do...
评论列表
文章目录