comparison scripts/generate-ini.py @ 8368:e5ccabbc3cd7 stable

release: merge default to stable for 0.6.0
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Sat, 02 May 2020 21:20:43 +0200
parents ef9fd1434270
children 6eb1f66ac23f
comparison
equal deleted inserted replaced
8320:b1b1f69b1f28 8368:e5ccabbc3cd7
1 #!/usr/bin/env python2 1 #!/usr/bin/env python3
2 """ 2 """
3 Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini 3 Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini
4 """ 4 """
5
6 from __future__ import print_function
7 5
8 import re 6 import re
9 7
10 from kallithea.lib import inifile 8 from kallithea.lib import inifile
11 9
60 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE) 58 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE)
61 if mako_marked_up != mako_org: 59 if mako_marked_up != mako_org:
62 print('writing:', makofile) 60 print('writing:', makofile)
63 open(makofile, 'w').write(mako_marked_up) 61 open(makofile, 'w').write(mako_marked_up)
64 62
63 lines = re.findall(r'\n(# [^ ].*)', mako_marked_up)
64 if lines:
65 print('ERROR: the template .ini file convention is to use "## Foo Bar" for text comments and "#foo = bar" for disabled settings')
66 for line in lines:
67 print(line)
68 raise SystemExit(1)
69
65 # create ini files 70 # create ini files
66 for fn, settings in ini_files: 71 for fn, settings in ini_files:
67 print('updating:', fn) 72 print('updating:', fn)
68 inifile.create(fn, None, settings) 73 inifile.create(fn, None, settings)
69 74