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:
objectFrozen, 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. Usedataclasses.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_bomis applied by the high-level source readers, not byTransactions.parse.- Parameters:
- applicant_iban: bool¶
File the
?31sub-field of a structured:86:underapplicant_ibaninstead of prepending it toapplicant_name(issue #132, the 4.x behaviour).
- merge_keeps_values: bool¶
A structured
:86:emitsNonefor every sub-field it does not carry. With this on, such aNonenever replaces a value another tag already provided, so the:61:customer reference survives an:86:without aKREF.
- reversal_sign: bool¶
Give the
:61:reversal-of-credit markRCa 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+0100is 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", givingd_floor_limitandc_floor_limitand 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 valueTrue. Subclass fields are supported when the subclass constructor accepts all those keywords.
- __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)¶
- __repr__()¶
Return repr(self).