Exemplo n.º 1
0
def input(prompt='Enter value', secret=False, default=None, check=False, error=None, warn=None):  # {{{1
    if secret:
        default = None
    if check and not INTERACTIVE:
        return default or u''
    prompt = condense(prompt)
    default = decode(default, encoding=ENCODING)
    getter = getpass if secret else raw_input
    if default:
        prompt += " [%s]" % default
    if warn:
        prompt += " (%s)" % warn_message(message=warn)
    if error:
        prompt += " (%s)" % error_message(message=error)
    try:
        if prompt:
            reply = getter(prompt.strip() + ': ')
        else:
            reply = getter()
    except:
        reply = ''
    reply = decode(reply, encoding=ENCODING)
    if not len(reply):
        reply = default
    return reply.strip()
Exemplo n.º 2
0
def input_lines(prompt='Enter values', check=False):  # {{{1
    if check and not INTERACTIVE:
        return None
    lines = []
    print '%s (one per line):' % condense(prompt)
    while True:
        try:
            lines.append(input(prompt=''))
        except EOFError:
            return lines
        except KeyboardInterrupt:
            return None
Exemplo n.º 3
0
def tag_message(tag, message):
    message = white(encode(condense(message), encoding=ENCODING))
    return bold(' '.join([tag, message]))
Exemplo n.º 4
0
 def _set_directories(self, directories):
     for wt, dirs in directories.iteritems():
         self.set('directories', wt, [pathutils.condense(d) for d in dirs])
Exemplo n.º 5
0
 def add_directory(self, directory):
     self.treeview.get_model().append([condense(directory)])