@@ -17,7 +17,7 @@ def load_json_as_dict(file_name):
17
17
with open (file_name , "r" ) as f :
18
18
return json .load (f )
19
19
def extends (json_dict , * , base_folder = None , base_dict = {}, object_route = "" ):
20
- extends_from = json_dict [SPECIAL_FIELD_FLAG + "extends" ][ SPECIAL_FIELD_FLAG + "from" ].split ("." )
20
+ extends_from = json_dict [FLAG_EXTENDS ][ FLAG_FROM ].split ("." )
21
21
attr_build = {}
22
22
if len (extends_from ) == 1 :
23
23
new_route = object_route_join (object_route ,extends_from [0 ])
@@ -26,35 +26,35 @@ def extends(json_dict, *, base_folder=None, base_dict={}, object_route=""):
26
26
else :
27
27
CustomLogging .error (f"Attribute { extends_from [0 ]} not found extending { object_route } \n { base_dict } " )
28
28
else :
29
- attr_file_name = search_json (json_dict [SPECIAL_FIELD_FLAG + "extends" ][ SPECIAL_FIELD_FLAG + "from" ], base_folder = base_folder )
29
+ attr_file_name = search_json (json_dict [FLAG_EXTENDS ][ FLAG_FROM ], base_folder = base_folder )
30
30
if not attr_file_name :
31
- CustomLogging .error (f"{ json_dict [SPECIAL_FIELD_FLAG + 'extends' ][ SPECIAL_FIELD_FLAG + 'from' ]} path does not exists in" )
31
+ CustomLogging .error (f"{ json_dict [FLAG_EXTENDS ][ FLAG_FROM ]} path does not exists in" )
32
32
attr_json = load_json_as_dict (attr_file_name )
33
33
attr_build = json_global_compile (
34
34
attr_json ,
35
- args = json_dict [SPECIAL_FIELD_FLAG + "extends" ],
35
+ args = json_dict [FLAG_EXTENDS ],
36
36
base_folder = os .path .dirname (attr_file_name ),
37
- object_route = json_dict [SPECIAL_FIELD_FLAG + "extends" ][ SPECIAL_FIELD_FLAG + "from" ]
37
+ object_route = json_dict [FLAG_EXTENDS ][ FLAG_FROM ]
38
38
)
39
- is_excluding = SPECIAL_FIELD_FLAG + "excludes" in json_dict [SPECIAL_FIELD_FLAG + "extends" ]
40
- is_including = SPECIAL_FIELD_FLAG + "includes" in json_dict [SPECIAL_FIELD_FLAG + "extends" ]
39
+ is_excluding = FLAG_EXCLUDES in json_dict [FLAG_EXTENDS ]
40
+ is_including = FLAG_INCLUDES in json_dict [FLAG_EXTENDS ]
41
41
if is_including and is_excluding :
42
42
CustomLogging .error ("can not use excludes and includes in a same block" )
43
43
if is_including :
44
44
new_attr_build = {}
45
- for include in json_dict [SPECIAL_FIELD_FLAG + "extends" ][ SPECIAL_FIELD_FLAG + "includes" ]:
45
+ for include in json_dict [FLAG_EXTENDS ][ FLAG_INCLUDES ]:
46
46
if include not in attr_build :
47
47
CustomLogging .error (f"{ object_route } include error: attribute { include } not in { json_dict [SPECIAL_FIELD_FLAG + 'extends' ][SPECIAL_FIELD_FLAG + 'from' ]} " )
48
48
new_attr_build [include ] = attr_build [include ]
49
49
attr_build = new_attr_build
50
50
if is_excluding :
51
- for exclude in json_dict [SPECIAL_FIELD_FLAG + "extends" ][ SPECIAL_FIELD_FLAG + "excludes" ]:
51
+ for exclude in json_dict [FLAG_EXTENDS ][ FLAG_EXCLUDES ]:
52
52
if exclude in attr_build :
53
53
attr_build .pop (exclude )
54
54
else :
55
55
CustomLogging .warning (f"exclude error { object_route } : attribute { exclude } not in { json_dict [SPECIAL_FIELD_FLAG + 'extends' ][SPECIAL_FIELD_FLAG + 'from' ]} " )
56
56
json_dict .update (attr_build )
57
- json_dict .pop (SPECIAL_FIELD_FLAG + "extends" )
57
+ json_dict .pop (FLAG_EXTENDS )
58
58
return json_dict
59
59
def cosntruct_replace (main_object , arg_replace , value , * , object_route = "" ):
60
60
if type (main_object ) == str :
@@ -85,12 +85,12 @@ def cosntructor(json_dict, *, args = {}, object_route=""):
85
85
constructor_dict = json_dict .pop (SPECIAL_FIELD_FLAG + "constructor" )
86
86
response_json = copy .deepcopy (json_dict )
87
87
args_to_check = copy .deepcopy (args )
88
- if SPECIAL_FIELD_FLAG + "from" in args_to_check :
89
- args_to_check .pop (SPECIAL_FIELD_FLAG + "from" )
90
- if SPECIAL_FIELD_FLAG + "excludes" in args_to_check :
91
- args_to_check .pop (SPECIAL_FIELD_FLAG + "excludes" )
92
- if SPECIAL_FIELD_FLAG + "includes" in args_to_check :
93
- args_to_check .pop (SPECIAL_FIELD_FLAG + "includes" )
88
+ if FLAG_FROM in args_to_check :
89
+ args_to_check .pop (FLAG_FROM )
90
+ if FLAG_EXCLUDES in args_to_check :
91
+ args_to_check .pop (FLAG_EXCLUDES )
92
+ if FLAG_INCLUDES in args_to_check :
93
+ args_to_check .pop (FLAG_INCLUDES )
94
94
for arg_to_check in args_to_check :
95
95
if arg_to_check not in constructor_dict :
96
96
CustomLogging .warning (f"error in constructor: invalid parameter { arg_to_check } " )
@@ -118,7 +118,7 @@ def special_flags_processing(json_dict, *, args = {}, base_folder=None, base_dic
118
118
if SPECIAL_FIELD_FLAG + "constructor" in json_dict :
119
119
json_dict = cosntructor (json_dict , args = args , object_route = object_route )
120
120
base_dict = copy .deepcopy (json_dict )
121
- if SPECIAL_FIELD_FLAG + "extends" in json_dict :
121
+ if FLAG_EXTENDS in json_dict :
122
122
json_dict = extends (json_dict , base_folder = base_folder , base_dict = base_dict , object_route = object_route )
123
123
for attribute in json_dict :
124
124
if type (json_dict [attribute ]) == dict :
0 commit comments