uri.py 384 B

123456789101112131415161718
  1. import re
  2. componentRegex = re.compile(r"^[a-z][a-z0-9_]*$")
  3. def checkURI(uri):
  4. """
  5. uri: lowercase, dot separated string.
  6. throws exception if invalid.
  7. returns: uri
  8. """
  9. components = uri.split(".")
  10. for component in components:
  11. match = componentRegex.match(component)
  12. if not match:
  13. raise Exception("invalid URI")
  14. return uri