Revision 49283373

b/autotools/build-bash-completion
28 28

  
29 29
import os
30 30
import re
31
import itertools
31 32
from cStringIO import StringIO
32 33

  
33 34
from ganeti import constants
......
39 40
# making an exception here because this script is only used at build time.
40 41
from ganeti import _autoconf
41 42

  
43
#: Regular expression describing desired format of option names. Long names can
44
#: contain lowercase characters, numbers and dashes only.
45
_OPT_NAME_RE = re.compile(r"^-[a-zA-Z0-9]|--[a-z][-a-z0-9]+$")
46

  
42 47

  
43 48
def WritePreamble(sw):
44 49
  """Writes the script preamble.
......
244 249
      # pylint. pylint: disable-msg=W0212
245 250
      opt.all_names = sorted(opt._short_opts + opt._long_opts)
246 251

  
252
      invalid = list(itertools.ifilterfalse(_OPT_NAME_RE.match, opt.all_names))
253
      if invalid:
254
        raise Exception("Option names don't match regular expression '%s': %s" %
255
                        (_OPT_NAME_RE.pattern, utils.CommaJoin(invalid)))
256

  
247 257
  def _FindFirstArgument(self, sw):
248 258
    ignore = []
249 259
    skip_one = []

Also available in: Unified diff