Realmente dudo que hayas escrito el código, mas bien creo que estas copiando y pegando de diferentes partes. Se puede notar fácilmente que el código no esta escrito por una sola persona.
De hecho ni siquiera estas haciendo un uso correcto de la clase nodo. Ya que implementas el stack y el queue con listas y no con la clase nodo. Ademas que el código tienes bien escrito queue mientras en los comentarios escribes Queure casi siempre.
Otra cosa es que no incluiste el archivo peliculas100.dat, así que hice uno, en base en los parámetros del constructor Movies, de hecho también tienes errores ahí y haces mucha duplicación de codigo, movies[0], movies[1] ... movies[13]. Y los parámetros por default son listas en vez de strings. Todo eso nada mas en el costructor de Movies, no quiero hablar sobre el resto.
Bueno aqui dejo peliculas100.dat y el código.
Código:
title01|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title02|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title03|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title04|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title05|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title06|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title07|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title08|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title09|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title10|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title11|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title12|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title13|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title14|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title15|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title16|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title17|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title18|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title19|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title20|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
title21|director|cast|producer|writer|country|language|year|genres|votes|rating|runtime|plot|cover_url
Código Python:
Ver original#coding: utf-8
import random
#################################
#Movie
#Creamos la clase Movie
class Movie:
def __init__(self,title="emptyTitle",
director=["emptyDirector"],
cast = ["emptyCast"],
producer = ["emptyProducer"],
writer = ["emptyWriter"],
country = ["emptyCountry"],
language = ["emptyLanguage"],
year = "emptyYear",
genres = ["emptyGenres"],
votes = "emptyVotes",
rating = "emptyRating",
runtime = ["emptyRuntime"],
plot = ["emptyPlot"],
cover_url = "emptyCorver"):
self.title = title
self.director = director
self.cast = cast
self.producer = producer
self.writer = writer
self.country = country
self.language = language
self.year = year
self.genres = genres
self.votes = votes
self.rating = rating
self.runtime = runtime
self.plot = plot
self.cover_url = cover_url
def GetTitle(self):
return self.title
def __str__(self):
return self.title
def __repr__(self):
return self.__str__()
#################################
#función loadMovieList
def loadMovieList(filename):
peliculas = abrirarchivo(filename)
movieList = []
for peli in range(len(peliculas)):
pelicula = peliculas[peli].split("|")
p = Movie(pelicula[0],pelicula[1],pelicula[2],pelicula[3],pelicula[4],pelicula[5],pelicula[6],pelicula[7],pelicula[8],pelicula[9],pelicula[10],pelicula[11],pelicula[12],pelicula[13])
movieList.append(p)
movieList.sort()
return movieList
#################################
#Abrimos el archivo
def abrirarchivo(db):
file = open(db,"r")
peliculas = file.readlines()
file.close()
return peliculas
movieList = loadMovieList('peliculas100.dat')
#Reducimos la lista de peliculas a 21 elementos
movieList = movieList[0:20]
#################################
#Stack
#Creamos la clase Stack
class Stack:
def __init__(self):
pila = []
self.sList = pila
def push(self,node):
self.sList.append(node)
return True
def pop(self):
if self.isEmpty():
return "La pila esta vacia"
else:
return self.sList.pop()
def isEmpty(self):
return len(self.sList) == 0
def printStack(self):
print self.sList
return True
#################################
#Queure
#Creamos la clase Queure
class Queure:
def __init__(self):
cola = []
self.qList = cola
def enqueue(self,node):
self.qList.append(node)
return True
def dequeue(self):
if(self.isEmpty()):
return "La cola esta vacia"
else:
node = self.qList[0]
self.qList = self.qList[1:]
return node
def isEmpty(self):
return len(self.qList) == 0
def printQ(self):
print self.qList
return True
#################################
#Test de la clase Stack()
newStack = Stack()
newStack.printStack()
newNode = movieList[0]
newStack.push(newNode)
newStack.printStack()
newStack.push(movieList[1])
newStack.printStack()
newStack.push(movieList[2])
newStack.printStack()
m1 = newStack.pop()
newStack.printStack()
m2 = newStack.pop()
newStack.printStack()
m3 = newStack.pop()
newStack.printStack()
m4 = newStack.pop()
newStack.printStack()
print m1.GetTitle()
print m2.GetTitle()
print m3.GetTitle()
##print m4.GetTitle() GUESS WHAT HAPPENS...
#################################
#Test de la clase Queure()
#newQ = Queue()
#newQ.printQ()
#newNode = Node(movieList[0])
#newQ.enqueue(newNode)
#newQ.printQ()
#newQ.enqueue(Node(movieList[1]))
#newQ.printQ()
#newQ.enqueue(Node(movieList[2]))
#newQ.printQ()
#m1 = newQ.dequeue()
#newQ.printQ()
#m2 = newQ.dequeue()
#newQ.printQ()
#m3 = newQ.dequeue()
#newQ.printQ()
#m4 = newQ.dequeue()
#newQ.printQ()
#print m1.GetTitle()
#print m2.GetTitle()
#print m3.GetTitle()
#print m4.GetTitle() GUESS WHAT HAPPENS...