<commit_before># Return parser functions for generic elements
from iati import models
import iati_codelists.models as codelist_models
from iati.parser.exceptions import RequiredFieldError
import functools


def provider_org(self, parent_model, provider_model, fk_name):
    """
    parent_model: the model to which the provider_org will be applied
    provider_model: The provider_org model
    fk_name: the name of the foreign key back to the parent_model
    """

    def func(element):
        ref = element.attrib.get('ref', '')
        org_type = self.get_or_none(codelist_models.OrganisationType, code=element.attrib.get('type'))
        provider_activity_id = element.attrib.get('provider-activity-id', '').strip()
        provider_activity = self.get_or_none(models.Activity, iati_identifier=provider_activity_id)

        normalized_ref = self._normalize(ref)
        organisation = self.get_or_none(models.Organisation, pk=ref)

        setattr(provider_model, fk_name, parent_model)
        provider_model.ref = ref
        provider_model.type = org_type
        provider_model.normalized_ref = normalized_ref
        provider_model.organisation = organisation
        provider_model.provider_activity_ref = provider_activity_id
        provider_model.provider_activity = provider_activity

        self.register_model(type(provider_model).__name__, provider_model)

        return element

    return func

def receiver_org(self, parent_model, receiver_model, fk_name):
    """
    parent_model: the model to which the receiver_org will be applied
    receiver_model: The receiver_org model
    fk_name: the name of the foreign key back to the parent_model
    """

    def func(element):
        ref = element.attrib.get('ref', '')
        org_type = self.get_or_none(codelist_models.OrganisationType, code=element.attrib.get('type'))
        receiver_activity_id = element.attrib.get('receiver-activity-id', '').strip()<commit_msg>trim receiver/provider activity-id<commit_after># Return parser functions for generic elements
from iati import models
import iati_codelists.models as codelist_models
from iati.parser.exceptions import RequiredFieldError
import functools


def provider_org(self, parent_model, provider_model, fk_name):
    """
    parent_model: the model to which the provider_org will be applied
    provider_model: The provider_org model
    fk_name: the name of the foreign key back to the parent_model
    """

    def func(element):
        ref = element.attrib.get('ref', '')
        org_type = self.get_or_none(codelist_models.OrganisationType, code=element.attrib.get('type'))
        provider_activity_id = element.attrib.get('provider-activity-id', None)
        if provider_activity_id:
            provider_activity_id = provider_activity_id.strip()
        provider_activity = self.get_or_none(models.Activity, iati_identifier=provider_activity_id)

        normalized_ref = self._normalize(ref)
        organisation = self.get_or_none(models.Organisation, pk=ref)

        setattr(provider_model, fk_name, parent_model)
        provider_model.ref = ref
        provider_model.type = org_type
        provider_model.normalized_ref = normalized_ref
        provider_model.organisation = organisation
        provider_model.provider_activity_ref = provider_activity_id
        provider_model.provider_activity = provider_activity

        self.register_model(type(provider_model).__name__, provider_model)

        return element

    return func

def receiver_org(self, parent_model, receiver_model, fk_name):
    """
    parent_model: the model to which the receiver_org will be applied
    receiver_model: The receiver_org model
    fk_name: the name of the foreign key back to the parent_model
    """

    def func(element):
        ref = element.attrib.get('ref', '')
        org_type = self.get_or_none(codelist_models.OrganisationType, code=element.attrib.get('type'))
        receiver_activity_id = element.attrib.get('receiver-activity-id', None)
        if receiver_activity_id:
            receiver_activity_id = receiver_activity_id.strip()
{'fraction_non_alphanumeric': 0.07867090153921329, 'fraction_numerical': 0.0, 'mean_word_length': 3.8564650059311982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4318072', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1161, 'n_words': 269}