fjuniorr / flowmapper

Mappings between elementary flows
MIT License
0 stars 1 forks source link

Store original field names from field mapping in Flow class #18

Closed fjuniorr closed 7 months ago

fjuniorr commented 7 months ago

Currently I pass a fields object containing field mapping information all over the place.

It make sense to store this information under the Flow class to simplify functions calls and simplify access. So for example format_match_result could be written as:


def format_match_result(s: Flow, t: Flow, memo: str, is_match: bool):
    if is_match:
        result = {
                'source': {
                    s.fields['uuid']: s.uuid,
                    s.fields['name']: s.name,
                    s.fields['context']: s.context.full
                },
                'target': {
                    t.fields['uuid']: t.uuid,
                },
                'conversionFactor': 1 if s.unit == t.unit else '?',
                'MemoMapper': memo
            }
    else:
        result = None
    return result