<commit_before>from utils import CanadianScraper, CanadianPerson as Person

import re

COUNCIL_PAGE = 'https://www.vsj.ca/conseil-municipal-et-comite-executif/membres-du-conseil-municipal'


class SaintJeromePersonScraper(CanadianScraper):
    def scrape(self):
        page = self.lxmlize(COUNCIL_PAGE, encoding='utf-8')
        councillors = page.xpath('//div[contains(@class," inner_member")]')
        assert len(councillors), 'No councillors found'

        for councillor in councillors:
            name = councillor.xpath('.//h2/text()')[0]
            district_data = councillor.xpath('.//div[contains(@class,"district")]/text()')[0]

            if 'Maire' in district_data:
                district = 'Saint-Jerome'
                role = 'Maire'
            else:
                district = 'District ' + re.sub('[^0-9]', '', district_data.split('ro')[-1])
                role = 'Conseiller'

            image = councillor.xpath('.//div[@class="portrait_single"]/img/@data-lazy-src')[0]
            contact = councillor.xpath('.//div[contains(@class,"phone")]/text()')[0]
            p = Person(primary_org='legislature',
                       name=name,
                       district=district,
                       role=role)
            p.add_source(COUNCIL_PAGE)
            p.image = image
            p.add_contact('voice', contact, 'legislature')
            p.add_contact('email', self.get_email(councillor))
            yield p<commit_msg>Put method call on one line. Simplify district calculation.<commit_after>from utils import CanadianScraper, CanadianPerson as Person

import re

COUNCIL_PAGE = 'https://www.vsj.ca/conseil-municipal-et-comite-executif/membres-du-conseil-municipal'


class SaintJeromePersonScraper(CanadianScraper):
    def scrape(self):
        page = self.lxmlize(COUNCIL_PAGE, encoding='utf-8')
        councillors = page.xpath('//div[contains(@class," inner_member")]')
        assert len(councillors), 'No councillors found'

        for councillor in councillors:
            name = councillor.xpath('.//h2/text()')[0]
            district = councillor.xpath('.//div[contains(@class,"district")]/text()')[0].replace('numéro ', '')

            if 'Maire' in district:
                district = 'Saint-Jérôme'
                role = 'Maire'
            else:
                role = 'Conseiller'

            image = councillor.xpath('.//div[@class="portrait_single"]/img/@data-lazy-src')[0]
            contact = councillor.xpath('.//div[contains(@class,"phone")]/text()')[0]

            p = Person(primary_org='legislature', name=name, district=district, role=role)
            p.add_source(COUNCIL_PAGE)
            p.image = image

            p.add_contact('voice', contact, 'legislature')
            p.add_contact('email', self.get_email(councillor))

            yield p
{'fraction_non_alphanumeric': 0.14442090395480225, 'fraction_numerical': 0.005296610169491525, 'mean_word_length': 2.4214975845410627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '941490', 'n_tokens_mistral': 936, 'n_tokens_neox': 871, 'n_words': 139}