aquaduct.utils.clui module¶
Module comprises convieniences functions and definitios for different operations related to command line user interface.
-
message(mess, cont=False)[source]¶ Prints message to standard error. If FileHandler is present in the
root_loggerthe same message is appended to the log file.
-
gregorian_year_in_days= 365.2425¶ Length of Gregorian year in days. Average value. Source: https://en.wikipedia.org/wiki/Year
-
smart_time_string(s, rl=0, t=1.1, maximal_length=None, maximal_units=5)[source]¶ Function transforms time in seconds to nicely formatted string of length defined by
maximal_length. Depending on number of seconds time is represented with one or more of the following units:Unit name
Unit abbreviation
seconds
s
minutes
m
hours
h
days
d
years
y
Maximal number of units used in time string can be set with
maximal_units.- Parameters
s (int) – Input time in seconds.
rl (int) – Number of units already used for representing time.
t (float) – Exces above standard number of current time units.
maximal_length (int) – Maximal length of the output string. Must be greater then 0.
maximal_units (int) – Maximal number of units used in the output string. Must be greater then 0 and lower then 6.
- Returns
string of nicely formated time
- Return type
-
class
SimpleProgressBar(maxval=None, mess=None, iterable=None)[source]¶ Bases:
objectSimple progress bar displaying progress with percent indicator, progress bar and ETA. Progress is measured by iterations.
- Variables
rotate (str) – String comprising characters with frames of a rotating toy.
barlenght (int) – Length of progress bar.
maxval (int) – maximal number of iterations
current (int) – current number of iterations
overrun_notice (bool) – if True, overrun above
maxvaliterations causes insert of newlineoverrun (bool) – flag of overrun
begin (int) – time in seconds at the initialization of the
SimpleProgressBarclass.tcurrent (int) – time in seconds of current iteration
-
ETA()[source]¶ Returns ETA calculated on the basis of current number of iterations
currentand current timetcurrent. If number of iterations is 0 returns?. Time is formated wihtsmart_time_string().- Returns
ETA as string.
- Return type
-
percent()[source]¶ Returns float number of precent progress calculated in the basis of current number of iterations
current. Should return number between 0 and 100.- Returns
percent progress number
- Return type
-
show()[source]¶ Shows current progress.
If value returned by
percent()is =< 100 then progres is printed as percent indicator leaded by ETA calculated byETA().If value returned by
percent()is > 100 then progress is printed as number of iterations and total time.Progress bar is writen to standard error.
-
update(step)[source]¶ Updates number of current iterations
currentby one ifstepis > 0. Otherwise number of current iterations is not updated. In boths cases time of current iterationtcurrentis updated andshow()is called.- Parameters
step (int) – update step
-
ttime()[source]¶ Calculates and returns total time string formated with
smart_time_string().- Returns
string of total time
- Return type
-
pbar¶