Skip to content

Commit 01314ed

Browse files
committed
move main to example
1 parent dd8df2d commit 01314ed

2 files changed

Lines changed: 44 additions & 22 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#############################################################################
2+
# Copyright (C) 2020-2021 German Aerospace Center (DLR-SC)
3+
#
4+
# Authors: Rene Schmieding
5+
#
6+
# Contact: Martin J. Kuehn <[email protected]>
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#############################################################################
20+
"""@ProgressIndicator.py
21+
WARNING: This file is currently not tested and maintained.
22+
"""
23+
from memilio import progress_indicator
24+
import time
25+
26+
print("This is only a usage example, and does not actually do anything.")
27+
# using start/stop
28+
p = progress_indicator.Dots(message="waiting", delay=0.5)
29+
p.start()
30+
time.sleep(1.6)
31+
p.stop()
32+
# using with as block
33+
with progress_indicator.Percentage(message="download 1", delay=0.4) as p:
34+
for i in range(13):
35+
time.sleep(0.1467)
36+
p.set_progress((i+1)/13)
37+
with progress_indicator.Percentage(message="download 2", use_bar=False,
38+
delay=0, keep_output=False) as p:
39+
for i in range(97):
40+
time.sleep(0.0367)
41+
p.set_progress((i+1)/97)
42+
# using with block ('as' is not usefull without Percentage)
43+
with progress_indicator.Spinner(message="finish"):
44+
time.sleep(2)

pycode/memilio-epidata/memilio/progress_indicator.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -324,25 +324,3 @@ def _bar(width, percentage):
324324
w = width - 3 # 3 == len("[] ")
325325
n = int(w * percentage)
326326
return "[" + "#" * n + " " * (w - n) + "] "
327-
328-
329-
if __name__ == "__main__":
330-
print("This is only a usage example, and does not actually do anything.")
331-
# using start/stop
332-
p = Dots(message="waiting", delay=0.5)
333-
p.start()
334-
time.sleep(1.6)
335-
p.stop()
336-
# using with as block
337-
with Percentage(message="download 1", delay=0.4) as p:
338-
for i in range(13):
339-
time.sleep(0.1467)
340-
p.set_progress((i+1)/13)
341-
with Percentage(message="download 2", use_bar=False,
342-
delay=0, keep_output=False) as p:
343-
for i in range(97):
344-
time.sleep(0.0367)
345-
p.set_progress((i+1)/97)
346-
# using with block ('as' is not usefull without Percentage)
347-
with Spinner(message="finish"):
348-
time.sleep(2)

0 commit comments

Comments
 (0)