Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@
BOLD = ''
UNDERLINE = ''

class ProgressBar:

Check warning

Code scanning / Pylint (reported by Codacy)

Too few public methods (1/2) Warning

Too few public methods (1/2)

Check warning

Code scanning / Pylint (reported by Codacy)

Missing class docstring Warning

Missing class docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing class docstring Warning

Missing class docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Too few public methods (1/2) Warning

Too few public methods (1/2)
def __init__(self, total: int, prefix: str = "Progress", length: int = 30):
self.total = total
self.prefix = prefix
self.length = length
self.current = 0

def increment(self):

Check warning

Code scanning / Pylint (reported by Codacy)

Missing method docstring Warning

Missing method docstring

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Missing function or method docstring Warning

Missing function or method docstring
self.current += 1
self._print()

def _print(self):
if not USE_COLORS or self.total == 0:
return
percent = float(self.current) / self.total
filled = int(self.length * percent)
bar = '█' * filled + '-' * (self.length - filled)

Check warning

Code scanning / Prospector (reported by Codacy)

Black listed name "bar" (blacklisted-name) Warning

Black listed name "bar" (blacklisted-name)

Check warning

Code scanning / Pylint (reported by Codacy)

Black listed name "bar" Warning

Black listed name "bar"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Black listed name "bar" Warning

Black listed name "bar"
sys.stderr.write(f"\r{Colors.CYAN}{self.prefix} |{bar}| {self.current}/{self.total}{Colors.ENDC}")

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (106/100) Warning

Line too long (106/100)

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (106/100) Warning

Line too long (106/100)
sys.stderr.flush()
if self.current == self.total:
sys.stderr.write("\n")

class ColoredFormatter(logging.Formatter):
"""Custom formatter to add colors to log levels."""
LEVEL_COLORS = {
Expand Down Expand Up @@ -387,7 +409,9 @@
log.info(f"Warming up cache for {len(urls_to_fetch)} URLs...")
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = {executor.submit(_gh_get, url): url for url in urls_to_fetch}
pb = ProgressBar(len(futures), "Fetching")

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "pb" doesn't conform to snake_case naming style Warning

Variable name "pb" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "pb" doesn't conform to snake_case naming style Warning

Variable name "pb" doesn't conform to snake_case naming style
for future in concurrent.futures.as_completed(futures):
pb.increment()
try:
future.result()
except Exception as e:
Expand Down Expand Up @@ -673,7 +697,9 @@
for folder_data in folder_data_list
}

pb = ProgressBar(len(future_to_folder), "Syncing folders")

Check warning

Code scanning / Pylint (reported by Codacy)

Variable name "pb" doesn't conform to snake_case naming style Warning

Variable name "pb" doesn't conform to snake_case naming style

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Variable name "pb" doesn't conform to snake_case naming style Warning

Variable name "pb" doesn't conform to snake_case naming style
for future in concurrent.futures.as_completed(future_to_folder):
pb.increment()
folder_data = future_to_folder[future]
folder_name = folder_data["group"]["group"].strip()
try:
Expand Down
Loading