<commit_before># -*- coding: utf-8 -*-
import sys
import os
import signal
from datetime import datetime, timedelta

import configdb

from ooop import OOOP
from consolemsg import error
from utils import *
from validation_utils import adelantar_polissa_endarerida
from display import *

def remove_modmeter_lect(meters, lects):
    dates_out = {meter['data_baixa']: meter['id'] for meter in meters if meter['data_baixa']}
    return [lect for lect in lects if not((lect['name'] in dates_out.keys())
            and not(dates_out[lect['name']] == lect['comptador'][0]))]


def fix_measure(O, polissa_id, lects, last_idx, _last_idx, _prev_idx, offset, kWh_day_db, n_days_02):
    quarantine = []
    kWh_day = (lects[offset]['lectura']-lects[last_idx+offset]['lectura'])/float(n_days_02)

    n_days_12 = (datetime.strptime(lects[_prev_idx+offset]['name'], '%Y-%m-%d') -
                 datetime.strptime(lects[_last_idx+offset]['name'], '%Y-%m-%d')).days

    if ((kWh_day_db == 0) and not(kWh_day == 0)) \
        or (not(kWh_day_db == 0) and ((kWh_day/kWh_day_db) > 5)):
        quarantine.append(polissa_id)

    lect_old = lects[_prev_idx+offset]['lectura']
    lects[_prev_idx+offset]['lectura'] = lects[_last_idx+offset]['lectura']+n_days_12*kWh_day
    observacions = 'R. {lect_old}\n{observacions}'.format(**{'lect_old':lect_old,
                                                             'observacions':lects[_prev_idx+offset]['observacions']})

    measures_id = [lects[_prev_idx+offset]['id']]
    measures_value = {'lectura': lects[_prev_idx+offset]['lectura'],
                      'observacions': '{observacions}'.format(**locals())}
    update_measures(O, measures_id, measures_value, pool=False)
<commit_msg>encoding fix<commit_after># -*- coding: utf-8 -*-
import sys
import os
import signal
from datetime import datetime, timedelta

import configdb

from ooop import OOOP
from consolemsg import error
from utils import *
from validation_utils import adelantar_polissa_endarerida
from display import *

def remove_modmeter_lect(meters, lects):
    dates_out = {meter['data_baixa']: meter['id'] for meter in meters if meter['data_baixa']}
    return [lect for lect in lects if not((lect['name'] in dates_out.keys())
            and not(dates_out[lect['name']] == lect['comptador'][0]))]


def fix_measure(O, polissa_id, lects, last_idx, _last_idx, _prev_idx, offset, kWh_day_db, n_days_02):
    quarantine = []
    kWh_day = (lects[offset]['lectura']-lects[last_idx+offset]['lectura'])/float(n_days_02)

    n_days_12 = (datetime.strptime(lects[_prev_idx+offset]['name'], '%Y-%m-%d') -
                 datetime.strptime(lects[_last_idx+offset]['name'], '%Y-%m-%d')).days

    if ((kWh_day_db == 0) and not(kWh_day == 0)) \
        or (not(kWh_day_db == 0) and ((kWh_day/kWh_day_db) > 5)):
        quarantine.append(polissa_id)

    lect_old = lects[_prev_idx+offset]['lectura']
    lects[_prev_idx+offset]['lectura'] = lects[_last_idx+offset]['lectura']+n_days_12*kWh_day
    observacions = 'R. {lect_old}\n{observacions}'.format(**{'lect_old':lect_old,
                                                             'observacions':lects[_prev_idx+offset]['observacions'].encode('utf-8')})

    measures_id = [lects[_prev_idx+offset]['id']]
    measures_value = {'lectura': lects[_prev_idx+offset]['lectura'],
                      'observacions': '{observacions}'.format(**locals())}
    update_measures(O, measures_id, measures_value, pool=False)

{'fraction_non_alphanumeric': 0.15468975468975468, 'fraction_numerical': 0.00836940836940837, 'mean_word_length': 4.097058823529411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1754837', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1189, 'n_words': 219}