def _PrepareRegex(pattern):
  """Compiles a regular expression.

  """
  try:
    return re.compile(pattern)
  except re.error, err:
    raise errors.ParameterError("Invalid regex pattern (%s)" % err)
dataset/ETHPy150Open ganeti/ganeti/lib/query.py/_PrepareRegex/original