X-Git-Url: https://git.distorted.org.uk/~mdw/distorted-keys/blobdiff_plain/b5991f0555161e7baf665822dac54d493209dae2..0bc47568f2c94d6e48bc389ac508d5f905daa9c7:/extract-profile.in diff --git a/extract-profile.in b/extract-profile.in index 918da8c..0de7af0 100755 --- a/extract-profile.in +++ b/extract-profile.in @@ -277,7 +277,9 @@ class Section (object, UD.DictMixin): ## Otherwise take as many constituent characters as we can. else: left = dol + 1 - while left < n and (string[left].isalnum() or string[left] in '-_'): + if left < n and string[left] == '@': + left += 1 + while left < n and (string[left].isalnum() or string[left] in '%-_'): left += 1 prop = string[dol + 1:left] @@ -296,10 +298,13 @@ class Section (object, UD.DictMixin): (' -> '.join(["`%s'" % p for p in path[seen[prop]:]])) ## Look up the raw value. - try: - value = me.inherited[prop] - except KeyError: - raise UserError, "unknown property `%s'" % prop + if prop == '@name': + value = me.name + else: + try: + value = me.inherited[prop] + except KeyError: + raise UserError, "unknown property `%s'" % prop ## Recursively expand, and unwind the PATH and SEEN stuff. seen[prop] = len(path) - 1 @@ -391,7 +396,7 @@ def parse(filename, d): name = name.replace('-', '_') if not (name and (name in SPECIALS or - all(map(lambda ch: ch == '_' or ch.isalnum(), name)))): + all(map(lambda ch: ch in '%_' or ch.isalnum(), name)))): raise UserError, "%s:%d: bad name `%s'" % (filename, n, name) ## Store the assignment. @@ -402,7 +407,7 @@ def parse(filename, d): OP = O.OptionParser( usage = '%prog SECTION FILE|DIRECTORY ...', - version = '%%prog, version %s' % VERSION, + version = '%%prog, %s version %s' % (PACKAGE, VERSION), description = '''\ Parse the configurations FILE and DIRECTORY contents, and output the named SECTION as a sequence of simple assignments. @@ -443,6 +448,7 @@ def main(args): except KeyError: raise UserError, "unknown section `%s'" % sect for k, v in s.inherited.iteritems(): + if '%' in k: continue print '%s=%s' % (k, s.expand(v)) ## Report errors for expected problems.