-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
62 lines (48 loc) · 1.83 KB
/
settings.py
File metadata and controls
62 lines (48 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from enum import Enum
class RepositoryType(Enum):
MEMORY = 0
TEXT_FILE = 1
BINARY_FILE = 2
class Settings:
__instance = None
@staticmethod
def get_instance():
if Settings.__instance is not None:
return Settings.__instance
fin = open("settings.properties", "rt")
file_lines = fin.readlines()
fin.close()
settings_dict = {}
for line in file_lines:
if line.strip().startswith("#"):
continue
tokens = line.strip().split("=")
settings_dict[tokens[0].strip()] = tokens[1].strip()
repo_type = settings_dict["repository"]
students_file = settings_dict["student_file"]
disciplines_file = settings_dict["discipline_file"]
grades_file = settings_dict["grade_file"]
repository_type = RepositoryType.MEMORY
if repo_type == "textfile":
repository_type = RepositoryType.TEXT_FILE
elif repo_type == "binaryfile":
repository_type = RepositoryType.BINARY_FILE
Settings.__instance = Settings(repository_type, students_file, disciplines_file, grades_file)
return Settings.__instance
def __init__(self, repo_type: RepositoryType, students_file: str, disciplines_file: str, grades_file: str):
self.__repo_type = repo_type
self.__students_file = students_file
self.__disciplines_file = disciplines_file
self.__grades_file = grades_file
@property
def repository_type(self):
return self.__repo_type
@property
def students_file(self):
return self.__students_file
@property
def disciplines_file(self):
return self.__disciplines_file
@property
def grades_file(self):
return self.__grades_file