<commit_before>import re

from pyquery import PyQuery as pq
import requests

from . import models
from . import utils

BASE_FILER_URL_TEMPLATE = 'http://www.ethics.state.tx.us/php/filer.php?acct={filer_id}'
BASE_URL_TEMPLATE = 'http://204.65.203.5/public/{report_id}noadd.csv'


def fetch_raw_report(report_id):
    return requests.get(BASE_URL_TEMPLATE.format(report_id=report_id))


def get_report(report_id):
    raw_report = fetch_raw_report(report_id)
    return models.Report(raw_report=raw_report)


def compile_filing_data(filing_cell):
    data = [x.strip() for x in filing_cell.html().split('<br />')]

    report_due = re.sub(r'(st|nd|rd|th),', ',', data[3].split(':')[1].strip())
    report_filed = re.sub(r'(st|nd|rd|th),', ',', data[4].split(':')[1].strip())

    return {
        'filer_name': data[0].split(' - ')[0],
        'report_id': utils.parse_num_from_string(data[1]),
        'is_correction': 'Corrected Report' in data[1],
        'report_type': pq(data[2]).find('b').text(),
        'report_due': utils.string_to_date(report_due, format='%B %d, %Y'),
        'report_filed': utils.string_to_date(report_filed, format='%B %d, %Y'),
        'filing_method': data[5].split(':')[1].strip(),
    }


def fetch_filings_list(filer_id):
    p = pq(BASE_FILER_URL_TEMPLATE.format(filer_id=filer_id))
    rows = p('table[bordercolor="#CCCCCC"] tr')

    filings = []

    for row in rows.items():
        filings.append(compile_filing_data(row('td').eq(0)))

    return filings<commit_msg>Rename for consistency<commit_after>import re

from pyquery import PyQuery as pq
import requests

from . import models
from . import utils

BASE_FILER_URL_TEMPLATE = 'http://www.ethics.state.tx.us/php/filer.php?acct={filer_id}'
BASE_URL_TEMPLATE = 'http://204.65.203.5/public/{report_id}noadd.csv'


def fetch_raw_report(report_id):
    return requests.get(BASE_URL_TEMPLATE.format(report_id=report_id))


def get_report(report_id):
    raw_report = fetch_raw_report(report_id)
    return models.Report(raw_report=raw_report)


def compile_filing_data(filing_cell):
    data = [x.strip() for x in filing_cell.html().split('<br />')]

    report_due = re.sub(r'(st|nd|rd|th),', ',', data[3].split(':')[1].strip())
    report_filed = re.sub(r'(st|nd|rd|th),', ',', data[4].split(':')[1].strip())

    return {
        'filer_name': data[0].split(' - ')[0],
        'report_id': utils.parse_num_from_string(data[1]),
        'is_correction': 'Corrected Report' in data[1],
        'report_type': pq(data[2]).find('b').text(),
        'report_due': utils.string_to_date(report_due, format='%B %d, %Y'),
        'report_filed': utils.string_to_date(report_filed, format='%B %d, %Y'),
        'filing_method': data[5].split(':')[1].strip(),
    }


def get_filings_list(filer_id):
    p = pq(BASE_FILER_URL_TEMPLATE.format(filer_id=filer_id))
    rows = p('table[bordercolor="#CCCCCC"] tr')

    filings = []

    for row in rows.items():
        filings.append(compile_filing_data(row('td').eq(0)))

    return filings
{'fraction_non_alphanumeric': 0.18019211659489898, 'fraction_numerical': 0.01391189135475323, 'mean_word_length': 4.402504472271914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, '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': '2194347', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1143, 'n_words': 169}