示例#1
0
文件: tools.py 项目: 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()
示例#2
0
文件: user_input.py 项目: tek/pytek
 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
示例#3
0
文件: user_input.py 项目: tek/pytek
 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
示例#4
0
文件: user_input.py 项目: tek/pytek
 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
示例#5
0
文件: user_input.py 项目: tek/pytek
 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)