-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
91 lines (67 loc) · 2.18 KB
/
config.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import os
import configparser
def create_path(fn):
def _wrapper(*args, **kwargs):
result = fn(*args, **kwargs)
if not os.path.exists(result):
os.makedirs(result, exist_ok=True)
return result
return _wrapper
class Config:
def __init__(self):
self.root = os.getcwd() + '/'
self.parser = configparser.ConfigParser()
self.parser.read(self.root + 'config.ini')
@property
@create_path
def output_path(self):
return self.root + parser['PATH']['output']
@property
def input_path(self):
return self.root + parser['PATH']['input']
@property
def get_json_data_path(self):
return self.root + parser['TRAIN']['json_data']
@property
@create_path
def temp_data(self):
return self.root + parser['TRAIN']['temp_data']
@property
def training_csv(self):
return os.path.join(self.temp_data, 'train_dataset.csv')
@property
def testing_csv(self):
return os.path.join(self.temp_data, 'test_dataset.csv')
@property
@create_path
def model_directory(self):
return self.root + parser['TRAIN']['model_data']
@property
def check_point(self):
return os.path.join(self.model_directory, 'checkpoint-mal.pt')
@property
def check_point_training(self):
return os.path.join(self.model_directory, 'checkpoint-MLP.pt')
@property
def model_file(self):
return os.path.join(self.model_directory, 'mal-Trained-Model.pt')
@property
def trained_model_file(self):
return os.path.join(self.model_directory, 'MLP-Trained-Model.pt')
@property
def encoded_csv(self):
return os.path.join(self.model_directory, "encoded-form-mal.csv")
@property
def label_text(self):
return os.path.join(self.model_directory, 'malware-label-index.txt')
@property
def unigram_path(self):
return os.path.join(self.temp_data, 'top_unigrams.txt')
@property
def dataset_path(self):
return os.path.join(self.temp_data, 'dataset.csv.xz')
@property
def training_params(self):
return self.parser['TRAIN']
config = Config()
parser = config.parser