Skip to content

Commit

Permalink
add bespoke function
Browse files Browse the repository at this point in the history
  • Loading branch information
markj0hnst0n committed Jul 3, 2024
1 parent b1aa29e commit e306fb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mail/libraries/lite_to_edifact_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
class EdifactValidationError(Exception):
pass

def get_class_attributes(cls):
return [str(attr) for attr in dir(cls)]

def generate_lines_for_licence(licence: LicencePayload) -> Iterable[chieftypes._Record]:
"""Yield line tuples for a single licence, to use in a CHIEF message.
Expand Down Expand Up @@ -136,8 +138,8 @@ def generate_lines_for_licence(licence: LicencePayload) -> Iterable[chieftypes._
)
controlled_by = "Q" # usage is controlled by quantity only
quantity = commodity.get("quantity")

if commodity["unit"] in LegacyUnitCodeMapping:
if commodity["unit"] in get_class_attributes(LegacyUnitCodeMapping):
qunit = LegacyUnitCodeMapping[commodity["unit"]]
else:
qunit = UnitMapping[commodity["unit"]]
Expand Down

0 comments on commit e306fb6

Please sign in to comment.