Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# -*- coding: utf-8 -*- 

2# 

3# Copyright (c) 2017, the cclib development team 

4# 

5# This file is part of cclib (http://cclib.github.io) and is distributed under 

6# the terms of the BSD 3-Clause License. 

7 

8import sys 

9 

10 

11class TextProgress: 

12 

13 def __init__(self): 

14 

15 self.nstep = 0 

16 self.text = None 

17 self.oldprogress = 0 

18 self.progress = 0 

19 self.calls = 0 

20 

21 def initialize(self, nstep, text=None): 

22 

23 self.nstep = float(nstep) 

24 self.text = text 

25 

26 #sys.stdout.write("\n") 

27 

28 def update(self, step, text=None): 

29 

30 self.progress = int(step * 100 / self.nstep) 

31 

32 if self.progress/2 >= self.oldprogress/2 + 1 or self.text != text: 

33 # just went through at least an interval of ten, ie. from 39 to 41, 

34 # so update 

35 

36 mystr = "\r[" 

37 prog = int(self.progress / 10) 

38 mystr += prog * "=" + (10-prog) * "-" 

39 mystr += "] %3i" % self.progress + "%" 

40 

41 if text: 

42 mystr += " "+text 

43 

44 sys.stdout.write("\r" + 70 * " ") 

45 sys.stdout.flush() 

46 sys.stdout.write(mystr) 

47 sys.stdout.flush() 

48 self.oldprogress = self.progress 

49 

50 if self.progress >= 100 and text == "Done": 

51 print(" ") 

52 

53 return