-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeBuilder.py
More file actions
25 lines (19 loc) · 809 Bytes
/
TreeBuilder.py
File metadata and controls
25 lines (19 loc) · 809 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
import json
from NameTable import NameTable
from Model.Identifier import Identifier
from Utils import Constants
class TreeBuilder(object):
__file_path = ""
def __init__(self, file_path):
self.__file_path = file_path
def build_name_table(self):
with open(self.__file_path) as data_file:
raw_identifiers = json.load(data_file)
identifiers = []
for raw_identifier in raw_identifiers:
identifier = Identifier(name=raw_identifier[Constants.Name],
type=raw_identifier[Constants.Type],
scope=raw_identifier[Constants.Scope])
identifiers.append(identifier)
name_table = NameTable(identifiers)
return name_table