How to use parsed_name method in avocado

Best Python code snippet using avocado_python

links.py

Source:links.py Github

copy

Full Screen

1import requests as rq2import urllib.parse as url3import json4import AdvancedHTMLParser56html = AdvancedHTMLParser.AdvancedHTMLParser()789def get_anime_info(browse):10 html.parseStr(browse)11 lista = html.getElementsByClassName("Anime alt B")12 if len(lista) == 0:13 print("No existe ningun anime con ese nombre")14 return None15 else:16 for i in range(len(lista)):17 a = lista[i].getChildren()[0].getChildren()[1].innerHTML18 print(i+1, a)19 choice = int(input("Selecione un título: "))20 link = lista[choice-1].getChildren()[0].getAttribute("href")21 name = lista[choice-1].getChildren()[0].getChildren()[1].innerHTML22 return [link, name]232425def get_episodes(anime):26 text = anime.text27 epiindex1 = text.find("var episodes")28 epiindex1 += text[epiindex1:].find("=")29 epiindex2 = text[epiindex1:].find(";")30 episodes = eval(text[epiindex1+2:epiindex2+epiindex1])31 episodes.reverse()32 return len(episodes)333435def links(serie):36 try:37 from control import current_download_file, register_log_file38 browse = rq.get("https://animeflv.net/browse?q="+serie).text39 l = get_anime_info(browse)40 print("Descargando:", l[1])41 if l == None:42 return None43 else:44 link = l[0]45 name = l[1]46 parsed_name = link.split("/")[2]47 try:48 anime = rq.get("https://animeflv.net"+link)49 print("Cuenta con:", get_episodes(anime), "episodios")50 except:51 print("Hubo un problema al intentar acceder a la pagina del anime")52 with open(register_log_file, "r") as file:53 reg_log = json.load(file)54 if not parsed_name in reg_log['animes']:55 reg_log['animes'][parsed_name] = {'chapters': {}, 'name': name}56 ongoing = {57 'chapters': {},58 'name': name,59 'parsed_name': parsed_name60 }61 ongoing['first'] = int(input("Primer capitulo a descargar: "))62 ongoing['last'] = int(input("Ultimo capitulo: "))63 if anime.status_code != 200:64 print("Al parecer hay un error en el nombre, intenta de nuevo")65 return False66 else:67 for i in range(ongoing['first'], ongoing['last'] + 1):68 if str(i) in reg_log['animes'][parsed_name]['chapters']:69 ongoing['chapters'][i] = reg_log['animes'][parsed_name]['chapters'][str(70 i)]71 else:72 try:73 chapter = rq.get(74 "https://animeflv.net/ver/"+parsed_name+"-"+str(i))75 except:76 print("Hubo un problema al intentar acceder al capitulo")77 if (chapter.status_code != 200):78 print(name, i)79 print("Capitulo fuera de rango")80 return False81 else:82 text = chapter.text83 html.parseStr(text)84 table_body = html.getElementsByClassName("RTbl Dwnl")[85 0][1]86 children = table_body.getChildren()87 for child in children:88 if child[0].innerHTML == "Zippyshare":89 link = child[-1].firstChild.attributes["href"]90 reg_log["animes"][parsed_name]['chapters'][i] = link91 ongoing['chapters'][i] = link92 json.dump(reg_log, open(register_log_file, "w+"), indent=4)93 json.dump(ongoing, open(current_download_file, 'w+'), indent=4)94 return True95 except Exception as e:96 print("Hubo un problema con la busqueda", e) ...

Full Screen

Full Screen

parse_name.py

Source:parse_name.py Github

copy

Full Screen

