mt940.options

Immutable switches for parser behaviour changes.

All ten Options fields default to False. The switches preserve legacy output for affected fields unless explicitly enabled. Pass an instance to mt940.parse(), mt940.parse_statements() or mt940.models.Transactions. Options.all() enables every currently defined switch.

Example

>>> import mt940
>>> options = mt940.Options(reversal_sign=True, applicant_iban=True)
>>> options.reversal_sign, options.strip_bom
(True, False)
>>> mt940.Options.all().strip_bom
True
class mt940.options.Options(applicant_iban=False, merge_keeps_values=False, reversal_sign=False, case_insensitive_marks=False, timezone_offset=False, unbounded_details=False, non_swift_free_text=False, floor_limit_blank_mark=False, strip_bom=False, gvc_leading_text=False)[source]

Bases: object

Frozen, slotted configuration for ten opt-in parser behaviours.

Each constructor keyword is a boolean field described below. Omitted fields remain False. Instances can be shared between collections because fields cannot be reassigned. Use dataclasses.replace() to make an instance with selected fields changed.

No field changes tag registration or processor ordering. Options are read from the collection while its tags and processors run. strip_bom is applied by the high-level source readers, not by Transactions.parse.

Parameters:
  • applicant_iban (bool)

  • merge_keeps_values (bool)

  • reversal_sign (bool)

  • case_insensitive_marks (bool)

  • timezone_offset (bool)

  • unbounded_details (bool)

  • non_swift_free_text (bool)

  • floor_limit_blank_mark (bool)

  • strip_bom (bool)

  • gvc_leading_text (bool)

applicant_iban: bool

File the ?31 sub-field of a structured :86: under applicant_iban instead of prepending it to applicant_name (issue #132, the 4.x behaviour).

merge_keeps_values: bool

A structured :86: emits None for every sub-field it does not carry. With this on, such a None never replaces a value another tag already provided, so the :61: customer reference survives an :86: without a KREF.

reversal_sign: bool

Give the :61: reversal-of-credit mark RC a negative amount, like the debit it is (issue #130).

case_insensitive_marks: bool

Treat lowercase debit/credit marks (d, c, rc, rd) like their uppercase forms when signing an amount. The tag patterns already accept them.

timezone_offset: bool

Read the :13D: offset as hours and minutes, so +0100 is one hour. 5.0.0 read the digits as a minute count.

unbounded_details: bool

Keep :86: details of any length. 5.0.0 silently truncated them after nine chunks of 65 characters.

non_swift_free_text: bool

Keep the content of :NS: lines that do not start with a two-digit sub-tag. 5.0.0 replaced such a line with an empty one when it followed a sub-tag line.

floor_limit_blank_mark: bool

Treat a blank :34F: debit/credit mark as "both", giving d_floor_limit and c_floor_limit and a statement currency. 5.0.0 produced a key with a leading space.

strip_bom: bool

Drop a leading byte-order mark, so the first :20: tag is recognised. 5.0.0 kept it and lost that tag.

gvc_leading_text: bool

Do not interpret a + in the first four purpose characters as a GVC keyword terminator. This preserves free text that the legacy empty-key match can drop. Text before a genuine keyword is still dropped.

classmethod all()[source]

Construct an instance with every declared field set to True.

Every name returned by names() is passed to the constructor as a keyword with value True. Subclass fields are supported when the subclass constructor accepts all those keywords.

Returns:

An instance of the called class. For Options this enables all ten switches.

Raises:

TypeError -- The constructor rejects a field keyword, for example when a subclass adds a dataclass field with init=False.

Return type:

Options

classmethod names()[source]

Return dataclass field names in declaration order.

Returns:

A tuple of names, including inherited fields when called on a dataclass subclass. The tuple can be used to enumerate supported switches without maintaining a second list.

Return type:

tuple[str, ...]

__eq__(other)

Return self==value.

__getstate__()

Helper for pickle.

__hash__()

Return hash(self).

__init__(applicant_iban=False, merge_keeps_values=False, reversal_sign=False, case_insensitive_marks=False, timezone_offset=False, unbounded_details=False, non_swift_free_text=False, floor_limit_blank_mark=False, strip_bom=False, gvc_leading_text=False)
Parameters:
  • applicant_iban (bool)

  • merge_keeps_values (bool)

  • reversal_sign (bool)

  • case_insensitive_marks (bool)

  • timezone_offset (bool)

  • unbounded_details (bool)

  • non_swift_free_text (bool)

  • floor_limit_blank_mark (bool)

  • strip_bom (bool)

  • gvc_leading_text (bool)

Return type:

None

__repr__()

Return repr(self).