def municipalidadValparaiso(): # https://www.municipalidaddevalparaiso.cl/ n = New() n.institution = "Seremi de Cultura" n.url_base = "https://www.municipalidaddevalparaiso.cl/" n.url_news = n.url_base + "HistoricoNoticias.aspx" bs = openUrl("https://www.municipalidaddevalparaiso.cl/HistoricoNoticias.aspx") news = bs.find_all("div", class_="box cargador")
def new(self): ''' Create new playlist. If mode = "edit" same window is used to edit existing playlist. ''' self.switchFrame() from new import New n = New(self.mainframe) n.pack(fill=BOTH, expand=True, padx=10, pady=5) self.root.wait_window(n) self.player()
def test_add_new(app): app.session.login(username="******", password="******") app.contact.create_new( New(firstname="Konstantin", middlename="Styagailo", address="Parkovaya, 8")) app.session.logout()
def get_contact_from_view_page(self, index): wd = self.app.wd self.open_contact_view_by_index(index) # вытаскиваем текст text = wd.find_element_by_id("content").text homephone = re.search("H: (.*)", text).group(1) mobilephone = re.search("M: (.*)", text).group(1) workphone = re.search("W: (.*)", text).group(1) secondaryphone = re.search("P: (.*)", text).group(1) return New(homephone=homephone, workphone=workphone,mobilephone=mobilephone,secondaryphone=secondaryphone)
def __init__(self): self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog)
def __init__(self): # linking files and creating objects self.new_Window = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.new_Window) self.evaluate_Window = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.evaluate_Window) self.open_Window = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.open_Window)
def __init__(self): #NEW self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) #EVALUATE self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) #OPEN self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog)
def test_delete_some_new(app): if app.contact.count() == 0: app.contact.create(New(firstname="Svetlana", middlename="Alexeyevna", lastname="Andreeva", nickname="Sveta", title="test", company="2B", address="Saint-Petersburg", homephone="+78120000000", mobilephone="+79110000000", workphone="+78121000000", fax="+78122000000", email="*****@*****.**", email2="*****@*****.**", email3="*****@*****.**", homepage="www.andreeva.ru", bday="19", bmonth="September", byear="1987", aday="9", amonth="May", ayear="2000", address2="Moscow", secondaryphone="1", notes="Test")) old_contacts = app.contact.get_contact_list() index = randrange (len(old_contacts)) app.contact.delete_contact_by_index(index) assert len(old_contacts) - 1 == app.contact.count() new_contacts = app.contact.get_contact_list() old_contacts[index:index+1] = [] assert old_contacts == new_contacts
def generate_f_data(): """Generates fictional data to load the program.""" ch = Channel("Life","This channel is made to talk about life") ch2 = Channel("None", "none") u = User.users[random.choice(list(User.users.keys()))] u2 = User.users[random.choice(list(User.users.keys()))] while u == u2: u2 = User.users[random.choice(list(User.users.keys()))] a = Admin("Valentina", "Vvasquez", "*****@*****.**", "V123") q = Question(u, ch, "What is life?") c = Comment(u2, q, "That is; in fact, a hard question, what would it be?") r = Rating(u2, q, "like") r1 = Rating(a, c, "dislike") q2 = Question(u2, ch, "What is love?") c2 = Comment(u, q2, "The affection you feel for someone; or even, something.") r2 = Rating(a, q2, "dislike") q3 = Question(a, ch, "What is Death?") n = New(a, "The hollow has come!", "That witch has taken my daughthers body.", "Niklaus.", "Drama")
def get_contact_info_from_edit_page(self, index): wd = self.app.wd # открываем форму редактирования по заданному индексу self.open_contact_to_edit_by_index(index) # из формы читаем информацию firstname = wd.find_element_by_name("firstname").get_attribute("value") # текст который мы видим в поле является значением аттрибута value lastname = wd.find_element_by_name("lastname").get_attribute("value") id = wd.find_element_by_name("id").get_attribute("value") homephone = wd.find_element_by_name("home").get_attribute("value") workphone = wd.find_element_by_name("work").get_attribute("value") mobilephone = wd.find_element_by_name("mobile").get_attribute("value") secondaryphone = wd.find_element_by_name("phone2").get_attribute("value") email = wd.find_element_by_name("email").get_attribute("value") email2 = wd.find_element_by_name("email2").get_attribute("value") email3 = wd.find_element_by_name("email3").get_attribute("value") # Строим объект из полученных данных, сначала название параметра а потом название локальной переменной return New(firstname=firstname, lastname=lastname, id=id,homephone=homephone, workphone=workphone,mobilephone=mobilephone, secondaryphone=secondaryphone, email=email, email2=email2, email3=email3)
def upload_a_new(language, admin): """Asks the admin for the title, content, author and label to create a comment, creates it and returns it. Args: language (dict): The language in which the information will be given. admin (Admin): The admin that creates the questions. Returns: New: The created new. """ print(language.get("title")) title = input(language.get("inputtabs")) print(language.get("content")) content = input(language.get("inputtabs")) print(language.get("author")) author = input(language.get("inputtabs")) print(language.get("label")) label = input(language.get("inputtabs")) new = New(admin, title, content, author, label) return new
def get_contact_list(self): if self.contact_cache is None: wd = self.app.wd self.open_home_page() # строим объект с информацией о контакте contacts = [] self.contact_cache = [] for row in wd.find_elements_by_name("entry"): cells = row.find_elements_by_tag_name("td") # получаем данные из ячеек firstname = cells[2].text lastname = cells[1].text id = cells[0].find_element_by_tag_name("input").get_attribute("value") # так как в ячейке телефонов отдельные телефоны не указаны приходится получать информацию по всей ячейке а потом порезать её на части all_phones = cells[ 5].text # теперь это список телефонов у ячейки берём текст а потом делим его на телефоны # и мы можем этот список использовать что бы заполнить свойства объекта contact all_emails = cells[4].text # параметры для конструирования нового объекта contacts self.contact_cache.append(New(firstname=firstname, lastname=lastname, id=id, all_phones_from_home_page=all_phones, all_emails_from_home_page=all_emails)) return list(self.contact_cache)
def test_contact_info_on_main_page(app): if app.contact.count() == 0: app.contact.add_contact( New(firstname="Svetlana", middlename="Alexeyevna", lastname="Andreeva", nickname="Sveta", title="test", company="2B", address="Saint-Petersburg", homephone="+78120000000", workphone="+78121000000", mobilephone="+79110000000", secondaryphone="1", fax="+78122000000", email="*****@*****.**", email2="*****@*****.**", email3="*****@*****.**", homepage="www.andreeva.ru", bday="19", bmonth="September", byear="1987", aday="9", amonth="May", ayear="2000", address2="Moscow", notes="Test")) old_contact_list = app.contact.get_contact_list() index = randrange(len(old_contact_list)) contact_from_home_page = app.contact.get_contact_list()[index] contact_from_edit_page = app.contact.get_contact_info_from_edit_page(index) assert contact_from_home_page.firstname == contact_from_edit_page.firstname assert contact_from_home_page.lastname == contact_from_edit_page.lastname assert contact_from_home_page.address == contact_from_edit_page.address assert contact_from_home_page.all_phones_from_home_page == merge_phones_like_on_home_page( contact_from_edit_page) assert contact_from_home_page.all_emails_from_home_page == merge_emails_like_on_home_page( contact_from_edit_page)
def seremiCultura(): # https://www.cultura.gob.cl/valparaiso/ n = New() n.institution = "Seremi de Cultura" n.url_base = "https://www.cultura.gob.cl/" n.url_news = n.url_base + "valparaiso/noticias/" bs = openUrl(n.url_news) news = bs.find_all("div", class_="list") for new in news: locale.setlocale(locale.LC_ALL, 'es_CL') n.date = new.find("span", class_="list-date").text.strip() n.date = formatTime(n.date, "%A %d de %B de %Y") n.url_new = new.a["href"] bs_new = openUrl(n.url_new) n.img = bs_new.find("div", id="img-top").img.get('src') n.title = bs_new.find("span", class_="t2").text.strip() n.lead = bs_new.find("strong").text.strip() n.body_full = bs_new.find("div", id="cont-izq-in").prettify() n.body = bs_new.find("div", id="cont-izq-in").text.strip() n.saveNew()
def test_empty_new(app): app.session.login(username="******", password="******") app.contact.create_new(New(firstname="", middlename="", address="")) app.session.logout()
def random_string(prefix, maxlen): symbols = string.ascii_letters + string.digits return prefix + "".join( [random.choice(symbols) for i in range(random.randrange(maxlen))]) testdata = [ New(firstname="", lastname="", nickname="", title="", company="", address="", homephone="", mobilephone="", workphone="", fax="", email="", email2="", email3="", homepage="", address2="", secondaryphone="", notes="") ] + [ New(firstname=random_string("firstname", 10), lastname=random_string("lastname", 10), nickname=random_string("nickname", 10), title=random_string("title", 10), company=random_string("company", 10), address=random_string("address", 10),
def intendenciaValparaiso(): n = New() n.institution = "Intendencia Valparaíso" n.url_base = "http://www.intendenciavalparaiso.gov.cl" n.url_news = n.url_base + "/noticias/" bs = openUrl(n.url_news) news = bs.find_all("div", class_="post tarjeta") for new in news: n.url_new = n.url_base + new.a["href"] bs_new = openUrl(n.url_new) locale.setlocale(locale.LC_ALL, 'es_CL') n.date = bs_new.find("span", class_="meta").text.strip() n.date = formatTime(n.date, "%d de %B de %Y") n.img = n.url_base + bs_new.find("div", class_="pic").img.get('src') n.title = bs_new.find("h3", class_="title").text.strip() n.lead = " PORNER LA BAJADA O PRIMER PARRAFO" n.body_full = bs_new.find("div", class_="contenido").prettify() n.body = bs_new.find("div", class_="contenido").text.strip() n.saveNew()
def seremiSalud(): n = New() n.institution = "Seremi de Salud" n.url_base = "http://seremi5.redsalud.gob.cl/" n.url_news = n.url_base + "?feed=rss2" feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') n.category = f['category'] locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] bs_new = openUrl(n.url_new) try: n.img = n.url_base + bs_new.find("section", class_="body").p.a.img.get('src') except Exception as e: n.img = None n.body_full = bs_new.find("section", class_="body").prettify().strip() n.body = bs_new.find("section", class_="body").text.strip() n.saveNew()
def municipalidadQuilpue(): # https://www.quilpue.cl/ n = New() n.institution = "Municipalidad Quilpue" n.url_base = "https://www.quilpue.cl/" n.url_news = n.url_base + "articulos/1/0/municipio.html" bs = openUrl(n.url_news) news = bs.find_all("a", class_="noti-c") for new in news: locale.setlocale(locale.LC_ALL, 'es_CL') n.date = new.find("div", class_="meta-fecha").text.strip() n.date = formatTime(n.date, "%d de %B, %Y") n.title = new['title'].strip() n.img = new.figure.img.get('src') n.lead = new.find("div", class_="txt-intro").p.text.strip() n.url_new = new["href"] bs_new = openUrl(n.url_new) n.category = bs_new.find("a", class_="noti-tag").text.strip() n.body_full = bs_new.find("div", id="texto").prettify() n.body = bs_new.find("div", id="texto").text.strip() n.saveNew()
def seremiMedioAmbiente(): n = New() n.institution = "Seremi Medio Ambiente" n.url_base = "https://mma.gob.cl/category/region-de-valparaiso/" n.url_news = n.url_base + "feed/" if hasattr(ssl, '_create_unverified_context'): ssl._create_default_https_context = ssl._create_unverified_context feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') n.category = f['category'] locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] bs_new = openUrl(n.url_new, ssl=False) n.img = bs_new.find("div", class_="entry-thumbnail").img.get('data-src') n.body_full = bs_new.find("div", class_="entry-content").prettify().strip() n.body = bs_new.find("div", class_="entry-content").text.strip() n.saveNew()
def soyChileQuillota(): # https://www.soychile.cl/quillota/ n = New() n.institution = "Soy Valparaíso - Quillota" n.url_base = "http://feeds.feedburner.com/soyquillotacl-todas" n.url_news = n.url_base + "" feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%d %b %Y %H:%M:%S:%f") n.url_new = f['link'] bs_new = openUrl(n.url_new) try: n.img = bs_new.find("div", class_="gallery-item").a.img.get('src') except: n.img = bs_new.find("div", class_="gallery-item gallery-item--1").img.get('src') n.body_full = bs_new.find("div", class_="note-inner-text").prettify().strip() n.body = bs_new.find("div", class_="note-inner-text").text.strip() n.saveNew()
def elInformador(): # https://www.elinformador.cl n = New() n.institution = "El Informador" n.url_base = "https://www.elinformador.cl/" n.url_news = n.url_base + "feed/" feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') n.lead = BeautifulSoup(n.lead, "html.parser").p.text.strip() locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] bs_new = openUrl(n.url_new) n.img = bs_new.find("div", class_="td-post-featured-image").a.img.get('src') n.body_full = bs_new.find("div", class_="td-post-content").prettify().strip() n.body = bs_new.find("div", class_="td-post-content").text.strip() n.saveNew()
def radioValparaiso(): # http://www.radiovalparaiso.cl/ciudades/valparaiso/ n = New() n.institution = "Radio Valparaíso" n.url_base = "http://www.radiovalparaiso.cl/ciudades/valparaiso/" n.url_news = n.url_base + "feed/" feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') n.lead = BeautifulSoup(n.lead, "html.parser").p.text.strip() locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] bs_new = openUrl(n.url_new) n.img = bs_new.find("div", class_="featured-big-image news").img.get('src') n.body_full = bs_new.find("div", class_="textContent").prettify().strip() n.body = bs_new.find("div", class_="textContent").text.strip() n.saveNew()
def elMatutino(): # http://www.elmartutino.cl/ n = New() n.institution = "El Matutino" n.url_base = "http://www.elmartutino.cl/" n.url_news = n.url_base + "rss/noticias/local" feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] n.img = f['links'][1]['href'] bs_new = openUrl(n.url_new) n.body_full = bs_new.find("div", class_="panel-pane pane-node-body").div.prettify().strip() n.body = bs_new.find("div", class_="panel-pane pane-node-body").div.text.strip() n.saveNew()
def seremiEducacion(): # https://valparaiso.mineduc.cl/ n = New() n.institution = "Seremi de Educación" n.url_base = "https://valparaiso.mineduc.cl/" n.url_news = n.url_base + "feed/" if hasattr(ssl, '_create_unverified_context'): ssl._create_default_https_context = ssl._create_unverified_context feed = feedparser.parse( n.url_news ) for f in feed['items']: n.title = f['title'] n.lead = f['summary'].replace('[…]', '') n.category = f['category'] locale.setlocale(locale.LC_ALL, 'en_US') n.date = formatTime(f['published'], "%a, %d %b %Y %H:%M:%S %z") n.url_new = f['link'] bs_new = openUrl(n.url_new) n.img = bs_new.find("div", class_="imgDest").img.get('src') n.body_full = bs_new.find("div", class_="content").prettify().strip() n.body = bs_new.find("div", class_="content").text.strip() n.saveNew()