1import re2import pandas as pd3def _parse_name(name):4 parsed_name = {"subject": None, "teacher": None, "place": None}5 result = re.match(6 r"([А-Яа-яёЁa-zA-Z +,/.\-\d]+)<nobr>([А-Яа-яёЁa-zA-Z +,/.\-\d]+)</nobr>([А-Яа-яёЁa-zA-Z +,/.\-\d]+)",7 name)8 if not (result is None):9 if name == result[0]:10 parsed_name["subject"] = result[1]11 parsed_name["place"] = result[2]12 parsed_name["teacher"] = result[3]13 return parsed_name14 # ... <nobr>Каф.</nobr>15 result = re.match(r"([А-Яа-яёЁa-zA-Z +,/.\-0-9]+)<nobr>([А-Яа-яёЁa-zA-Z +,/.\-0-9]+)</nobr> *", name)16 if not (result is None):17 if name == result[0]:18 parsed_name["subject"] = result[1]19 parsed_name["place"] = result[2]20 return parsed_name21 # Специальный физический практикум Андрианов Т. А.22 for i in range(2):23 result = re.match(r"([А-Яа-яёЁa-zA-Z +,/.\-\d]*) ([А-Яа-яёЁa-zA-Z]+ *[А-Яа-яёЁa-zA-Z]\. *[А-Яа-яёЁa-zA-Z]\.)"24 r" ([А-Яа-яёЁa-zA-Z]+ *[А-Яа-яёЁa-zA-Z]\. *[А-Яа-яёЁa-zA-Z]\.)" * i + " *", name)25 if not (result is None):26 if name == result[0]:27 parsed_name["subject"] = result[1]28 parsed_name["teacher"] = "".join([result[j+2] + " " for j in range(i+1)])29 return parsed_name30 return {"subject": name, "teacher": None, "place": None}31def parse_name(lessons):32 """33 Разделяет колонку 'name' на 'subject', 'teacher' и 'place'.34 """35 parsed_names = []36 for index, row in lessons.iterrows():37 name = row["name"]38 parsed_name = _parse_name(name)39 parsed_names.append(parsed_name)40 lessons = lessons.reset_index(drop=True)41 addition = pd.DataFrame(parsed_names).reset_index(drop=True)42 lessons = pd.concat([lessons, addition], axis=1)43 lessons.drop("name", inplace=True, axis=1)...

Full Screen

Full Screen

migrate5_cleanup_providers.py

Source:migrate5_cleanup_providers.py Github

copy

Full Screen

1from actorpermission.models.actortypes import BaseActorDocument, ProviderActor2from permissions.models import Actor3from nameparser import HumanName4from tenant.models import Tenant5def run():6 """7 Script to split out providers title into a lastname, firstname, title, provider_title8 """9 #actors = Actor.objects.all()10 raw_docs = BaseActorDocument.view('actorpermission/all_actors', include_docs=True).all()11 pact_tenant = Tenant.objects.get(name="PACT")12 for r in raw_docs:13 try:14 actor_doc = BaseActorDocument.get_typed_from_id(r._id)15 raw_name = actor_doc.name16 parsed_name = HumanName(raw_name)17 #print parsed_name.title18 if isinstance(actor_doc, ProviderActor):19 #set the old title to the new provider_title20 actor_doc.provider_title = actor_doc.title21 print "%s: %s" % (raw_name, list(parsed_name))22 if len(parsed_name.title) > 0:23 print "\tTitles: %s" % parsed_name.title24 actor_doc.title=parsed_name.title25 print "\tFirst: %s" % parsed_name.first26 if len(parsed_name.middle) > 0:27 print "\tMiddle: %s" % parsed_name.middle28 actor_doc.first_name = "%s %s" % (parsed_name.first, parsed_name.middle.replace('.',''))29 else:30 actor_doc.first_name = parsed_name.first31 print "\tLast: %s" % parsed_name.last32 if len(parsed_name.suffix) > 0:33 print "\tSuffix: %s" % parsed_name.suffix34 actor_doc.last_name = "%s %s" % (parsed_name.last, parsed_name.suffix)35 else:36 actor_doc.last_name = parsed_name.last37 #print "%s: %s, %s\n" % (raw_name, parsed_name.last, parsed_name.first)38 delattr(actor_doc,'name')39 actor_doc.save(pact_tenant)40 except Exception, ex:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful