Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)

        def yn(prompt, default='y', batch=False):
    # A sanity check against default value
    # If not y/n then y is assumed
    if default not in ['y', 'n']:
        default = 'y'

    # Let's build the prompt
    choicebox = '[Y/n]' if default == 'y' else '[y/N]'
    prompt = prompt + ' ' + choicebox + ' '

    # If input is not a yes/no variant or empty
    # keep asking
    while True:
        # If batch option is True then auto reply
        # with default input
        if not batch:
            input = raw_input(prompt).strip()
        else:
            print prompt
            input = ''

        # If input is empty default choice is assumed
        # so we return True
        if input == '':
            return True

        # Given 'yes' as input if default choice is y
        # then return True, False otherwise
        if match('y(?:es)?', input, I):
            return True if default == 'y' else False

        # Given 'no' as input if default choice is n
        # then return True, False otherwise
        elif match('n(?:o)?', input, I):
            return True if default == 'n' else False
        


src/s/y/SyncHg-1.0.0/synchg/sync.py   SyncHg(Download)
from remote import RemoteMachine
from repo import Repo
from utils import yn
 
 
    if not rpath.exists():
        print "Remote repository can't be found."
        if yn('Do you want to create a clone?'):
            local_repo.Clone(hg_remote_path)
        else:
            # We can't push/pop patches to check remote is
            # in sync if we've got local changes, so prompt to refresh.
            if yn('Do you want to refresh the current patch?'):
                local.RefreshMq()
            else:
            # these changes, but probably want to make sure that's
            # what the user wants...
            if not yn('Do you want to ignore these changes?'):
                print "Ok.  Please run again after dealing with changes."
                raise AbortException
                        desc = desc[:47] + '...'
                    print "  {0}  {1}".format(hash[:6], desc)
                if not yn('Do you want to continue?'):
                    raise AbortException()
                remote.Strip(incomings)