Skip to content

Commit 9a5a7cc

Browse files
authored
Merge pull request #1806 from Manas-maker/feature/converter-keyerror-ror-swgb
convert/tech_subprocessor: extend contextual KeyErrors to RoR and SWGB
2 parents 289ef46 + 0516825 commit 9a5a7cc

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

copying.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ _the openage authors_ are:
168168
| Daniel Wieczorek | Danio | danielwieczorek96 à gmail dawt com |
169169
| | bytegrrrl | bytegrrrl à proton dawt me |
170170
| Nicolas Sanchez | nicolassanchez02 | nicolasjpsanchez à gmail dawt com |
171+
| Manas Pradhan | manas-maker | manasmpradhan5 à gmail dawt com |
171172

172173
If you're a first-time committer, add yourself to the above list. This is not
173174
just for legal reasons, but also to keep an overview of all those nicknames.

openage/convert/processor/conversion/ror/tech_subprocessor.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 the openage authors. See copying.md for legal info.
1+
# Copyright 2020-2026 the openage authors. See copying.md for legal info.
22
#
33
# pylint: disable=too-many-locals,too-many-branches
44
#
@@ -158,7 +158,13 @@ def attribute_modify_effect(
158158
else:
159159
return patches
160160

161-
upgrade_func = RoRTechSubprocessor.upgrade_attribute_funcs[attribute_type]
161+
try:
162+
upgrade_func = RoRTechSubprocessor.upgrade_attribute_funcs[attribute_type]
163+
except KeyError as exc:
164+
raise KeyError(
165+
f"No subprocessor function found for handling upgrade of "
166+
f"unit attribute: {attribute_type}"
167+
) from exc
162168
for affected_entity in affected_entities:
163169
patches.extend(upgrade_func(converter_group, affected_entity, value, operator, team))
164170

@@ -202,7 +208,13 @@ def resource_modify_effect(
202208
# 30 = building limits (unused)
203209
return patches
204210

205-
upgrade_func = RoRTechSubprocessor.upgrade_resource_funcs[resource_id]
211+
try:
212+
upgrade_func = RoRTechSubprocessor.upgrade_resource_funcs[resource_id]
213+
except KeyError as exc:
214+
raise KeyError(
215+
f"No subprocessor function found for handling upgrade of "
216+
f"resource: {resource_id}"
217+
) from exc
206218
patches.extend(upgrade_func(converter_group, value, operator, team))
207219

208220
return patches

openage/convert/processor/conversion/swgbcc/tech_subprocessor.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 the openage authors. See copying.md for legal info.
1+
# Copyright 2020-2026 the openage authors. See copying.md for legal info.
22
#
33
# pylint: disable=too-many-locals,too-many-branches
44
#
@@ -245,7 +245,13 @@ def attribute_modify_effect(
245245
else:
246246
return patches
247247

248-
upgrade_func = SWGBCCTechSubprocessor.upgrade_attribute_funcs[attribute_type]
248+
try:
249+
upgrade_func = SWGBCCTechSubprocessor.upgrade_attribute_funcs[attribute_type]
250+
except KeyError as exc:
251+
raise KeyError(
252+
f"No subprocessor function found for handling upgrade of "
253+
f"unit attribute: {attribute_type}"
254+
) from exc
249255
for affected_entity in affected_entities:
250256
patches.extend(upgrade_func(converter_group, affected_entity, value, operator, team))
251257

@@ -288,7 +294,13 @@ def resource_modify_effect(
288294
# 21 = tech count (unused)
289295
return patches
290296

291-
upgrade_func = SWGBCCTechSubprocessor.upgrade_resource_funcs[resource_id]
297+
try:
298+
upgrade_func = SWGBCCTechSubprocessor.upgrade_resource_funcs[resource_id]
299+
except KeyError as exc:
300+
raise KeyError(
301+
f"No subprocessor function found for handling upgrade of "
302+
f"resource: {resource_id}"
303+
) from exc
292304
patches.extend(upgrade_func(converter_group, value, operator, team))
293305

294306
return patches

0 commit comments

Comments
 (0)