<commit_before>#!/usr/bin/env python3

from dateutil import parser

from statsSend.teamCity.teamCityConnection import TeamCityConnection
from statsSend.teamCity.teamCityUrlBuilder import TeamCityUrlBuilder
from statsSend.teamCity.teamCityProject import TeamCityProject

class TeamCityStatisticsSender:
    def __init__(self, cfg, reporter):
        self.page_size = int(cfg['page_size'])
        connection = TeamCityConnection(cfg['user'], cfg['password'])
        url_builder = TeamCityUrlBuilder(cfg['server_url'], cfg['api_url_prefix'])
        self.project = TeamCityProject(cfg['project_id'], connection, url_builder, self.page_size)
        self.since_timestamp = parser.parse(cfg['since_timestamp']).strftime('%Y%m%dT%H%M%S%z')
        self.reporter = reporter

    async def send(self):
        if ("report_categories" in dir(self.reporter)):
            categories = [build_configuration.toCategory() async for build_configuration in self.project.retrieve_build_configurations()]
            self.reporter.report_categories(categories)

        async for build_configuration in self.project.retrieve_build_configurations():
            async for build_run in build_configuration.retrieve_build_runs_since_timestamp(self.since_timestamp):
                job = build_run.toJob()
                self.reporter.report_job(job)<commit_msg>Rename cfg to settings<commit_after>#!/usr/bin/env python3

from dateutil import parser

from statsSend.teamCity.teamCityConnection import TeamCityConnection
from statsSend.teamCity.teamCityUrlBuilder import TeamCityUrlBuilder
from statsSend.teamCity.teamCityProject import TeamCityProject

class TeamCityStatisticsSender:
    def __init__(self, settings, reporter):
        self.page_size = int(settings['page_size'])
        connection = TeamCityConnection(settings['user'], settings['password'])
        url_builder = TeamCityUrlBuilder(settings['server_url'], settings['api_url_prefix'])
        self.project = TeamCityProject(settings['project_id'], connection, url_builder, self.page_size)
        self.since_timestamp = parser.parse(settings['since_timestamp']).strftime('%Y%m%dT%H%M%S%z')
        self.reporter = reporter

    async def send(self):
        if ("report_categories" in dir(self.reporter)):
            categories = [build_configuration.toCategory() async for build_configuration in self.project.retrieve_build_configurations()]
            self.reporter.report_categories(categories)

        async for build_configuration in self.project.retrieve_build_configurations():
            async for build_run in build_configuration.retrieve_build_runs_since_timestamp(self.since_timestamp):
                job = build_run.toJob()
                self.reporter.report_job(job)
{'fraction_non_alphanumeric': 0.09492515516611902, 'fraction_numerical': 0.0007301935012778386, 'mean_word_length': 4.436507936507937, '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': '5099421', 'n_tokens_mistral': 745, 'n_tokens_neox': 733, 'n_words': 140}