示例#1
0
def check_candidates_for_updates(candidates, reference_path):
    '''
    Returns human-readable list of candidates added since last full data scrape. (Updated w/ fetch script)
    '''
    prev_candidates = open_json(reference_path)
    
    prev_ids = [c['candidate_id'] for c in prev_candidates]
    cur_ids = [c['candidate_id'] for c in candidates]
    
    added_candidates = [c for c in candidates if c['candidate_id'] not in prev_ids]
    dropped_candidates = [c for c in prev_candidates if c['candidate_id'] not in cur_ids]
    
    return {
        'added': [c['name'] for c in added_candidates],
        'dropped': [c['name'] for c in dropped_candidates],
    }
示例#2
0
def check_reports_for_updates(reports, archive_path):
    '''
    Returns human-readable list of reports added since last full data scrape.
    '''
    prev_reports = open_json(archive_path)
    
    prev_ids = [r['reportId'] for r in prev_reports]
    cur_ids = [r['reportId'] for r in reports]
    
    added_reports = [r for r in reports if r['reportId'] not in prev_ids]
    dropped_reports = [r for r in prev_reports if r['reportId'] not in cur_ids]
    
    use_keys = ['formTypeCode','candidateName','toDateStr']
    return {
        'added': [{ key: report[key] for key in use_keys } for report in added_reports],
        'dropped': [{ key: report[key] for key in use_keys } for report in dropped_reports],
    }
def check_candidates_for_updates(candidates, archive_path):
    '''
    Returns human-readable list of candidates added since last full data scrape.
    '''
    prev_candidates = open_json(archive_path)

    prev_ids = [c['candidateId'] for c in prev_candidates]
    cur_ids = [c['candidateId'] for c in candidates]

    added_candidates = [
        c for c in candidates if c['candidateId'] not in prev_ids
    ]
    dropped_candidates = [
        c for c in prev_candidates if c['candidateId'] not in cur_ids
    ]

    return {
        'added': [c['candidateName'] for c in added_candidates],
        'dropped': [c['candidateName'] for c in dropped_candidates],
    }
示例#4
0
import automaton as atm
import functions as fnc

epsilon = "&"
verifi = "?"

arq = fnc.open_json()  # abre arquivo
pilha = atm.Pilha()  # criando pilha do automato
words_to_aprove = arq.get("aprovar")  # lote de palavras para aprovar
words_to_reject = arq.get("rejeitar")  # lote de palavras para rejeitar
init_state = arq.get("init_state")  # estado inicial
final_states = arq.get("final_states")  # estados finais
actual_state = atm.CurrentState(init_state)
mostrar_pilha = arq.get("mostrar_pilha")
evolucao_estados = arq.get("evolucao_estados")

all_states = []
for state_item in arq["all_states"]:
    transitions = []
    for transition_item in state_item.get("transitions"):
        transition = atm.Transition(transition_item.get("letter"),
                                    transition_item.get("unstack"),
                                    transition_item.get("stack_up"),
                                    transition_item.get("goes_to"))
        transitions.append(transition)
    state = atm.State(state_item.get("state"), transitions)
    all_states.append(state)

if mostrar_pilha == "True" and evolucao_estados == "True":
    user_option = 0
elif mostrar_pilha == "True" and evolucao_estados == "False":
示例#5
0
import csv
import logging
import praw
import sys
import random
import traceback
import youtube_dl
import asyncio

from operator import itemgetter
from functions import update_covid_database, write_json, contains_banned_words, open_json

stderr = sys.stderr
sys.stderr = open('files/discord.log', 'w')

DATA = open_json()
LEVELS = [int(math.pow(x, 1.5) * 20) for x in range(100)]
BANNED_WORDS = (  #open('files/swearWords.txt', 'r').read().replace(" ", "").split(",") +
    open('files/swearWordsPL.txt',
         'r').read().replace("'", "").replace("\n", "").replace(" ",
                                                                "").split(","))
CURSE_PHRASES = [
    "Watch your mouth son!", "Yo yooo chill out!",
    "How about we take our time and try to rephrase that?",
    "Bad words, you use - rephrase you should ~ Yoda Master", "You mad bruh?",
    "I mean, that ain't goin' through brother..."
]

# Setting up discord loggers
logger = logging.getLogger('discord')
logger.setLevel(logging.DEBUG)