Changeset - 04908b44005c
[Not reviewed]
stable
0 3 0
Mads Kiilerich - 5 years ago 2020-05-22 16:54:10
mads@kiilerich.com
ini: put kallithea-config version in the ini file it creates (Issue #373)

Help keeping track of how the .ini was created.
3 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_config.py
Show inline comments
 
@@ -53,24 +53,25 @@ def config_create(config_file, key_value
 
    settings you specify.
 

	
 
    The primary high level configuration keys and their default values are
 
    shown with --show-defaults . Custom values for these keys can be specified
 
    on the command line as key=value arguments.
 

	
 
    Additional key=value arguments will be patched/inserted in the [app:main]
 
    section ... until another section name specifies where any following values
 
    should go.
 
    """
 

	
 
    mako_variable_values = {
 
        'version': kallithea.__version__,
 
        'git_hook_interpreter': sys.executable,
 
        'user_home_path': os.path.expanduser('~'),
 
        'kallithea_cli_path': cli_base.kallithea_cli_path,
 
        'ssh_locale': kallithea.lib.locale.get_current_locale(),
 
    }
 
    ini_settings = defaultdict(dict)
 

	
 
    section_name = None
 
    for parameter in key_value_pairs:
 
        parts = parameter.split('=', 1)
 
        if len(parts) == 1 and parameter.startswith('[') and parameter.endswith(']'):
 
            section_name = parameter
kallithea/lib/inifile.py
Show inline comments
 
@@ -31,24 +31,25 @@ log = logging.getLogger(__name__)
 

	
 

	
 
template_file = os.path.join(
 
    os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
 
    'kallithea/lib/paster_commands/template.ini.mako')
 

	
 
default_variables = {
 
    'database_engine': 'sqlite',
 
    'http_server': 'waitress',
 
    'host': '127.0.0.1',
 
    'port': '5000',
 
    'uuid': lambda: 'VERY-SECRET',
 
    'version': '',
 
}
 

	
 
variable_options = {
 
    'database_engine': ['sqlite', 'postgres', 'mysql'],
 
    'http_server': ['waitress', 'gearbox', 'gevent', 'gunicorn', 'uwsgi'],
 
}
 

	
 
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.
 

	
kallithea/lib/paster_commands/template.ini.mako
Show inline comments
 
## -*- coding: utf-8 -*-
 
<%text>##</%text>#################################################################################
 
<%text>##</%text>#################################################################################
 
<%text>##</%text> Kallithea config file generated with kallithea-config                         ##
 
<%text>##</%text> Kallithea config file generated with kallithea-config ${'%-24s' % version    }##
 
<%text>##</%text>                                                                               ##
 
<%text>##</%text> The %(here)s variable will be replaced with the parent directory of this file ##
 
<%text>##</%text>#################################################################################
 
<%text>##</%text>#################################################################################
 

	
 
[DEFAULT]
 

	
 
<%text>##</%text>##############################################################################
 
<%text>##</%text> Email settings                                                             ##
 
<%text>##</%text>                                                                            ##
 
<%text>##</%text> Refer to the documentation ("Email settings") for more details.            ##
 
<%text>##</%text>                                                                            ##
0 comments (0 inline, 0 general)