def test_create_ok_simple(self): tempfile = get_temp_file(self) _create(tempfile, ['foo=57']) # check saved = load(tempfile) self.assertEqual(saved, {'foo': '57'})
def test_create_weird_equals(self): tempfile = get_temp_file(self) _create(tempfile, ['foo=', '=bleh', 'a=b=c']) # check saved = load(tempfile) self.assertEqual(saved, {'foo': '', '': 'bleh', 'a': 'b=c'})
def test_create_ok_several(self): tempfile = get_temp_file(self) _create(tempfile, ['foo=57', 'bar=bleh']) # check saved = load(tempfile) self.assertEqual(saved, {'foo': '57', 'bar': 'bleh'})
def test_sanity_sequence(self): tempfile = get_temp_file(self) # dump random stuff numbers = [random.randint(-3, 200) for _ in range(len(string.ascii_letters))] original_data = dict(zip(string.ascii_letters, numbers)) dump(original_data, tempfile) # load and compare retrieved_data = load(tempfile) self.assertEqual(original_data, retrieved_data)
def __init__(self): creds = infoauth.load(os.path.expanduser('~/.tmdb_auth')) self.api_key = creds['key']
('Nacionalidad', 'nacionalidad'), ('Estado Civil', 'ecivil'), ('Profesión', 'profesion'), ('Fecha Nacimiento', 'fnac'), ('Domicilio', 'domicilio'), ('Forma de pago', 'formadepago'), ('Datos que faltan', 'datosquefaltan'), ] # the row where the titles are TITLE_ROW = 8 # mail data MAIL_HOST = 'smtp.gmail.com' MAIL_PORT = 587 MAIL_TOKENS = infoauth.load( os.path.expanduser("~/.pyarac-presidencia-mail.tokens")) FROM = "Facundo Batista <{}>".format(MAIL_TOKENS['user']) MISSING = """\ Para completar los datos legales, necesito por favor que me pases/ajustes también lo siguiente: {missing_items} """ MAIN_TEXT = """\ Hola! ¡Gracias por completar el formulario! Te pido por favor que valides los datos: Nombre(s): {nombre}
import sys from urllib import request, parse import infoauth # fades import dropbox # fades from bs4 import BeautifulSoup # fades headers = { 'User-Agent': ( "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"), } socket.setdefaulttimeout(5) dropbox_secrets = infoauth.load("/home/facundo/.config/dropbox-secrets") def search_url(fpath): with open(fpath, "rt", encoding="utf8") as fh: content = fh.read() targets = re.findall(":target:(.*)\n", content) links = re.findall(r"`(.*?) \<(.*?)\>`", content, re.S) results = set() for target in targets: results.add(target.strip()) for description, link in links: results.add(link.strip())