Example #1
0
File: tools.py Project: tek/pytek
 def _print_progress(self):
     if os.path.isfile(self._destination):
         self._file_size = os.path.getsize(self._destination)
         text = "{:.2%} ({}k)".format(self._percent, self._progress)
         terminal.pop()
         terminal.push(text)
         terminal.flush()
Example #2
0
 def _read(self, prompt):
     terminal.push(prompt)
     terminal.write(' ')
     input = terminal.input(single=self._single,
                            initial=self._initial_input)
     valid = self._do_input(input)
     if not valid:
         terminal.pop()
     return valid
Example #3
0
 def read(self):
     self._remove_text |= self._overwrite
     while True:
         value = super(LoopingInput, self).read()
         if value == self._terminate:
                 break
         elif isinstance(value, str) and value in self._dispatch:
             self._dispatch[value]()
         self.process()
         if self._force_terminate:
             break
     if self._overwrite and not input_queue.suppress_output:
         terminal.push(self.prompt)
         terminal.push()
     if self._raise_quit:
         raise UserInputTerminated()
     else:
         return self.loop_value
Example #4
0
 def read(self):
     prompt = self.prompt
     if input_queue:
         self._synth_input()
     else:
         clear_count = max(len(prompt) - len(self.fail_prompt), 0)
         lower = prompt[clear_count:]
         upper = prompt[:clear_count]
         if not terminal.locked:
             terminal.lock()
         if self._remove_text:
             terminal.push_lock()
         terminal.push(upper)
         while not self._read(lower):
             lower = self.fail_prompt
         if self._remove_text:
             terminal.pop_lock()
         if self._newline:
             terminal.push()
     return self.value
Example #5
0
 def _synth_input(self):
     if not input_queue.suppress_output:
         terminal.push(self.prompt)
     input = input_queue.pop
     if not self._do_input(input):
         raise InvalidInput(input)