@@ -22,7 +22,7 @@ BarGlyphs() = BarGlyphs(
22
22
)
23
23
24
24
"""
25
- printprogress(io::IO, barglyphs::BarGlyphs, tfirst::Float64, desc, progress::Real)
25
+ printprogress(io::IO, barglyphs::BarGlyphs, tfirst::Float64, desc, progress, eta_seconds ::Real)
26
26
27
27
Print progress bar to `io`.
28
28
@@ -31,24 +31,24 @@ Print progress bar to `io`.
31
31
- `barglyphs::BarGlyphs`
32
32
- `tfirst::Float64`
33
33
- `desc`: description to be printed at left side of progress bar.
34
- - `progress::Real `: a number between 0 and 1 or a `NaN `.
34
+ - `progress`: a number between 0 and 1 or `nothing `.
35
35
- `eta_seconds::Real`: ETA in seconds
36
36
"""
37
37
function printprogress (
38
38
io:: IO ,
39
39
barglyphs:: BarGlyphs ,
40
40
tfirst:: Float64 ,
41
41
desc,
42
- progress:: Real ,
42
+ progress,
43
43
eta_seconds:: Real ,
44
44
)
45
45
t = time ()
46
- percentage_complete = 100.0 * (isnan (progress) ? 0.0 : progress)
46
+ percentage_complete = 100.0 * (isnothing (progress) || isnan (progress) ? 0.0 : progress)
47
47
48
48
# ...length of percentage and ETA string with days is 29 characters
49
49
barlen = max (0 , displaysize (io)[2 ] - (length (desc) + 29 ))
50
50
51
- if progress >= 1
51
+ if ! isnothing (progress) && progress >= 1
52
52
bar = barstring (barlen, percentage_complete, barglyphs= barglyphs)
53
53
dur = durationstring (t - tfirst)
54
54
@printf io " %s%3u%%%s Time: %s" desc round (Int, percentage_complete) bar dur
@@ -111,4 +111,12 @@ function durationstring(nsec)
111
111
hhmmss
112
112
end
113
113
114
+ # issue #31: isnothing require Julia 1.1
115
+ # copy-over from
116
+ # https://github.com/JuliaLang/julia/blob/0413ef0e4de83b41b637ba02cc63314da45fe56b/base/some.jl
117
+ if ! isdefined (Base, :isnothing )
118
+ isnothing (:: Any ) = false
119
+ isnothing (:: Nothing ) = true
120
+ end
121
+
114
122
end
0 commit comments