@@ -27,32 +27,32 @@ def apply_rules_on_ini_cst(parsed_subset):
27
27
def apply_rules_on_sections (parsed_subset ):
28
28
for section in parsed_subset :
29
29
for token in section :
30
- if token ["type" ] == "lines_tokens " :
31
- lines_tokens = token ["content" ]
30
+ if token ["type" ] == "children " :
31
+ children = token ["content" ]
32
32
33
33
# TODO: Remove contains_property_shallowly() and write out what they do in this function
34
- if contains_property_shallowly (lines_tokens , "MaxMass" ):
35
- max_mass_to_max_inventory_mass (lines_tokens )
34
+ if contains_property_shallowly (children , "MaxMass" ):
35
+ max_mass_to_max_inventory_mass (children )
36
36
37
- iconfile_path = iconfile_path_to_thumbnail_generator (lines_tokens )
37
+ iconfile_path = iconfile_path_to_thumbnail_generator (children )
38
38
39
- for line_tokens in lines_tokens :
39
+ for line_tokens in children :
40
40
replace_property_and_value (line_tokens , "MinThrottleRange" , "NegativeThrottleMultiplier" , min_throttle_range_to_negative_throttle_multiplier )
41
41
replace_property_and_value (line_tokens , "MaxThrottleRange" , "PositiveThrottleMultiplier" , max_throttle_range_to_positive_throttle_multiplier )
42
42
43
43
# TODO: Remove contains_property_and_value_shallowly() and write out what it does in this function
44
44
# TODO: I don't remember whether this one works
45
45
if contains_property_and_value_shallowly (section , "AddActor" , "Leg" ):
46
46
for token in section :
47
- if token ["type" ] == "lines_tokens " :
48
- lines_tokens = token ["content" ]
47
+ if token ["type" ] == "children " :
48
+ children = token ["content" ]
49
49
50
- max_length_to_offsets (lines_tokens )
50
+ max_length_to_offsets (children )
51
51
52
52
53
- def contains_property_shallowly (lines_tokens , prop ):
53
+ def contains_property_shallowly (children , prop ):
54
54
""" This function deliberately doesn't check the section's contents recursively. """
55
- return [True for line_tokens in lines_tokens for token in line_tokens if token ["type" ] == "property" and token ["content" ] == prop ] != []
55
+ return [True for line_tokens in children for token in line_tokens if token ["type" ] == "property" and token ["content" ] == prop ] != []
56
56
57
57
58
58
def contains_property_and_value_shallowly (section , prop , value ):
@@ -67,13 +67,13 @@ def contains_property_and_value_shallowly(section, prop, value):
67
67
return contains_property and contains_value
68
68
69
69
70
- def max_mass_to_max_inventory_mass (lines_tokens ):
70
+ def max_mass_to_max_inventory_mass (children ):
71
71
""" MaxInventoryMass = MaxMass - Mass """
72
72
73
73
mass = 0 # The Mass is optionally defined in the INI file.
74
74
75
75
# TODO: Find a way to split these into subfunctions.
76
- for line_tokens in lines_tokens :
76
+ for line_tokens in children :
77
77
for token in line_tokens :
78
78
if token ["type" ] == "property" :
79
79
if token ["content" ] == "Mass" :
@@ -90,7 +90,7 @@ def max_mass_to_max_inventory_mass(lines_tokens):
90
90
91
91
max_inventory_mass = remove_excess_zeros (max_mass - mass )
92
92
93
- for line_tokens in lines_tokens :
93
+ for line_tokens in children :
94
94
for token in line_tokens :
95
95
if token ["type" ] == "property" :
96
96
if token ["content" ] == "MaxMass" :
@@ -127,7 +127,7 @@ def max_throttle_range_to_positive_throttle_multiplier(old_value):
127
127
128
128
129
129
# TODO: Refactor max_length_to_offsets and max_length_to_offsets_2
130
- def max_length_to_offsets (lines_tokens ):
130
+ def max_length_to_offsets (children ):
131
131
"""
132
132
If the parent line is AddActor = Leg:
133
133
MaxLength = old_value
@@ -140,18 +140,18 @@ def max_length_to_offsets(lines_tokens):
140
140
Y = 0
141
141
"""
142
142
143
- for index , line_tokens in enumerate (lines_tokens ):
143
+ for index , line_tokens in enumerate (children ):
144
144
old_value = max_length_to_offsets_2 (line_tokens )
145
145
146
146
if old_value != None :
147
147
# print(index, old_value)
148
148
149
- lines_tokens .insert (index + 1 , [
149
+ children .insert (index + 1 , [
150
150
{ "type" : "extra" , "content" : "\t " },
151
151
{ "type" : "property" , "content" : "ExtendedOffset" },
152
152
{ "type" : "extra" , "content" : " " }, {"type" : "extra" , "content" : "=" }, {"type" : "extra" , "content" : " " },
153
153
{ "type" : "value" , "content" : "Vector" },
154
- { "type" : "lines_tokens " , "content" : [
154
+ { "type" : "children " , "content" : [
155
155
[
156
156
{ "type" : "extra" , "content" : "\t \t " },
157
157
{ "type" : "property" , "content" : "X" },
@@ -179,7 +179,7 @@ def max_length_to_offsets_2(line_tokens):
179
179
old_value = float (token_2 ["content" ])
180
180
token_2 ["content" ] = "Vector"
181
181
182
- line_tokens .append ( { "type" : "lines_tokens " , "content" : [
182
+ line_tokens .append ( { "type" : "children " , "content" : [
183
183
[
184
184
{ "type" : "extra" , "content" : "\t \t " },
185
185
{ "type" : "property" , "content" : "X" },
@@ -197,15 +197,15 @@ def max_length_to_offsets_2(line_tokens):
197
197
return old_value
198
198
199
199
200
- def iconfile_path_to_thumbnail_generator (lines_tokens ):
201
- for line_tokens in lines_tokens :
200
+ def iconfile_path_to_thumbnail_generator (children ):
201
+ for line_tokens in children :
202
202
if {"type" : "property" , "content" : "IconFile" } in line_tokens and {"type" : "value" , "content" : "ContentFile" } in line_tokens :
203
203
for token in line_tokens :
204
- if token ["type" ] == "lines_tokens " :
205
- sublines_tokens = token ["content" ]
206
- # print(sublines_tokens )
204
+ if token ["type" ] == "children " :
205
+ subchildren = token ["content" ]
206
+ # print(subchildren )
207
207
208
- for subline_tokens in sublines_tokens :
208
+ for subline_tokens in subchildren :
209
209
if {"type" : "property" , "content" : "FilePath" } in subline_tokens :
210
210
# print(subline_tokens)
211
211
for subtoken in subline_tokens :
0 commit comments