##// END OF EJS Templates
ini: drop insertion of header comments in generated ini files...
Mads Kiilerich -
r6818:d06039dc default
parent child Browse files
Show More
@@ -1,11 +1,6 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # Kallithea - Development config: #
3 # Kallithea - config file generated with kallithea-config #
4 # listening on *:5000 #
5 # sqlite and kallithea.db #
6 # initial_repo_scan = true #
7 # debug = true #
8 # verbose and colorful logging #
9 # #
4 # #
10 # The %(here)s variable will be replaced with the parent directory of this file#
5 # The %(here)s variable will be replaced with the parent directory of this file#
11 ################################################################################
6 ################################################################################
@@ -29,7 +29,7 b' import mako.template'
29 log = logging.getLogger(__name__)
29 log = logging.getLogger(__name__)
30
30
31
31
32 def expand(template, desc, mako_variable_values, settings):
32 def expand(template, mako_variable_values, settings):
33 """Expand mako template and tweak it.
33 """Expand mako template and tweak it.
34 Not entirely stable for random templates as input, but good enough for our
34 Not entirely stable for random templates as input, but good enough for our
35 single template.
35 single template.
@@ -45,12 +45,11 b' def expand(template, desc, mako_variable'
45 ... # ${mako_function()}
45 ... # ${mako_function()}
46 ... [second-section]
46 ... [second-section]
47 ... %if conditional_options == 'option-a':
47 ... %if conditional_options == 'option-a':
48 ... # Kallithea - config file generated with kallithea-config #
48 ... # option a was chosen
49 ... %elif conditional_options == 'option-b':
49 ... %elif conditional_options == 'option-b':
50 ... some_variable = "never mind - option-b will not be used anyway ..."
50 ... some_variable = "never mind - option-b will not be used anyway ..."
51 ... %endif
51 ... %endif
52 ... '''
52 ... '''
53 >>> desc = 'Description\\nof this config file'
54 >>> selected_mako_conditionals = []
53 >>> selected_mako_conditionals = []
55 >>> mako_variable_values = {'mako_variable': 'VALUE', 'mako_function': (lambda: 'FUNCTION RESULT'),
54 >>> mako_variable_values = {'mako_variable': 'VALUE', 'mako_function': (lambda: 'FUNCTION RESULT'),
56 ... 'conditional_options': 'option-a'}
55 ... 'conditional_options': 'option-a'}
@@ -59,7 +58,7 b' def expand(template, desc, mako_variable'
59 ... '[third-section]': {'third_extra': ' 3'},
58 ... '[third-section]': {'third_extra': ' 3'},
60 ... '[fourth-section]': {'fourth_extra': '4', 'fourth': '"four"'},
59 ... '[fourth-section]': {'fourth_extra': '4', 'fourth': '"four"'},
61 ... }
60 ... }
62 >>> print expand(template, desc, mako_variable_values, settings)
61 >>> print expand(template, mako_variable_values, settings)
63 <BLANKLINE>
62 <BLANKLINE>
64 [first-section]
63 [first-section]
65 <BLANKLINE>
64 <BLANKLINE>
@@ -72,8 +71,7 b' def expand(template, desc, mako_variable'
72 <BLANKLINE>
71 <BLANKLINE>
73 # FUNCTION RESULT
72 # FUNCTION RESULT
74 [second-section]
73 [second-section]
75 # Description #
74 # option a was chosen
76 # of this config file #
77 <BLANKLINE>
75 <BLANKLINE>
78 [fourth-section]
76 [fourth-section]
79 fourth = "four"
77 fourth = "four"
@@ -87,11 +85,6 b' def expand(template, desc, mako_variable'
87
85
88 ini_lines = mako.template.Template(template).render(**mako_variable_values)
86 ini_lines = mako.template.Template(template).render(**mako_variable_values)
89
87
90 ini_lines = re.sub(
91 '# Kallithea - config file generated with kallithea-config *#\n',
92 ''.join('# %-77s#\n' % l.strip() for l in desc.strip().split('\n')),
93 ini_lines)
94
95 def process_section(m):
88 def process_section(m):
96 """process a ini section, replacing values as necessary"""
89 """process a ini section, replacing values as necessary"""
97 sectionname, lines = m.groups()
90 sectionname, lines = m.groups()
@@ -1,8 +1,6 b''
1 ################################################################################
1 ################################################################################
2 ################################################################################
2 ################################################################################
3 # Kallithea - config for tests: #
3 # Kallithea - config file generated with kallithea-config #
4 # sqlalchemy and kallithea_test.sqlite #
5 # custom logging #
6 # #
4 # #
7 # The %(here)s variable will be replaced with the parent directory of this file#
5 # The %(here)s variable will be replaced with the parent directory of this file#
8 ################################################################################
6 ################################################################################
@@ -23,11 +23,6 b' mako_variable_values = {'
23 # files to be generated from the mako template
23 # files to be generated from the mako template
24 ini_files = [
24 ini_files = [
25 ('kallithea/tests/test.ini',
25 ('kallithea/tests/test.ini',
26 '''
27 Kallithea - config for tests:
28 sqlalchemy and kallithea_test.sqlite
29 custom logging
30 ''',
31 {
26 {
32 '[server:main]': {
27 '[server:main]': {
33 'port': '4999',
28 'port': '4999',
@@ -51,14 +46,6 b' ini_files = ['
51 },
46 },
52 ),
47 ),
53 ('development.ini',
48 ('development.ini',
54 '''
55 Kallithea - Development config:
56 listening on *:5000
57 sqlite and kallithea.db
58 initial_repo_scan = true
59 debug = true
60 verbose and colorful logging
61 ''',
62 {
49 {
63 '[server:main]': {
50 '[server:main]': {
64 'host': '0.0.0.0',
51 'host': '0.0.0.0',
@@ -91,9 +78,9 b' def main():'
91 open(makofile, 'w').write(mako_marked_up)
78 open(makofile, 'w').write(mako_marked_up)
92
79
93 # create ini files
80 # create ini files
94 for fn, desc, settings in ini_files:
81 for fn, settings in ini_files:
95 print 'updating:', fn
82 print 'updating:', fn
96 ini_lines = inifile.expand(mako_marked_up, desc, mako_variable_values, settings)
83 ini_lines = inifile.expand(mako_marked_up, mako_variable_values, settings)
97 open(fn, 'w').write(ini_lines)
84 open(fn, 'w').write(ini_lines)
98
85
99 if __name__ == '__main__':
86 if __name__ == '__main__':
General Comments 0
You need to be logged in to leave comments. Login now