Beispiel #1
0
def _inter_auth_h(parsed, wb):
    print '### inter_auth_h'
    for i in range(len(parsed[INTERNATIONAL_AUTHORITIES])):
        ia = entities.translate_fields(
            parsed[INTERNATIONAL_AUTHORITIES][i], entities.international_authority)
        parsed[INTERNATIONAL_AUTHORITIES][i] = InternationalAuthority(**ia)
    return parsed
Beispiel #2
0
def _event_h(parsed, wb):
    print '### event_h'
    parsed = _pre_handle(parsed, wb,
        RELEASE_TYPES, LOCATIONS, PRISONS, SOURCES, ACTORS, RIGHTS_VIOLATIONS)
    for i in range(len(parsed[EVENTS])):
        event = entities.translate_fields(parsed[EVENTS][i], entities.event)
        event['release_types'] = _from_indices(event['release_types'], parsed[RELEASE_TYPES])
        event['locations'] = _from_indices(event['locations'], parsed[LOCATIONS])
        event['prisons'] = _from_indices(event['prisons'], parsed[PRISONS])
        event['sources'] = _from_indices(event['sources'], parsed[SOURCES])
        event['witnesses'] = _from_indices(event['witnesses'], parsed[ACTORS])
        event['victims'] = _from_indices(event['victims'], parsed[ACTORS])
        event['perpetrators'] = _from_indices(event['perpetrators'], parsed[ACTORS])
        event['event_types'] = _from_indices(
            event['event_types'], parsed[RIGHTS_VIOLATIONS])
        event['event_start'] = _excel_parse_date(event['event_start'], wb)
        event['event_end'] = _excel_parse_date(event['event_end'], wb)
        event['report_date'] = _excel_parse_date(event['report_date'], wb)
        event['psych_assist'] = event['psych_assist'].lower() == YES
        event['material_assist'] = event['material_assist'].lower() == YES
        event['was_activist'] = event['was_activist'].lower() == YES
        event['victim_is_complainant'] = event['victim_is_complainant'].lower() == YES
        event['allow_storage'] = event['allow_storage'].lower() == YES
        event['allow_publishing'] = event['allow_publishing'].lower() == YES
        event['allow_representation'] = event['allow_representation'].lower() == YES
        event['data_is_sensitive'] = event['data_is_sensitive'].lower() == YES
        parsed[EVENTS][i] = Event(**event)
    return parsed
Beispiel #3
0
def _source_h(parsed, wb):
    print '### source_h'
    parsed = _pre_handle(parsed, wb, ORGANISATIONS)
    for i in range(len(parsed[SOURCES])):
        source = entities.translate_fields(parsed[SOURCES][i], entities.source)
        source['organisations'] = _from_indices(source['organisations'], parsed[ORGANISATIONS])
        parsed[SOURCES][i] = Source(**source)
    return parsed
Beispiel #4
0
def _organisation_h(parsed, wb):
    print '### organisation_h'
    parsed = _pre_handle(parsed, wb, LOCATIONS)
    for i in range(len(parsed[ORGANISATIONS])):
        organisation = entities.translate_fields(parsed[ORGANISATIONS][i], entities.organisation)
        organisation['locations'] = _from_indices(organisation['locations'], parsed[LOCATIONS])
        parsed[ORGANISATIONS][i] = Organisation(**organisation)
    return parsed
Beispiel #5
0
def _report_h(parsed, wb):
    print '### report_h'
    parsed = _pre_handle(parsed, wb, EVENTS)
    for i in range(len(parsed[REPORTS])):
        report = entities.translate_fields(parsed[REPORTS][i], entities.report)
        report['events'] = _from_indices(report['events'], parsed[EVENTS])
        parsed[REPORTS][i] = Report(**report)
    return parsed 
