-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
43 lines (37 loc) · 1.8 KB
/
utils.py
File metadata and controls
43 lines (37 loc) · 1.8 KB
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
37
38
39
40
41
42
43
from colors import Colors
import os
import platform
PROGRAM_NAME = "detect_tabs.py"
ARGS_EXPLANATION = {
"replace": "replace all TAB usage in file with spaces and generate new file",
"<int(number)>": "OPTIONAL argument (int number) which will convert all tabs to the provided number of spaces.\nDefault value is 8 (Please not for python files (.py) the value is 4 by default (PEP8))",
"check": "analyze file for TAB usage and provides output",
"check-short": "analyze file for TAB usage and provide simplified output",
}
EXAMPLE_USAGES = {
"example usage with 'check' argument": f"python3 {PROGRAM_NAME} <filename> check",
"example usage with 'check-short' argument": f"python3 {PROGRAM_NAME} <filename> check-short",
"example usage with 'replace' argument": f"python3 {PROGRAM_NAME} <filename> replace",
"example usage with 'replace' argument and not default tab to space value": f"python3 {PROGRAM_NAME} <filename> <10> replace",
"example usage with 'replace' argument and .py file": f"python3 {PROGRAM_NAME} <filename.py> replace ",
}
def clear() -> None:
"""Clears the terminal input"""
current_os = platform.system()
if current_os == "Linux":
os.system("clear")
else:
os.system("cls")
def help():
clear()
print(
f"{Colors.FAIL}Usage: python3 {PROGRAM_NAME} <file> <OPTINAL: space numbers> <check/check-short/replace>"
)
print(f"{Colors.DEFAULT}-" * 20)
print(f"{Colors.BOLD}{Colors.WARNING}Usage of arguments:\n")
for key, value in ARGS_EXPLANATION.items():
print(f"{Colors.RESET}{Colors.OKGREEN}{key}: {value}")
print(f"{Colors.DEFAULT}-" * 20)
print(f"{Colors.BOLD}{Colors.WARNING}Example usages:\n")
for key, value in EXAMPLE_USAGES.items():
print(f"{Colors.RESET}{Colors.OKGREEN}{key}: {value}")