Changeset - 0f9e7dbfa5d2
[Not reviewed]
default
0 5 0
Mads Kiilerich - 7 years ago 2018-11-18 19:57:40
mads@kiilerich.com
utils2: Move ask_ok out of paster_commands

The ask_ok function is still a mess and should be cleaned up ...
5 files changed with 16 insertions and 17 deletions:
0 comments (0 inline, 0 general)
kallithea/bin/kallithea_cli_extensions.py
Show inline comments
 
@@ -26,7 +26,7 @@ import os
 
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():
kallithea/bin/kallithea_cli_repo.py
Show inline comments
 
@@ -27,9 +27,8 @@ import os
 
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
kallithea/lib/db_manage.py
Show inline comments
 
@@ -77,7 +77,7 @@ class DbManage(object):
 
        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):
kallithea/lib/paster_commands/common.py
Show inline comments
 
@@ -38,19 +38,6 @@ import kallithea.lib.utils2
 
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.
kallithea/lib/utils2.py
Show inline comments
 
@@ -681,3 +681,16 @@ def repo_name_slug(value):
 
    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
0 comments (0 inline, 0 general)