-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmodule.py
More file actions
51 lines (35 loc) · 939 Bytes
/
Copy pathmodule.py
File metadata and controls
51 lines (35 loc) · 939 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
40
41
42
43
44
45
46
47
48
49
50
51
import os
import re
import shutil
########################
### GLOBALS
NEWLINE = '\n'
INFINITY = float("INFINITY")
########################
def checkFiles(*filenames):
for filename in filenames:
if not os.path.exists(filename):
return False
return True
#########################
def convertHexToASCII(str):
return re.sub(r'\%([A-Z0-9][A-Z0-9])', lambda match: "{0}".format(bytes.fromhex(match.group(1)).decode("utf-8")), str)
#########################
def prep_output_dir(path, makedir=True):
# Does the directory already exist?
if os.path.exists(path):
# it does exist... delete
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
# Make the directory
if makedir:
os.mkdir(path)
#######################
### MODULE BASE CLASS
class Module():
ready = True
output_files = []
def run():
pass