Mercurial > kallithea
changeset 7418:0f9e7dbfa5d2
utils2: Move ask_ok out of paster_commands
The ask_ok function is still a mess and should be cleaned up ...
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sun, 18 Nov 2018 19:57:40 +0100 |
parents | 1d539bb18165 |
children | a6b24ff6d65c |
files | kallithea/bin/kallithea_cli_extensions.py kallithea/bin/kallithea_cli_repo.py kallithea/lib/db_manage.py kallithea/lib/paster_commands/common.py kallithea/lib/utils2.py |
diffstat | 5 files changed, 16 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/bin/kallithea_cli_extensions.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/bin/kallithea_cli_extensions.py Sun Nov 18 19:57:40 2018 +0100 @@ -26,7 +26,7 @@ import pkg_resources import kallithea -from kallithea.lib.paster_commands.common import ask_ok +from kallithea.lib.utils2 import ask_ok @cli_base.register_command(config_file=True) def extensions_create():
--- a/kallithea/bin/kallithea_cli_repo.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/bin/kallithea_cli_repo.py Sun Nov 18 19:57:40 2018 +0100 @@ -27,9 +27,8 @@ import re import shutil -from kallithea.lib.paster_commands.common import ask_ok from kallithea.lib.utils import repo2db_mapper, REMOVED_REPO_PAT -from kallithea.lib.utils2 import safe_unicode, safe_str +from kallithea.lib.utils2 import safe_unicode, safe_str, ask_ok from kallithea.model.db import Repository, Ui from kallithea.model.meta import Session from kallithea.model.scm import ScmModel
--- a/kallithea/lib/db_manage.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/lib/db_manage.py Sun Nov 18 19:57:40 2018 +0100 @@ -77,7 +77,7 @@ force_ask = self.cli_args.get('force_ask') if force_ask is not None: return force_ask - from kallithea.lib.paster_commands.common import ask_ok + from kallithea.lib.utils2 import ask_ok return ask_ok(msg) def init_db(self, SESSION=None):
--- a/kallithea/lib/paster_commands/common.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/lib/paster_commands/common.py Sun Nov 18 19:57:40 2018 +0100 @@ -38,19 +38,6 @@ import kallithea.lib.utils -def ask_ok(prompt, retries=4, complaint='Yes or no please!'): - while True: - ok = raw_input(prompt) - if ok in ('y', 'ye', 'yes'): - return True - if ok in ('n', 'no', 'nop', 'nope'): - return False - retries = retries - 1 - if retries < 0: - raise IOError - print complaint - - class BasePasterCommand(gearbox.command.Command): """ Abstract Base Class for gearbox commands.
--- a/kallithea/lib/utils2.py Sun Nov 18 20:02:17 2018 +0100 +++ b/kallithea/lib/utils2.py Sun Nov 18 19:57:40 2018 +0100 @@ -681,3 +681,16 @@ slug = recursive_replace(slug, '-') slug = collapse(slug, '-') return slug + + +def ask_ok(prompt, retries=4, complaint='Yes or no please!'): + while True: + ok = raw_input(prompt) + if ok in ('y', 'ye', 'yes'): + return True + if ok in ('n', 'no', 'nop', 'nope'): + return False + retries = retries - 1 + if retries < 0: + raise IOError + print complaint