def inicio(): vingadores = Filme('vingadores - guerra infinita', 2018, 160) atlanta = Serie('atlanta', 2018, 2) vingadores.dar_likes() vingadores.dar_likes() vingadores.dar_likes() atlanta.dar_likes() atlanta.dar_likes() listinha = [atlanta, vingadores] for programa in listinha: print(programa)
def get(self): user = users.get_current_user() if user != None: serie = Serie() serie.name = "Name" serie.web = "http://en.wikipedia.org/wiki/Serial_(radio_and_television)" serie.comments = "Serial comments." serie.picture = "https://upload.wikimedia.org/wikipedia/commons/6/66/SMPTE_Color_Bars.svg" serie.user = user.user_id() serie.lastEpisode = 1001 serie.put() self.redirect("/modify?id=" + serie.key.urlsafe()) else: self.redirect("/")
def get(self): user = users.get_current_user() if user != None: serie = Serie() serie.name = "Name" serie.web = "http://en.wikipedia.org/wiki/Serial_(radio_and_television)"; serie.comments = "Serial comments."; serie.picture = "https://upload.wikimedia.org/wikipedia/commons/6/66/SMPTE_Color_Bars.svg"; serie.user = user.user_id() serie.lastEpisode = 1001 serie.put() self.redirect("/modify?id=" + serie.key.urlsafe()) else: self.redirect("/")
def charger_series(): # Tendance linéaire simple serie_1 = Serie("Série 1", formule="0.3*x", std=6) # Tendance linéaire + saisonnalité simple de période 12 serie_2 = Serie("Série 2", formule="sin(x*pi/6)*4+0.3*x", std=2) # Tendance linéaire + saisonnalité de période 12 multiplicative serie_3 = Serie("Série 3", formule="sin(x*pi/6)*4*(0.01*x)+0.3*x", std=1.8) # Tendance non polynomiale + saisonnalités imbriquées non multiples serie_4 = Serie( "Série 4", formule= "(sin(x*pi/3.5)*8-sin(x*pi/6)*15)+sin(x*pi/40)*40+((4*x)**0.4)*30", std=2.8) # Série production de bières en Australie de 1956 à 1995 serie_bieres = Serie("Production de bières", csv_file="production_biere_australie.csv") # Série financière très bruitée : le rendement du Bitcoin sur 4 heures serie_bitcoin = Serie("Rendement du Bitcoin", csv_file="rendements_bitcoin_4H.csv") return [serie_1, serie_2, serie_3, serie_4, serie_bieres, serie_bitcoin]
def get(self): user = users.get_current_user() if user != None: user_name = user.nickname() access_link = users.create_logout_url("/") series = Serie.query(Serie.user == user.user_id()).order(Serie.added) template_values = {"user_name": user_name, "access_link": access_link, "series": series} template = JINJA_ENVIRONMENT.get_template("mainMenu.html") self.response.write(template.render(template_values)) else: self.redirect("/")
def prepare_values(raw, config, cls): """Prepare the values to start with sane values""" if not raw: return adapters = list(cls._adapters) or [lambda x:x] if config.logarithmic: for fun in not_zero, positive: if fun in adapters: adapters.remove(fun) adapters = adapters + [positive, not_zero] adapter = reduce(compose, adapters) if not config.strict else ident series = [] width = max([len(values) for _, values in raw] + [len(config.x_labels or [])]) for title, raw_values in raw: metadata = {} values = [] if isinstance(raw_values, dict): value_list = [None] * width for k, v in raw_values.items(): if k in config.x_labels: value_list[config.x_labels.index(k)] = v raw_values = value_list else: raw_values = list(raw_values) for index, raw_value in enumerate( raw_values + ( (width - len(raw_values)) * [None] # aligning values if len(raw_values) < width else [])): if isinstance(raw_value, dict): value = raw_value.pop('value') metadata[index] = raw_value else: value = raw_value if cls.__name__ == 'XY': if not hasattr(value, '__iter__'): value = (value, config.zero) value = map(adapter, value) else: value = adapter(value) values.append(value) series.append(Serie(title, values, metadata)) return series
def leitura_arquivo(): try: arq = open(os.path.join(os.getcwd(), 'series.html'), 'rt') inicio_info = '<td class="titleColumn">' #Tag de inicio de informacoes de serie series = {} for i in arq: if inicio_info in i: #Ler linhas de arquivo arq.readline() #Pular linha nome = separador(arq.readline()) ano = separador(arq.readline()).replace(')', '').replace('(', '') arq.readline() #Pular linha arq.readline() #Pular linha avaliacao = separador(arq.readline()) series[nome] = Serie(nome, ano, avaliacao) except FileNotFoundError: print('ARQUIVO NAO ENCONTRADO') return series
def get(self): user = users.get_current_user() if user != None: user_name = user.nickname() access_link = users.create_logout_url("/") series = Serie.query(Serie.user == user.user_id()).order( Serie.added) template_values = { "user_name": user_name, "access_link": access_link, "series": series, } template = JINJA_ENVIRONMENT.get_template("mainMenu.html") self.response.write(template.render(template_values)) else: self.redirect("/")
def run(): vingadores = Filme('Vingadores - guerra infinita', 2018, 160) for i in range(100): vingadores.dar_likes() edg = Filme('Era do gelo', 206, 130) for i in range(10): edg.dar_likes() atlanta = Serie('atlanta', 2018, 2) atlanta.dar_likes() tbbt = Serie('The big bang theory', 2008, 11) for i in range(50): tbbt.dar_likes() filmes_series = [vingadores, edg, tbbt, atlanta] for programa in filmes_series: print(programa) # o python já sabe que ele deve chamar o __str__ print() print('from playlist') playlist = Playlist('fim de semana', filmes_series) for programa in playlist: # eu so posso iterar pq Playlist extends a classe list print(programa) print(f'Tamanho da lista: {len(playlist)}') print(f'TBBT em playlist? { tbbt in playlist }') print() print('from playlist') playlist2 = Playlist2('fim de semana', filmes_series) for programa in playlist2: # eu so posso iterar por causa do método __getitem__ print(programa) print(f'Tamanho da lista: { len(playlist2) }' ) # só posso chamar o len por causa do método __len__ print(f'TBBT em playlist2? { tbbt in playlist2 }')
# account.whitdraw(20) # print("Balance: ", account.balance) # account.whitdraw(1300) # print("Balance: ", account.balance) # print(Account.bank_code) # print(Account.bank_codes()) avengers1 = Movie("avengers", 2017, 160) avengers2 = Movie("avengers", 2018, 160) avengers3 = Movie("avengers", 2018, 160) avengers2.addLike() avengers2.addLike() friends = Serie("friends", 2010, 10) friends.addLike() friends.addLike() friends.addLike() weekend_playlist = Playlist("Weekend playlist", [avengers2, friends]) for tvshow in weekend_playlist: print(tvshow) print(f"Playlist size: {len(weekend_playlist)}") print(avengers1 == avengers2) print(avengers2 == avengers3)
def main(self,*args,**kwargs) : self._serie = Serie(self._serieos, self._console) self._serie.main(*args,**kwargs)
class TestSerie(unittest.TestCase) : def setUp(self) : self.maxDiff = None self._serieos = SerieOsMock() self._console = ConsoleExporterMock() def tearDown(self) : self.assertEqual(self._console.errs(),[]) def assert_files(self, filenames, subdir=None) : if subdir is None : listdir = self._serieos.listdir('.') else : listdir = self._serieos.listdir(subdir) self.assertEqual(sorted(listdir),sorted(filenames)) def assert_out(self, lines) : self.assertEqual(self._console.outs(), lines) def main(self,*args,**kwargs) : self._serie = Serie(self._serieos, self._console) self._serie.main(*args,**kwargs) def touch(self,filenames) : for filename in filenames : self._serieos.touch(filename) def test_old_basic(self) : self.touch(['-1-']) self.main('7') self.assert_files(['-1--2--3--4--5--6-[7]']) def test_old_end(self) : self.touch(['-1-']) self.main('7') self.main('e9') self.assert_files(['-1--2--3--4--5--6-[7]-8--9-+']) def test_old_size_0_00(self) : self.touch(['-1-']) self.main('7') self.assert_files(['-1--2--3--4--5--6-[7]']) self.main('11') self.assert_files(['-01--02--03--04--05--06-[07]-08--09--10-[11]']) def test_old_size_sep_20(self) : self.touch(['-1-']) self.main('7') self.assert_files(['-1--2--3--4--5--6-[7]']) self.main('11') self.assert_files(['-01--02--03--04--05--06-[07]-08--09--10-[11]']) self.main('31') self.assert_files(['-01--02--03--04--05--06-[07]-08--09--10-[11]-12--13--14--15--16--17--18--19--20-','-21--22--23--24--25--26--27--28--29--30-[31]'],) def test_old_empty_row(self) : self.touch(['-1-']) self.main('7','51') self.assert_files(['-01--02--03--04--05--06-[07]-08--09--10--11--12--13--14--15--16--17--18--19--20-','-41--42--43--44--45--46--47--48--49--50-[51]'],) def test_new_basic(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) def test_new_end(self) : self.main('7') self.main('e9') self.assert_files(['@_-1--2--3--4--5--6-[7]-8--9-+']) def test_new_size_0_00(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) self.main('11') self.assert_files(['@_-01--02--03--04--05--06-[07]-08--09--10-[11]']) def test_new_size_sep_20(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) self.main('11') self.assert_files(['@_-01--02--03--04--05--06-[07]-08--09--10-[11]']) self.main('31') self.assert_files(['@_-01--02--03--04--05--06-[07]-08--09--10-[11]-12--13--14--15--16--17--18--19--20-','@_-21--22--23--24--25--26--27--28--29--30-[31]'],) def test_new_empty_row(self) : self.main('7','51') self.assert_files(['@_-01--02--03--04--05--06-[07]-08--09--10--11--12--13--14--15--16--17--18--19--20-','@_-41--42--43--44--45--46--47--48--49--50-[51]'],) def test_newsyntax_migration(self): self.touch(['-1-']) self.main('7') self.assert_files(['-1--2--3--4--5--6-[7]']) self.main('m') self.assert_files(['@_-1--2--3--4--5--6-[7]']) def test_newsyntax_migration_2(self): self.touch(['-1-']) self.main('7') self.assert_files(['-1--2--3--4--5--6-[7]']) self.main('migration') self.assert_files(['@_-1--2--3--4--5--6-[7]']) def test_namespace_basic(self): self.main('name:7') self.assert_files(['@_name_-1--2--3--4--5--6-[7]']) def test_namespace_numeral(self): self.main('name3:7') self.assert_files(['@_name03_-1--2--3--4--5--6-[7]']) def test_mix_namespaces(self): self.main('name3:7','name001:5') self.assert_files(['@_name01_-1--2--3--4-[5]','@_name03_-1--2--3--4--5--6-[7]']) self.main('name3:2-4','name1:s3-6','23') self.assert_files(['@_-21--22-[23]','@_name01_-1--2-!3!!4!$5$!6!','@_name03_-1-[2][3][4]-5--6-[7]']) def test_mix_namespaces_with_comma(self): self.main('name3:7','name001:5') self.assert_files(['@_name01_-1--2--3--4-[5]','@_name03_-1--2--3--4--5--6-[7]']) self.main('name3:2,4','name1:s3,6','23') self.assert_files(['@_-21--22-[23]','@_name01_-1--2-!3!-4-[5]!6!','@_name03_-1-[2]-3-[4]-5--6-[7]']) def test_end2(self) : self.main('7') self.main('-9') self.assert_files(['@_-1--2--3--4--5--6-[7]-8--9-']) def test_interval_creation(self) : self.main('3-7') self.assert_files(['@_-1--2-[3][4][5][6][7]']) def test_interval_use(self) : self.main('9') self.assert_files(['@_-1--2--3--4--5--6--7--8-[9]']) self.main('3-7') self.assert_files(['@_-1--2-[3][4][5][6][7]-8-[9]']) def test_interval_overlap(self) : self.main('9') self.assert_files(['@_-1--2--3--4--5--6--7--8-[9]']) self.main('2-5','4-7') self.assert_files(['@_-1-[2][3][4][5][6][7]-8-[9]']) def test_consolidate(self) : self.touch(['[7]']) self.assert_files(['[7]']) self.main() self.assert_files(['-1--2--3--4--5--6-[7]']) def test_consolidate_multiple(self) : self.touch(['[7]','[14][9]']) self.assert_files(['[7]','[14][9]']) self.main() self.assert_files(['-01--02--03--04--05--06-[07]-08-[09]-10--11--12--13-[14]']) def test_consolidate_multiple_overlap(self) : self.touch(['[7][8][9]','[08][09][10][11]']) self.main() self.assert_files(['-01--02--03--04--05--06-[07][08][09][10][11]']) def test_consolidate_multiple_overlap_oldandnewsyntax(self) : self.touch(['[7][8][9]','@_[08][09][10][11]']) self.main() self.assert_files(['@_-01--02--03--04--05--06-[07][08][09][10][11]']) def test_suppression_basic(self) : self.main('9') self.assert_files(['@_-1--2--3--4--5--6--7--8-[9]']) self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]-8-[9]']) self.main('-7') self.assert_files(['@_-1--2--3--4--5--6--7--8-[9]']) def test_suppression_end_empty(self) : self.main('e7','-7') self.assert_files(['@_-1--2--3--4--5--6--7-+']) def test_seen_basic(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) self.main('4') self.assert_files(['@_-1--2--3-[4]-5--6-[7]']) self.main('s4') self.assert_files(['@_-1--2--3-$4$-5--6-[7]']) def test_seen_interval(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) self.main('1-5') self.assert_files(['@_[1][2][3][4][5]-6-[7]']) self.main('s2-4') self.assert_files(['@_[1]$2$$3$$4$[5]-6-[7]']) def test_seen_interval2(self) : self.main('7') self.assert_files(['@_-1--2--3--4--5--6-[7]']) self.main('1-4') self.assert_files(['@_[1][2][3][4]-5--6-[7]']) self.main('s2-5') self.assert_files(['@_[1]$2$$3$$4$!5!-6-[7]']) def test_comma(self) : self.main('1,4,7') self.assert_files(['@_[1]-2--3-[4]-5--6-[7]']) def test_comma_interval_1(self) : self.main('1,4-6,8') self.assert_files(['@_[1]-2--3-[4][5][6]-7-[8]']) def test_comma_interval_2(self) : self.main('113-124,139-145,152-155') self.assert_files(['@_-101--102--103--104--105--106--107--108--109--110--111--112-[113][114][115][116][117][118][119][120]','@_[121][122][123][124]-125--126--127--128--129--130--131--132--133--134--135--136--137--138-[139][140]','@_[141][142][143][144][145]-146--147--148--149--150--151-[152][153][154][155]']) def test_comma_interval_multiple(self) : self.main('1,4-6,8','s3-4,6-8') self.assert_files(['@_[1]-2-!3!$4$[5]$6$!7!$8$']) def test_consolidate_multiple_end(self) : self.touch(['[7]','[14][9]','-17-']) self.assert_files(['[7]','[14][9]','-17-']) self.main() self.assert_files(['-01--02--03--04--05--06-[07]-08-[09]-10--11--12--13-[14]-15--16--17-']) def test_consolidate_multiple_end_2(self) : self.touch(['[7]','@_[14][9]','-22-']) self.assert_files(['[7]','@_[14][9]','-22-']) self.main() self.assert_files(['@_-01--02--03--04--05--06-[07]-08-[09]-10--11--12--13-[14]-15--16--17--18--19--20-','@_-21--22-']) def test_suppression_empty(self) : self.main('-7') self.assert_files(['@_-1--2--3--4--5--6--7-']) def test_subdir_basic(self): self.main('s1:7') self.assert_files(['@_s01_-1--2--3--4--5--6-[7]']) self.main('s1~SUB01') self.assert_files(['@_s01~SUB01']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') def test_subdir_basic_other_order(self): self.main('s1~SUB01') self.assert_files(['@_s01~SUB01']) self.main('s1:7') self.assert_files(['@_s01~SUB01']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') def test_subdir_multiple(self): self.main('s1:7','5') self.assert_files(['@_-1--2--3--4-[5]','@_s01_-1--2--3--4--5--6-[7]']) self.main('s1~SUB01') self.assert_files(['@_-1--2--3--4-[5]','@_s01~SUB01']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') self.main('s002~SUB002','s2:e10','s3:4') self.assert_files(['@_-1--2--3--4-[5]','@_s01~SUB01','@_s02~SUB002','@_s03_-1--2--3-[4]']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') self.assert_files(['@_-01--02--03--04--05--06--07--08--09--10-+'],subdir='SUB002') def test_flatten(self): self.main('s1:7','5','s1~SUB01','s002~SUB002','s2:e10','s3:4') self.assert_files(['@_-1--2--3--4-[5]','@_s01~SUB01','@_s02~SUB002','@_s03_-1--2--3-[4]']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') self.assert_files(['@_-01--02--03--04--05--06--07--08--09--10-+'],subdir='SUB002') self.main('flatten') self.assert_files(['@_-1--2--3--4-[5]','@_s01_-1--2--3--4--5--6-[7]','@_s02_-01--02--03--04--05--06--07--08--09--10-+','@_s03_-1--2--3-[4]']) self.assert_files([],subdir='SUB01') self.assert_files([],subdir='SUB002') def test_flatten_f(self): self.main('s1:7','5','s1~SUB01','s002~SUB002','s2:e10','s3:4') self.assert_files(['@_-1--2--3--4-[5]','@_s01~SUB01','@_s02~SUB002','@_s03_-1--2--3-[4]']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') self.assert_files(['@_-01--02--03--04--05--06--07--08--09--10-+'],subdir='SUB002') self.main('f') self.assert_files(['@_-1--2--3--4-[5]','@_s01_-1--2--3--4--5--6-[7]','@_s02_-01--02--03--04--05--06--07--08--09--10-+','@_s03_-1--2--3-[4]']) self.assert_files([],subdir='SUB01') self.assert_files([],subdir='SUB002') def test_text(self): self.main('s1:7','5','s1~SUB01','s002~SUB002','s2:e10','s3:4','s3:113-124,139-145,152-155','s3:s123-126') self.assert_files(['@_-1--2--3--4-[5]','@_s01~SUB01','@_s02~SUB002','@_s03_-001--002--003-[004]-005--006--007--008--009--010--011--012--013--014--015--016--017--018--019--020-','@_s03_-101--102--103--104--105--106--107--108--109--110--111--112-[113][114][115][116][117][118][119][120]','@_s03_[121][122]$123$$124$!125!!126!-127--128--129--130--131--132--133--134--135--136--137--138-[139][140]','@_s03_[141][142][143][144][145]-146--147--148--149--150--151-[152][153][154][155]']) self.assert_files(['@_-1--2--3--4--5--6-[7]'],subdir='SUB01') self.assert_files(['@_-01--02--03--04--05--06--07--08--09--10-+'],subdir='SUB002') self.main('text') self.assert_out([ ' 1 2 3 4 [5]', '', 's01 (SUB01):', ' 1 2 3 4 5 6 [7]', '', 's02 (SUB002):', ' 01 02 03 04 05 06 07 08 09 10 ++', '', 's03:', ' 001 002 003 [004] 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 ', ' 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 ', ' 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 ', ' 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 ', ' 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 ', ' 101 102 103 104 105 106 107 108 109 110 111 112 [113] [114] [115] [116] [117] [118] [119] [120]', '[121] [122] $123$ $124$ !125! !126! 127 128 129 130 131 132 133 134 135 136 137 138 [139] [140]', '[141] [142] [143] [144] [145] 146 147 148 149 150 151 [152] [153] [154] [155]', '', ])
from filme import Filme from playlist import Playlist from serie import Serie vingadores = Filme('vingadores - guerra infinita', 2018, 160) tmep = Filme('Todo mundo em pânico', 1999, 100) atlanta = Serie('atlanta', 2018, 2) demolidor = Serie('demolidor', 2016, 2) vingadores.dar_like() tmep.dar_like() tmep.dar_like() tmep.dar_like() tmep.dar_like() demolidor.dar_like() demolidor.dar_like() atlanta.dar_like() atlanta.dar_like() atlanta.dar_like() filmes_e_series = [vingadores, atlanta, demolidor, tmep] playlist_fim_de_semana = Playlist('fim de semana', filmes_e_series) for programa in playlist_fim_de_semana: print(programa) print(f'Tamanho do playlist: { len(playlist_fim_de_semana) }') print(f'Tem o filme vingadores na lista? R: { vingadores in playlist_fim_de_semana }') print(playlist_fim_de_semana[0])
from filme import Filme from serie import Serie from playlist import Playlist print('~' * 30) vingadores = Filme('Vingadores - Guerra Inifita', 2018, 160) atlanta = Serie('Atlanta', 2018, 2) tmep = Filme('Todo mundo em pânico', 1999, 100) demolidor = Serie('Demolidor', 2016, 2) vingadores.dar_likes() tmep.dar_likes() tmep.dar_likes() tmep.dar_likes() tmep.dar_likes() demolidor.dar_likes() demolidor.dar_likes() atlanta.dar_likes() atlanta.dar_likes() atlanta.dar_likes() filmes_e_series = [vingadores, atlanta, demolidor, tmep] #for programa in filmes_e_series: # print(programa) #detalhes = programa.duracao if hasattr(programa, 'duracao') else programa.temporadas #programa.imprime() playlist_fim_de_semana = Playlist('fim de semana', filmes_e_series) print(f'Tamanho da Playlist: {len(playlist_fim_de_semana)}')
from filme import Filme from serie import Serie from playlist import Playlist vingadores_g_i = Filme('vingadores, guerra infinita', 2018, 160) vingadores_u = Filme('vingadores, ultimato', 2019, 182) see = Serie('see', 2019, 1) the_morning_show = Serie('the morning show', 2019, 1) vingadores_g_i.dar_likes() vingadores_g_i.dar_likes() vingadores_u.dar_likes() vingadores_u.dar_likes() see.dar_likes() see.dar_likes() the_morning_show.dar_likes() the_morning_show.dar_likes() lista = [vingadores_g_i, vingadores_u, see, the_morning_show] minha_playlist = Playlist('fim de semana', lista) for programa in minha_playlist: print(programa) print('tamanho: {}'.format(len(minha_playlist)))
return self.__videos @name.setter def name(self, name) : self.__name = name @videos.setter def videos(self, videos_list) : self.__videos = video_list def size(self) : return len(self.__videos) if ( __name__ == "__main__" ) : avengers = Movie("Avengers: Infinity Wars", 2018, 160) office = Serie("The Office", 2005, 9) modern_family = Serie("Modern Family", 2009, 11) matrix = Movie("The Matrix", 1999, 136) matrix.add_like() office.add_like() modern_family.add_like() avengers.add_like() matrix.add_like() office.add_like() modern_family.add_like() office.add_like() modern_family.add_like()
def getSerie(self, outputFolder: PathModel, url: str, all: list[tuple]) -> None: for x in all: _m3u8 = self._getEpisode(url, x) Serie.initialize(x, outputFolder, PathModel(os.getcwd()).add(_m3u8)) self.root.quit()