Ejemplo n.º 1
0
def multi_input(prompt=''):
    """
    Get input from user
    Allow multiple lines using a continuation character
    """
    global _LINE_BUFFER
    line = []
    _LINE_BUFFER = ''
    while True:
        try:
            text = raw_input(prompt)
        except EOFError:
            return None
        err_buf.incr_lineno()
        if options.regression_tests:
            print ".INP:", text
            sys.stdout.flush()
            sys.stderr.flush()
        stripped = text.strip()
        if stripped.endswith('\\'):
            stripped = stripped.rstrip('\\')
            line.append(stripped)
            _LINE_BUFFER += stripped
            if prompt:
                prompt = '   > '
        else:
            line.append(stripped)
            break
    return ''.join(line)
Ejemplo n.º 2
0
Archivo: utils.py Proyecto: lge/crmsh
def multi_input(prompt=''):
    """
    Get input from user
    Allow multiple lines using a continuation character
    """
    global _LINE_BUFFER
    line = []
    _LINE_BUFFER = ''
    while True:
        try:
            text = raw_input(prompt)
        except EOFError:
            return None
        err_buf.incr_lineno()
        if options.regression_tests:
            print ".INP:", text
            sys.stdout.flush()
            sys.stderr.flush()
        stripped = text.strip()
        if stripped.endswith('\\'):
            stripped = stripped.rstrip('\\')
            line.append(stripped)
            _LINE_BUFFER += stripped
            if prompt:
                prompt = '   > '
        else:
            line.append(stripped)
            break
    return ''.join(line)
Ejemplo n.º 3
0
 except IOError, msg:
     common_err("open: %s" % msg)
     return ''
 l = []
 piece = []
 user_data = {}
 # states
 START = 0
 PFX = 1
 DATA = 2
 GENERATE = 3
 state = START
 err_buf.start_tmp_lineno()
 rc = True
 for inp in f:
     err_buf.incr_lineno()
     if inp.startswith('#'):
         continue
     if type(inp) == type(u''):
         inp = inp.encode('ascii')
     inp = inp.strip()
     try:
         s = shlex.split(inp)
     except ValueError, msg:
         common_err(msg)
         continue
     while '\n' in s:
         s.remove('\n')
     if not s:
         if state == GENERATE and piece:
             l.append(piece)
Ejemplo n.º 4
0
 except IOError, msg:
     common_err("open: %s" % msg)
     return ''
 l = []
 piece = []
 user_data = {}
 # states
 START = 0
 PFX = 1
 DATA = 2
 GENERATE = 3
 state = START
 err_buf.start_tmp_lineno()
 rc = True
 for inp in f:
     err_buf.incr_lineno()
     if inp.startswith('#'):
         continue
     if type(inp) == type(u''):
         inp = inp.encode('ascii')
     inp = inp.strip()
     try:
         s = shlex.split(inp)
     except ValueError, msg:
         common_err(msg)
         continue
     while '\n' in s:
         s.remove('\n')
     if not s:
         if state == GENERATE and piece:
             l.append(piece)