-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprogressBar.py
36 lines (30 loc) · 1.09 KB
/
progressBar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def GetPatchedProgress():
# Import a clean version of the entire package.
import progress
# Import the wraps decorator for copying over the name, docstring, and other metadata.
from functools import wraps
# Get the current platform.
from sys import platform
# Check if we're on Windows.
if platform.startswith("win"):
# Disable HIDE_CURSOR and SHOW_CURSOR characters.
progress.HIDE_CURSOR = ''
progress.SHOW_CURSOR = ''
# Create a patched clearln function that wraps the original function.
@wraps(progress.Infinite.clearln)
def patchedclearln(self):
# Get the current platform.
from sys import platform
# Some sort of check copied from the source.
if self.file and self.is_tty():
# Check if we're on Windows.
if platform.startswith("win"):
# Don't use the character.
print('\r', end='', file=self.file)
else:
# Use the character.
print('\r\x1b[K', end='', file=self.file)
# Copy over the patched clearln function into the imported clearln function.
progress.Infinite.clearln = patchedclearln
# Return the modified version of the entire package.
return progress