<commit_before>#!/usr/bin/env python
#-*- coding:utf-8 -*-

# TODO
# testar tudo isso, deveria ter usado TDD nesse projeto :(

from crawl import Crawl
import threading
from datetime import datetime
from wrapdb import Db

def fillDict(valDict):
    """
        retorna valDict com os valeres preenchidos com a respectiva data de hoje
    """
    ano = "%Y"
    mes = "%m"
    dia = "%d"
    nowDate = datetime.now()
    valDict["cmbAno"] = int(nowDate.strftime(ano))
    valDict["cmbMes"] = int(nowDate.strftime(mes))
    valDict["cmbDia"] = int(nowDate.strftime(dia))
    

class Slave(object):

    URL = "http://www2.sabesp.com.br/mananciais/DivulgacaoSiteSabesp.aspx"
    mainData = {'cmbAno': None,'cmbMes': None,'cmbDia': None}
    def __init__(self):
        self.crawler = Crawl(URL)
        self.db      = Db() 
        
    def work(self):
        dayCat = fillDict(self.mainData)
        data = self.crawler.getForm(dayCat)
        self.db.save(data)
        threading.Timer(86400, self.work).start() # se repete a cada 24h
        

if __name__ == '__main__':
    Slave().work()

        



    <commit_msg>fix the erro with fillDict<commit_after>#!/usr/bin/env python
#-*- coding:utf-8 -*-

# TODO
# 

from crawl import Crawl
import threading
from datetime import datetime
from wrapdb import Db

def fillDict(valDict):
    """
        retorna dicionario com os valeres preenchidos com a respectiva data de hoje
    """
    ano = "%Y"
    mes = "%m"
    dia = "%d"
    nowDate = datetime.now()
    copy = valDict
    copy["cmbAno"] = int(nowDate.strftime(ano))
    copy["cmbMes"] = int(nowDate.strftime(mes))
    copy["cmbDia"] = int(nowDate.strftime(dia))
    return copy
    

class Slave(object):

    URL = "http://www2.sabesp.com.br/mananciais/DivulgacaoSiteSabesp.aspx"
    mainData = {'cmbAno': None,'cmbMes': None,'cmbDia': None}
    def __init__(self):
        self.crawler = Crawl(self.URL)
        self.db      = Db() 
        
    def work(self):
        dayCat = fillDict(self.mainData)
        data = self.crawler.getForm(dayCat)
        self.db.save(data)
        threading.Timer(86400, self.work).start() # se repete a cada 24h
        

if __name__ == '__main__':
    Slave().work()
    
        



    
{'fraction_non_alphanumeric': 0.13569189431258397, 'fraction_numerical': 0.00806090461262875, 'mean_word_length': 2.5801282051282053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4504775', 'n_tokens_mistral': 845, 'n_tokens_neox': 802, 'n_words': 175}