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()
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
def tag_message(tag, message): message = white(encode(condense(message), encoding=ENCODING)) return bold(' '.join([tag, message]))
def _set_directories(self, directories): for wt, dirs in directories.iteritems(): self.set('directories', wt, [pathutils.condense(d) for d in dirs])
def add_directory(self, directory): self.treeview.get_model().append([condense(directory)])