-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.py
42 lines (33 loc) · 954 Bytes
/
main.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
import sys
import json
# A node which contains the data from the JSON file in a python format
class Node:
def __init__(self, nameAr: str, nameEn: str, nameFr: str, univ: str):
self.nameAr = nameAr
self.nameEn = nameEn
self.nameFr = nameFr
self.univ = univ
def getNameAr(self):
return self.nameAr
def getNameEn(self):
return self.nameEn
def getNameFr(self):
return self.nameFr
def getUniv(self):
return self.univ
# Converts the data from the
def getNodeByPath(path: str) -> Node:
try:
file = open(path, "r")
fileText = file.read()
pythonData = json.loads(fileText)
node = Node(pythonData["name"]["ar"], pythonData["name"]["en"], pythonData["name"]["fr"], pythonData["type"])
return node
except OSError as e:
raise FileNotFoundError(f"Error with the file : {e}")
def main():
try:
node = getNodeByPath(sys.argv[1])
except FileNotFoundError as e:
print(e)
main()