-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd8a553
commit 0891b78
Showing
4 changed files
with
75 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
*.png | ||
*.zip | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,44 @@ | ||
""" | ||
Progress Bar | ||
------------- | ||
Provides console progress bar functionality. | ||
Usage: | ||
Call start_progress(title) immediatley before action | ||
Call progress(x) after every step | ||
Call end_progress() after action is complete | ||
Based on code from https://stackoverflow.com/a/6169274 | ||
""" | ||
|
||
import sys | ||
|
||
def start_progress(title): | ||
""" | ||
Prints beggining of a console progress bar. | ||
Args: | ||
title: string, name of progress bar | ||
""" | ||
global progress_x | ||
sys.stdout.write(title + ": [" + "-"*40 + "]" + chr(8)*41) | ||
sys.stdout.flush() | ||
progress_x = 0 | ||
|
||
def progress(x): | ||
""" | ||
Updates a console progress bar with new progress. | ||
Args: | ||
x: percentage of total progress made | ||
""" | ||
global progress_x | ||
x = int(x * 40 // 100) | ||
sys.stdout.write("#" * (x - progress_x)) | ||
sys.stdout.flush() | ||
progress_x = x | ||
|
||
def end_progress(): | ||
"""Prints end of progress bar after action completion""" | ||
sys.stdout.write("#" * (40 - progress_x) + "] DONE\n") | ||
sys.stdout.flush() |