import os
import re
+import itertools
from cStringIO import StringIO
from ganeti import constants
# making an exception here because this script is only used at build time.
from ganeti import _autoconf
+#: Regular expression describing desired format of option names. Long names can
+#: contain lowercase characters, numbers and dashes only.
+_OPT_NAME_RE = re.compile(r"^-[a-zA-Z0-9]|--[a-z][-a-z0-9]+$")
+
def WritePreamble(sw):
"""Writes the script preamble.
# pylint. pylint: disable-msg=W0212
opt.all_names = sorted(opt._short_opts + opt._long_opts)
+ invalid = list(itertools.ifilterfalse(_OPT_NAME_RE.match, opt.all_names))
+ if invalid:
+ raise Exception("Option names don't match regular expression '%s': %s" %
+ (_OPT_NAME_RE.pattern, utils.CommaJoin(invalid)))
+
def _FindFirstArgument(self, sw):
ignore = []
skip_one = []