def Id(v):
"""Coerce to either a hex UUID, a 2-digit hex value."""
# Yes, we actually do want this function to raise ValueErrors instead of
# GadgetSpecificationErrors.
try:
return UUID(hex=v)
except ValueError:
pass
mo = re.match('^[a-fA-F0-9]{2}$', v)
if mo is None:
raise ValueError(v)
return mo.group(0).upper()
评论列表
文章目录