diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2013-03-26 12:48:05 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2013-03-26 12:48:05 +1100 |
commit | 06c7012160d9d450dc2351a573494b9a63ce6420 (patch) | |
tree | 694fc2cf69d181d7c5facdbbb22164b2d3a53cc9 /dist/api_config.py | |
parent | 9698d23d93137f841cd6f8211a345a0d4f9ac78f (diff) | |
download | mongo-06c7012160d9d450dc2351a573494b9a63ce6420.tar.gz |
Cleanup wiredtiger.in: adjust whitespace to make it more human readable.
Diffstat (limited to 'dist/api_config.py')
-rw-r--r-- | dist/api_config.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/dist/api_config.py b/dist/api_config.py index ce36b082964..5e87455a890 100644 --- a/dist/api_config.py +++ b/dist/api_config.py @@ -13,6 +13,7 @@ tmp_file = '__tmp' f='../src/include/wiredtiger.in' tfile = open(tmp_file, 'w') +whitespace_re = re.compile(r'\s+') cbegin_re = re.compile(r'(\s*\*\s*)@config(?:empty|start)\{(.*?),.*\}') def gettype(c): @@ -55,7 +56,7 @@ def typedesc(c): def parseconfig(c, name_indent=''): ctype = gettype(c) - desc = textwrap.dedent(c.desc) + '.' + desc = whitespace_re.sub(' ', c.desc.strip()) + '.' desc = desc.replace(',', '\\,') default = '\\c ' + str(c.default) if c.default or ctype == 'int' \ else 'empty' @@ -68,11 +69,11 @@ def parseconfig(c, name_indent=''): name += ' = (' tdesc += '.' tdesc = tdesc.replace(',', '\\,') - output = '@config{' + ','.join((name, desc, tdesc)) + '}' + output = '@config{' + ', '.join((name, desc, tdesc)) + '}\n' if ctype == 'category': for subc in c.subconfig: output += parseconfig(subc, name_indent + (' ' * 4)) - output += '@config{ ),,}' + output += '@config{ ),,}\n' return output def getconfcheck(c): @@ -120,7 +121,9 @@ for line in open(f, 'r'): ', see dist/api_data.py}\n') w = textwrap.TextWrapper(width=80-len(prefix.expandtabs()), - break_on_hyphens=False) + break_on_hyphens=False, + replace_whitespace=False, + fix_sentence_endings=True) lastname = None for c in sorted(api_data.methods[config_name].config): name = c.name @@ -137,7 +140,7 @@ for line in open(f, 'r'): continue output = parseconfig(c) for l in w.wrap(output): - tfile.write(prefix + l + '\n') + tfile.write(prefix + l.replace('\n', '\n' + prefix) + '\n') tfile.write(prefix + '@configend\n') @@ -166,15 +169,11 @@ def checkstr(c): cmin = str(checks.get('min', '')) cmax = str(checks.get('max', '')) choices = checks.get('choices', []) - subconfig = checks.get('subconfig', []) result = [] if cmin: result.append('min=' + cmin) if cmax: result.append('max=' + cmax) - if subconfig: - result.append('subconfig=' + '[' + - ','.join('\\"' + parseconfig(c) + '\\"' for c in subconfig) + ']') if choices: result.append('choices=' + '[' + ','.join('\\"' + s + '\\"' for s in choices) + ']') |