vnrecode: replace funky method with ASCII symbol
This commit is contained in:
parent
626eaae5e2
commit
d4092b46df
1 changed files with 6 additions and 17 deletions
|
@ -3,7 +3,6 @@ from pathlib import Path
|
||||||
import colorama
|
import colorama
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
|
|
||||||
class Printer:
|
class Printer:
|
||||||
"""
|
"""
|
||||||
|
@ -20,16 +19,6 @@ class Printer:
|
||||||
self.bar = IncrementalBar('Compressing', max=file_count, suffix='[%(index)d/%(max)d] (%(percent).1f%%)')
|
self.bar = IncrementalBar('Compressing', max=file_count, suffix='[%(index)d/%(max)d] (%(percent).1f%%)')
|
||||||
self.bar.update()
|
self.bar.update()
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def clean_str(string: str) -> str:
|
|
||||||
"""
|
|
||||||
Method fills end of string with spaces to remove progress bar garbage from console
|
|
||||||
:param string: String to "clean"
|
|
||||||
:return: "Clean" string
|
|
||||||
"""
|
|
||||||
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
||||||
return string + " " * (os.get_terminal_size().columns - len(ansi_escape.sub('', string)))
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def win_ascii_esc():
|
def win_ascii_esc():
|
||||||
"""
|
"""
|
||||||
|
@ -54,7 +43,7 @@ class Printer:
|
||||||
:param string: String to print
|
:param string: String to print
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.bar_print(self.clean_str(f"\r\033[100m- {string}\033[49m"))
|
self.bar_print(f"\x1b[2K\r\033[100m- {string}\033[49m")
|
||||||
|
|
||||||
def warning(self, string: str):
|
def warning(self, string: str):
|
||||||
"""
|
"""
|
||||||
|
@ -62,7 +51,7 @@ class Printer:
|
||||||
:param string: String to print
|
:param string: String to print
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.bar_print(self.clean_str(f"\r\033[93m!\033[0m {string}\033[49m"))
|
self.bar_print(f"\x1b[2K\r\033[93m!\033[0m {string}\033[49m")
|
||||||
|
|
||||||
def error(self, string: str):
|
def error(self, string: str):
|
||||||
"""
|
"""
|
||||||
|
@ -70,7 +59,7 @@ class Printer:
|
||||||
:param string: String to print
|
:param string: String to print
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.bar_print(self.clean_str(f"\r\033[31m\u2715\033[0m {string}\033[49m"))
|
self.bar_print(f"\x1b[2K\r\033[31m\u2715\033[0m {string}\033[49m")
|
||||||
|
|
||||||
def files(self, source_path: Path, output_path: Path, comment: str):
|
def files(self, source_path: Path, output_path: Path, comment: str):
|
||||||
"""
|
"""
|
||||||
|
@ -81,8 +70,8 @@ class Printer:
|
||||||
:param comment: Comment about recode quality setting
|
:param comment: Comment about recode quality setting
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.bar_print(self.clean_str(f"\r\033[0;32m\u2713\033[0m \033[0;37m{source_path.stem}\033[0m{source_path.suffix}\033[0;37m -> "
|
self.bar_print(f"\x1b[2K\r\033[0;32m\u2713\033[0m \033[0;37m{source_path.stem}\033[0m{source_path.suffix}\033[0;37m -> "
|
||||||
f"{source_path.stem}\033[0m{output_path.suffix}\033[0;37m ({comment})\033[0m"))
|
f"{source_path.stem}\033[0m{output_path.suffix}\033[0;37m ({comment})\033[0m")
|
||||||
|
|
||||||
def unknown_file(self, filename: str):
|
def unknown_file(self, filename: str):
|
||||||
"""
|
"""
|
||||||
|
@ -90,4 +79,4 @@ class Printer:
|
||||||
:param filename: Name of unknown file
|
:param filename: Name of unknown file
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self.bar_print(self.clean_str(f"\r\u2713 \033[0;33m{filename}\033[0m (File will be force compressed via ffmpeg)"))
|
self.bar_print(f"\x1b[2K\r\u2713 \033[0;33m{filename}\033[0m (File will be force compressed via ffmpeg)")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue