# HG changeset patch # User Thomas De Schampheleire # Date 1542567737 -3600 # Node ID f9c8fec481855167b34c68ef55b72050f34e7d2f # Parent 3158cf0dafb75cdf131f8196f0d5ed9495425549 cli: convert 'gearbox make-rcext' in 'kallithea-cli extensions-create' Note: 'extensions' instead of 'rcextensions' as first step to get away from the 'rc' prefix. diff -r 3158cf0dafb7 -r f9c8fec48185 docs/usage/customization.rst --- a/docs/usage/customization.rst Sun Nov 18 20:02:17 2018 +0100 +++ b/docs/usage/customization.rst Sun Nov 18 20:02:17 2018 +0100 @@ -55,7 +55,7 @@ To generate a skeleton extensions package, run:: - gearbox make-rcext -c my.ini + kallithea-cli extensions-create -c my.ini This will create an ``rcextensions`` package next to the specified ``ini`` file. See the ``__init__.py`` file inside the generated ``rcextensions`` package diff -r 3158cf0dafb7 -r f9c8fec48185 kallithea/bin/kallithea_cli.py --- a/kallithea/bin/kallithea_cli.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/bin/kallithea_cli.py Sun Nov 18 20:02:17 2018 +0100 @@ -18,6 +18,7 @@ # import commands (they will add themselves to the 'cli' object) import kallithea.bin.kallithea_cli_config import kallithea.bin.kallithea_cli_db +import kallithea.bin.kallithea_cli_extensions import kallithea.bin.kallithea_cli_iis import kallithea.bin.kallithea_cli_ishell import kallithea.bin.kallithea_cli_repo diff -r 3158cf0dafb7 -r f9c8fec48185 kallithea/bin/kallithea_cli_extensions.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kallithea/bin/kallithea_cli_extensions.py Sun Nov 18 20:02:17 2018 +0100 @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +""" +This file was forked by the Kallithea project in July 2014 and later moved. +Original author and date, and relevant copyright and licensing information is below: +:created_on: Mar 6, 2012 +:author: marcink +:copyright: (c) 2013 RhodeCode GmbH, and others. +:license: GPLv3, see LICENSE.md for more details. +""" +import click +import kallithea.bin.kallithea_cli_base as cli_base + +import os +import pkg_resources + +import kallithea +from kallithea.lib.paster_commands.common import ask_ok + +@cli_base.register_command(config_file=True) +def extensions_create(): + """Write template file for extending Kallithea in Python. + + An rcextensions directory with a __init__.py file will be created next to + the ini file. Local customizations in that file will survive upgrades. + The file contains instructions on how it can be customized. + """ + here = kallithea.CONFIG['here'] + content = pkg_resources.resource_string( + 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') + ) + ext_file = os.path.join(here, 'rcextensions', '__init__.py') + if os.path.exists(ext_file): + msg = ('Extension file %s already exists, do you want ' + 'to overwrite it ? [y/n] ') % ext_file + if not ask_ok(msg): + click.echo('Nothing done, exiting...') + return + + dirname = os.path.dirname(ext_file) + if not os.path.isdir(dirname): + os.makedirs(dirname) + with open(ext_file, 'wb') as f: + f.write(content) + click.echo('Wrote new extensions file to %s' % ext_file) diff -r 3158cf0dafb7 -r f9c8fec48185 kallithea/lib/paster_commands/make_rcextensions.py --- a/kallithea/lib/paster_commands/make_rcextensions.py Sun Nov 18 20:02:17 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -kallithea.lib.paster_commands.make_rcextensions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -make-rcext gearbox command for Kallithea - -This file was forked by the Kallithea project in July 2014. -Original author and date, and relevant copyright and licensing information is below: -:created_on: Mar 6, 2012 -:author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. -:license: GPLv3, see LICENSE.md for more details. -""" - - -import os -import pkg_resources - -from kallithea.lib.paster_commands.common import ask_ok, BasePasterCommand - - -class Command(BasePasterCommand): - """Kallithea: Write template file for extending Kallithea in Python - - A rcextensions directory with a __init__.py file will be created next to - the ini file. Local customizations in that file will survive upgrades. - The file contains instructions on how it can be customized. - """ - - requires_db_session = False - - def take_action(self, args): - here = self.config['here'] - content = pkg_resources.resource_string( - 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') - ) - ext_file = os.path.join(here, 'rcextensions', '__init__.py') - if os.path.exists(ext_file): - msg = ('Extension file %s already exists, do you want ' - 'to overwrite it ? [y/n]') % ext_file - if not ask_ok(msg): - print 'Nothing done, exiting...' - return - - dirname = os.path.dirname(ext_file) - if not os.path.isdir(dirname): - os.makedirs(dirname) - with open(ext_file, 'wb') as f: - f.write(content) - print 'Wrote new extensions file to %s' % ext_file diff -r 3158cf0dafb7 -r f9c8fec48185 setup.py --- a/setup.py Sun Nov 18 20:02:17 2018 +0100 +++ b/setup.py Sun Nov 18 20:02:17 2018 +0100 @@ -161,7 +161,6 @@ [gearbox.commands] celeryd=kallithea.lib.paster_commands.celeryd:Command make-index=kallithea.lib.paster_commands.make_index:Command - make-rcext=kallithea.lib.paster_commands.make_rcextensions:Command upgrade-db=kallithea.lib.dbmigrate:UpgradeDb """, )