# HG changeset patch # User Mads Kiilerich # Date 1505347686 -7200 # Node ID d06039dc4ca2cbdfe0dbcf8c60b6ab3d1cb31cd8 # Parent f9b5deab451edb53d8efcd13b94ebbf61d3dbdfc ini: drop insertion of header comments in generated ini files The header comments were kind of redundant and could easily get out of sync. Also, we are moving towards just generating files and don't need this and don't want to maintain it. diff -r f9b5deab451e -r d06039dc4ca2 development.ini --- a/development.ini Thu Sep 14 02:08:06 2017 +0200 +++ b/development.ini Thu Sep 14 02:08:06 2017 +0200 @@ -1,11 +1,6 @@ ################################################################################ ################################################################################ -# Kallithea - Development config: # -# listening on *:5000 # -# sqlite and kallithea.db # -# initial_repo_scan = true # -# debug = true # -# verbose and colorful logging # +# Kallithea - config file generated with kallithea-config # # # # The %(here)s variable will be replaced with the parent directory of this file# ################################################################################ diff -r f9b5deab451e -r d06039dc4ca2 kallithea/lib/inifile.py --- a/kallithea/lib/inifile.py Thu Sep 14 02:08:06 2017 +0200 +++ b/kallithea/lib/inifile.py Thu Sep 14 02:08:06 2017 +0200 @@ -29,7 +29,7 @@ log = logging.getLogger(__name__) -def expand(template, desc, mako_variable_values, settings): +def expand(template, mako_variable_values, settings): """Expand mako template and tweak it. Not entirely stable for random templates as input, but good enough for our single template. @@ -45,12 +45,11 @@ ... # ${mako_function()} ... [second-section] ... %if conditional_options == 'option-a': - ... # Kallithea - config file generated with kallithea-config # + ... # option a was chosen ... %elif conditional_options == 'option-b': ... some_variable = "never mind - option-b will not be used anyway ..." ... %endif ... ''' - >>> desc = 'Description\\nof this config file' >>> selected_mako_conditionals = [] >>> mako_variable_values = {'mako_variable': 'VALUE', 'mako_function': (lambda: 'FUNCTION RESULT'), ... 'conditional_options': 'option-a'} @@ -59,7 +58,7 @@ ... '[third-section]': {'third_extra': ' 3'}, ... '[fourth-section]': {'fourth_extra': '4', 'fourth': '"four"'}, ... } - >>> print expand(template, desc, mako_variable_values, settings) + >>> print expand(template, mako_variable_values, settings) [first-section] @@ -72,8 +71,7 @@ # FUNCTION RESULT [second-section] - # Description # - # of this config file # + # option a was chosen [fourth-section] fourth = "four" @@ -87,11 +85,6 @@ ini_lines = mako.template.Template(template).render(**mako_variable_values) - ini_lines = re.sub( - '# Kallithea - config file generated with kallithea-config *#\n', - ''.join('# %-77s#\n' % l.strip() for l in desc.strip().split('\n')), - ini_lines) - def process_section(m): """process a ini section, replacing values as necessary""" sectionname, lines = m.groups() diff -r f9b5deab451e -r d06039dc4ca2 kallithea/tests/test.ini --- a/kallithea/tests/test.ini Thu Sep 14 02:08:06 2017 +0200 +++ b/kallithea/tests/test.ini Thu Sep 14 02:08:06 2017 +0200 @@ -1,8 +1,6 @@ ################################################################################ ################################################################################ -# Kallithea - config for tests: # -# sqlalchemy and kallithea_test.sqlite # -# custom logging # +# Kallithea - config file generated with kallithea-config # # # # The %(here)s variable will be replaced with the parent directory of this file# ################################################################################ diff -r f9b5deab451e -r d06039dc4ca2 scripts/generate-ini.py --- a/scripts/generate-ini.py Thu Sep 14 02:08:06 2017 +0200 +++ b/scripts/generate-ini.py Thu Sep 14 02:08:06 2017 +0200 @@ -23,11 +23,6 @@ # files to be generated from the mako template ini_files = [ ('kallithea/tests/test.ini', - ''' - Kallithea - config for tests: - sqlalchemy and kallithea_test.sqlite - custom logging - ''', { '[server:main]': { 'port': '4999', @@ -51,14 +46,6 @@ }, ), ('development.ini', - ''' - Kallithea - Development config: - listening on *:5000 - sqlite and kallithea.db - initial_repo_scan = true - debug = true - verbose and colorful logging - ''', { '[server:main]': { 'host': '0.0.0.0', @@ -91,9 +78,9 @@ open(makofile, 'w').write(mako_marked_up) # create ini files - for fn, desc, settings in ini_files: + for fn, settings in ini_files: print 'updating:', fn - ini_lines = inifile.expand(mako_marked_up, desc, mako_variable_values, settings) + ini_lines = inifile.expand(mako_marked_up, mako_variable_values, settings) open(fn, 'w').write(ini_lines) if __name__ == '__main__':