-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathutils.py
More file actions
40 lines (29 loc) · 680 Bytes
/
utils.py
File metadata and controls
40 lines (29 loc) · 680 Bytes
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
import os
import sys
import pickle
import numpy as np
from PIL import Image
def mkdir(paths):
if not isinstance(paths, (list, tuple)):
paths = [paths]
for path in paths:
if not os.path.isdir(path):
os.makedirs(path)
def cprint(color, text, **kwargs):
if color[0] == '*':
pre_code = '1;'
color = color[1:]
else:
pre_code = ''
code = {
'a': '30',
'r': '31',
'g': '32',
'y': '33',
'b': '34',
'p': '35',
'c': '36',
'w': '37'
}
print("\x1b[%s%sm%s\x1b[0m" % (pre_code, code[color], text), **kwargs)
sys.stdout.flush()