-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.py
41 lines (32 loc) · 966 Bytes
/
debug.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
37
38
39
40
41
# Builtin.
import os
import shutil
# First party.
import config
from bank.info import BankNames
def save_txt_to_disk(text_data):
if config.DEBUG_MODE:
complete_path = os.path.join(config.dbg_path, config.current_file)
with open(f"{complete_path}.txt", "w") as text_file:
for text in text_data:
text_file.write(f"{text}\n")
def create_debug_mode_folders(home):
dirs = ["ocr_dbg",
"input_files",
"Bancos"
]
try_rmdir_contents(os.path.join(home, "Desktop", dirs[0]))
for directory in dirs:
try_mkdir(os.path.join(home, "Desktop", directory))
for x in range(len(BankNames)):
try_mkdir(os.path.join(home, "Desktop/Bancos", BankNames(x).name))
def try_mkdir(path):
try:
os.mkdir(path)
except FileExistsError:
pass
def try_rmdir_contents(path):
try:
shutil.rmtree(path)
except FileNotFoundError:
pass