<commit_before>import re

from datetime import date

from . import base
from . import mixins

from .. import cleaver


class TransformedRecord(
    mixins.GenericCompensationMixin,
    mixins.GenericDepartmentMixin, mixins.GenericIdentifierMixin,
    mixins.GenericJobTitleMixin, mixins.GenericPersonMixin,
    mixins.MembershipMixin, mixins.OrganizationMixin, mixins.PostMixin,
        mixins.RaceMixin, mixins.LinkMixin, base.BaseTransformedRecord):

    MAP = {
        'last_name': '<NAME>',
        'first_name': '<NAME>',
        'department': 'AGENCY NAME',
        'job_title': 'CLASS TITLE',
        'gender': 'GENDER',
        'race': 'ETHNICITY',
        'hire_date': 'HIRE DATE',
        'compensation': 'ANNUAL SALARY',
        'compensation_type': 'EMPLOYEE TYPE',
        'agency_number': 'AGENCY',
        'state_number': 'STATE NUMBER',
    }

    NAME_FIELDS = ('first_name', 'last_name', )

    gender_map = {'FEMALE': 'FEMALE', 'MALE': 'MALE'}

    # State of Texas uses these employment status codes:
    description_map = {
        'URP': 'UNCLASSIFIED REGULAR PART-TIME',
        'URF': 'UNCLASSIFIED REGULAR FULL-TIME',
        'UTP': 'UNCLASSIFIED TEMPORARY PART-TIME',
        'UTF': 'UNCLASSIFIED TEMPORARY FULL-TIME',
        'ERF': 'EXEMPT REGULAR FULL-TIME',
        'CRF': 'CLASSIFIED REGULAR FULL-TIME',
        'CRP': 'CLASSIFIED REGULAR PART-TIME',
        'CTF': 'CLASSIFIED TEMPORARY FULL-TIME',
        'CTP': 'CLASSIFIED TEMPORARY PART-TIME',
    }
    status_map = {'F': 'FT', 'P': 'PT'}

    ORGANIZATION_NAME = 'State of Texas'

    ORGANIZATION_CLASSIFICATION = 'State'

    DATE_PROVIDED = date(2016, 2, 29)

    URL = ('http://raw.texastribune.org.s3.amazonaws.com/state_of_texas/'
           'salaries/2016-02/USPS_SPRS_ASOFJAN312016_.xlsx')

    @property
    def is_valid(self):
        # Adjust to return False on invalid fields.  For example:
        return self.last_name.strip() != ''

    def get_cleaved_first_or_last(self, name):
        try:
            return str(cleaver.EmployeeNameCleaver(name).parse())
        except IndexError:
            return name

    @property
    def person(self):
        data = {
            'family_name': self.get_cleaved_first_or_last(
                self.last_name.strip()),<commit_msg>Change organization name to account for last year's rename<commit_after>import re

from datetime import date

from . import base
from . import mixins

from .. import cleaver


class TransformedRecord(
    mixins.GenericCompensationMixin,
    mixins.GenericDepartmentMixin, mixins.GenericIdentifierMixin,
    mixins.GenericJobTitleMixin, mixins.GenericPersonMixin,
    mixins.MembershipMixin, mixins.OrganizationMixin, mixins.PostMixin,
        mixins.RaceMixin, mixins.LinkMixin, base.BaseTransformedRecord):

    MAP = {
        'last_name': '<NAME>',
        'first_name': '<NAME>',
        'department': 'AGENCY NAME',
        'job_title': 'CLASS TITLE',
        'gender': 'GENDER',
        'race': 'ETHNICITY',
        'hire_date': 'HIRE DATE',
        'compensation': 'ANNUAL SALARY',
        'compensation_type': 'EMPLOYEE TYPE',
        'agency_number': 'AGENCY',
        'state_number': 'STATE NUMBER',
    }

    NAME_FIELDS = ('first_name', 'last_name', )

    gender_map = {'FEMALE': 'FEMALE', 'MALE': 'MALE'}

    # State of Texas uses these employment status codes:
    description_map = {
        'URP': 'UNCLASSIFIED REGULAR PART-TIME',
        'URF': 'UNCLASSIFIED REGULAR FULL-TIME',
        'UTP': 'UNCLASSIFIED TEMPORARY PART-TIME',
        'UTF': 'UNCLASSIFIED TEMPORARY FULL-TIME',
        'ERF': 'EXEMPT REGULAR FULL-TIME',
        'CRF': 'CLASSIFIED REGULAR FULL-TIME',
        'CRP': 'CLASSIFIED REGULAR PART-TIME',
        'CTF': 'CLASSIFIED TEMPORARY FULL-TIME',
        'CTP': 'CLASSIFIED TEMPORARY PART-TIME',
    }
    status_map = {'F': 'FT', 'P': 'PT'}

    ORGANIZATION_NAME = 'State Comptroller Payroll'

    ORGANIZATION_CLASSIFICATION = 'State'

    DATE_PROVIDED = date(2016, 2, 29)

    URL = ('http://raw.texastribune.org.s3.amazonaws.com/state_of_texas/'
           'salaries/2016-02/USPS_SPRS_ASOFJAN312016_.xlsx')

    @property
    def is_valid(self):
        # Adjust to return False on invalid fields.  For example:
        return self.last_name.strip() != ''

    def get_cleaved_first_or_last(self, name):
        try:
            return str(cleaver.EmployeeNameCleaver(name).parse())
        except IndexError:
            return name

    @property
    def person(self):
        data = {
            'family_name': self.get_cleaved_first_or_last(
                self.last_name.strip()),
{'fraction_non_alphanumeric': 0.1246207195491981, 'fraction_numerical': 0.008669267446900737, 'mean_word_length': 2.8298755186721993, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5005182', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1520, 'n_words': 325}