Beispiel #6
0
def _prison_h(parsed, wb):
    print '### prison_h'
    parsed = _pre_handle(parsed, wb, LOCATIONS, PRISON_TYPES)
    for i in range(len(parsed[PRISONS])):
        prison = entities.translate_fields(parsed[PRISONS][i], entities.prison)
        prison['locations'] = _from_indices(prison['locations'], parsed[LOCATIONS])
        prison['prison_types'] = _from_indices(prison['prison_types'], parsed[PRISON_TYPES])
        parsed[PRISONS][i] = Prison(**prison)
    return parsed
Beispiel #7
0
def _action_h(parsed, wb):
    print '### action_h'
    parsed = _pre_handle(parsed, wb, STATE_AUTHORITIES, INTERNATIONAL_AUTHORITIES, EVENTS)
    for i in range(len(parsed[ACTIONS])):
        action = entities.translate_fields(parsed[ACTIONS][i], entities.action)
        action['state_bodies_approached'] = _from_indices(
            action['state_bodies_approached'], parsed[STATE_AUTHORITIES])
        action['international_bodies_approached'] = _from_indices(
            action['international_bodies_approached'], parsed[INTERNATIONAL_AUTHORITIES])
        action['events'] = _from_indices(action['events'], parsed[EVENTS])
        parsed[ACTIONS][i] = Action(**action)
    return parsed
Beispiel #8
0
def _actor_h(parsed, wb):
    print '### actor_h'
    parsed = _pre_handle(parsed, wb, ORGANISATIONS, PROFESSIONS, LOCATIONS)
    for i in range(len(parsed[ACTORS])):
        actor = entities.translate_fields(parsed[ACTORS][i], entities.actor)
        actor['organisations'] = _from_indices(actor['organisations'], parsed[ORGANISATIONS])
        actor['professions'] = _from_indices(actor['professions'], parsed[PROFESSIONS])
        actor['locations'] = _from_indices(actor['locations'], parsed[LOCATIONS])
        actor['birth_date'] = _excel_parse_date(actor['birth_date'], wb)
        actor['gender'] = actor['gender'].lower() == MALE # Not trying to be sexist, just efficient.
        actor['is_activist'] = actor['is_activist'].lower() == YES
        parsed[ACTORS][i] = Actor(**actor)
    return parsed
Beispiel #9
0
def _prison_type_h(parsed, wb):
    print '### prison_type_h'
    for i in range(len(parsed[PRISON_TYPES])):
        pt = entities.translate_fields(parsed[PRISON_TYPES][i], entities.prison_type)
        parsed[PRISON_TYPES][i] = PrisonType(**pt)
    return parsed
Beispiel #10
0
def _release_type_h(parsed, wb):
    print '### release_type_h'
    for i in range(len(parsed[RELEASE_TYPES])):
        rt = entities.translate_fields(parsed[RELEASE_TYPES][i], entities.release_type)
        parsed[RELEASE_TYPES][i] = ReleaseType(**rt)
    return parsed
Beispiel #11
0
def _event_type_h(parsed, wb):
    print '### event_type_h'
    for i in range(len(parsed[RIGHTS_VIOLATIONS])):
        rv = entities.translate_fields(parsed[RIGHTS_VIOLATIONS][i], entities.event_type)
        parsed[RIGHTS_VIOLATIONS][i] = EventType(**rv)
    return parsed
Beispiel #12
0
def _location_h(parsed, wb):
    print '### location_h'
    for i in range(len(parsed[LOCATIONS])):
        location = entities.translate_fields(parsed[LOCATIONS][i], entities.location)
        parsed[LOCATIONS][i] = Location(**location)
    return parsed
Beispiel #13
0
def _profession_h(parsed, wb):
    print '### profession_h'
    for i in range(len(parsed[PROFESSIONS])):
        profession = entities.translate_fields(parsed[PROFESSIONS][i], entities.profession)
        parsed[PROFESSIONS][i] = Profession(**profession)
    return parsed
Beispiel #14
0
def _state_auth_h(parsed, wb):
    print '### state_auth_h'
    for i in range(len(parsed[STATE_AUTHORITIES])):
        sa = entities.translate_fields(parsed[STATE_AUTHORITIES][i], entities.state_authority)
        parsed[STATE_AUTHORITIES][i] = StateAuthority(**sa)
    return parsed