def __init__(self, session=None): config = Config() if session is not None: self.session = session else: self.session = Entidades.Init.Session() self.comicVineSearcher = ComicVineSearcher( config.getClave('publishers'), session=self.session) self.comicVineSearcher.setEntidad("publishers") self.handlers = { 'click_boton_buscar_mas': self.click_boton_buscar_mas, 'selection': self.selection, 'click_boton_aceptar': self.click_boton_aceptar, 'click_boton_buscar': self.click_boton_buscar } self.builder = Gtk.Builder() self.builder.add_from_file( "../Glade_files/Publisher_vine_search_gtk.glade") self.builder.connect_signals(self.handlers) self.window = self.builder.get_object("Publisher_vine_search_Gtk") self.window.set_icon_from_file('../iconos/BabelComic.png') self.entry_nombre = self.builder.get_object('entry_nombre') self.spinner = self.builder.get_object('spinner') self.publisher_logo_image = self.builder.get_object( 'publisher_logo_image') self.listmodel_publishers = Gtk.ListStore(str, str) self.gtk_tree_view_publisher = self.builder.get_object( 'gtk_tree_view_publisher')
def agregarVolumen(self): cnf = Config(self.session) cv = ComicVineSearcher(cnf.getClave('volume'), self.session) cv.entidad = 'volume' volumenAndIssues = cv.getVineEntity(self.volume.id) self.session.query(ComicInVolumes).filter( ComicInVolumes.volumeId == self.volume.id).delete() for index, numeroComic in enumerate(volumenAndIssues[1], start=0): numeroComic.offset = int(index / 100) self.session.add(numeroComic) self.session.add(volumenAndIssues[0]) self.session.commit()
def copiarInfo(self): cnf = Config(self.session) print('clave: ' + cnf.getClave('issue')) cv = ComicVineSearcher(cnf.getClave('issue'),session=self.session) cv.setEntidad('issue') completComicInfo = cv.getVineEntity(self.comicBookVine.idExterno) self.comicbook = self.session.query(ComicBook).filter(ComicBook.path==self.comicbook.path).first() catalogador = Catalogador(self.session) catalogador.copyFromComicToComic(completComicInfo,self.comicbook) self.setup.ultimoNumeroConsultadoHasta = self.entryNumeroHasta.get() self.setup.ultimoNumeroConsultadoDesde = self.entryNumeroDesde.get() self.setup.ultimoVolumeIdUtilizado = self.entrySerie.get() self.setup.expresionRegularNumero = self.entryPathRe.get() print(self.setup) self.session.commit()
def __init__(self, session=None): config = Config() self.listaFiltrada = [] if session is None: self.session = Entidades.Init.Session() else: self.session = session self.comicVineSearcher = ComicVineSearcher(config.getClave('volumes'), session=self.session) self.comicVineSearcher.setEntidad("volumes") self.publishers_manager = Publishers() self.handlers = { 'click_lookup_editorial': self.click_lookup_editorial, 'click_buscar_serie': self.click_buscar_serie, 'click_buscar_mas_serie': self.click_buscar_mas_serie, 'click_aceptar': self.click_aceptar, 'entry_id_editorial_change': self.entry_id_editorial_change, 'seleccion': self.seleccion, 'click_detener': self.click_detener, 'intro_detection': self.intro_detection } self.builder = Gtk.Builder() self.builder.add_from_file( "../Glade_files/Volumen_vine_search_gtk.glade") self.builder.connect_signals(self.handlers) self.window = self.builder.get_object("Volumen_vine_search_Gtk") self.window.set_icon_from_file('../iconos/BabelComic.png') self.entry_serie_nombre = self.builder.get_object("entry_serie_nombre") self.label_descripcion_editorial = self.builder.get_object( "label_descripcion_editorial") self.entry_id_editorial = self.builder.get_object("entry_id_editorial") self.gtk_tree_view_volumens = self.builder.get_object( "gtk_tree_view_volumens") self.listmodel_volumenes = self.builder.get_object( 'listmodel_volumenes') self.listmodel_volumenes.clear() self.label_status = self.builder.get_object("label_status") self.volume_logo_image = self.builder.get_object("volumen_logo_image") self.spinner = self.builder.get_object("spinner") self.volume = None self.publisher = None self.cargarResultado(self.listmodel_volumenes)
def copiarInfoGrupo(self): cantidadZeros=0 for comic in self.comicbooks: if comic.numero == 0: cantidadZeros+=1 if cantidadZeros>1: print("hay mas de un cero en la lista a catalogar. Se anula el proceso") return cnf = Config(self.session) print('clave: ' + cnf.getClave('issue')) cv = ComicVineSearcher(cnf.getClave('issue'),session=self.session) cv.setEntidad('issue') catalogador = Catalogador(self.session) for comic in self.comicbooks: print("Vamos a ACTUALIZAR EL COMIC") print(comic) comicInfo=None '''Buscamos en la lista de Vine el numero de comic''' for comicVine in self.listaAMostrar: if comicVine.numero==comic.numero: comicInfo = comicVine break print("Encontramos el comic:") print(comicInfo) '''Si existe lo catalogamos''' if comicInfo is not None: print("LA INFO COMPLETA") print(comicInfo) cv.setEntidad('issue') completComicInfo = cv.getVineEntity(comicInfo.comicVineId) comicbook = self.session.query(ComicBook).filter(ComicBook.path==comic.path).first() catalogador.copyFromComicToComic(completComicInfo,comicbook) for item in self.listViewComics.get_children(): if completComicInfo.numero == self.listViewComics.item(item, 'text'): print("ACTUALIZANDO GUI") t = threading.Thread(target=self.updateGui, args=[item]) t.start() self.setup.ultimoNumeroConsultadoHasta = self.entryNumeroHasta.get() self.setup.ultimoNumeroConsultadoDesde = self.entryNumeroDesde.get() self.setup.ultimoVolumeIdUtilizado = self.entrySerie.get() self.setup.expresionRegularNumero = self.entryPathRe.get() print(self.setup) self.session.commit()
def updateVolume(self): cnf = Config(self.session) cv = ComicVineSearcher(cnf.getClave('volume'),session=self.session) cv.entidad='volume' volumenAndComics = cv.getVineEntity(self.volume.id) volumeUpdated = volumenAndComics[0] self.volume.cantidadNumeros = volumeUpdated.cantidadNumeros self.volume.nombre = volumeUpdated.nombre print(volumeUpdated.image_url) self.volume.image_url = volumeUpdated.image_url self.volume.publisher_name = volumeUpdated.publisher_name self.volume.publisherId = volumeUpdated.publisherId self.setVolume(self.volume) self.loadVolume() self.numerosPorVolumen = volumenAndComics[1] self.guardar()
def itemClicked(self, event): if (self.grillaComics.selection): item = self.grillaComics.item(self.grillaComics.selection()) cnf = Config(self.session) cv = ComicVineSearcher(cnf.getClave('issues'), session=self.session) cv.setEntidad('issues') print(item['values'][2]) cv.addFilter("id:"+str(item['values'][2])) cv.vineSearch() webImage = cv.listaBusquedaVine[0].thumb_url nombreImagen = webImage[webImage.rindex('/') + 1:] print(webImage) print(nombreImagen) path = self.setup.directorioBase + os.sep + "images" + os.sep + "searchCache" + os.sep if not (os.path.isfile(path + nombreImagen)): print('no existe') print(nombreImagen) # path = setup.directorioBase + os.sep + "images"+ os.sep+"searchCache" + os.sep jpg = urllib.request.urlopen(webImage) jpgImage = jpg.read() fImage = open(path + nombreImagen, 'wb') fImage.write(jpgImage) fImage.close() fImage = open(path + nombreImagen, 'rb') im = Image.open(fImage) # print(item['values'][8],item['values'][4]) self.comicBookVine = ComicBook() self.comicBookVine.path = 'Path' self.comicBookVine.titulo = str(item['values'][1]) self.comicBookVine.volumeId = self.entrySerie.get() self.comicBookVine.numero = item['values'][0] #self.comicBookVine.fechaTapa = item['values'][0] #self.comicBookVine.resumen = item['values'][2] self.comicBookVine.idExterno = item['values'][2] self.panelVineComic = self.__createPanelComic__(self, self.comicBookVine, im.resize(self.size), 'Vine Info') self.panelVineComic.grid(column=2, row=0, sticky=(N, S, E, W))
def __init__(self, parent, session=None, cnf={}, **kw): Frame.__init__(self, parent, cnf, **kw) config = Config() self.iconos = Iconos() if session is None: self.session = Entidades.Init.Session() else: self.session = session self.comicVineSearcher = ComicVineSearcher( config.getClave('publishers'), session=self.session) self.comicVineSearcher.setEntidad("publishers") self.labelId = Label(self, text="Nombre Editorial: ") self.labelId.grid(row=0, column=0, sticky=W, padx=5, pady=5) self.entradaNombreEditorial = Entry(self, width=50) self.varID = StringVar() self.entradaNombreEditorial.grid(row=0, column=1, sticky=W + E, padx=5, pady=5, columnspan=2) self.botonLookupPublisher = Button(self, command=self.buscar) self.botonLookupPublisher.grid(row=0, column=3) self.pilImagenLookup = self.iconos.pilImagenLookup self.imageLookup = PIL.ImageTk.PhotoImage(self.pilImagenLookup) self.botonLookupPublisher.config(image=self.imageLookup) self.labelImagen = Label(self, text="logo edtorial") self.coverSize = (150, 150) self.labelImagen.grid(column=4, row=1) ##config grilla series self.panelGrilla = Frame(self) self.panelGrilla.grid(column=0, row=1, columnspan=3, sticky=(N, S, E, W), padx=5) self.grillaPublishers = ttk.Treeview(self.panelGrilla, columns=('Id', 'Nombre'), displaycolumns=('Id', 'Nombre')) self.grillaPublishers.grid(column=0, row=0, columnspan=3, sticky=(N, S, E, W)) self.grillaPublishers.bind( '<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() scrollGrid = ttk.Scrollbar(self.panelGrilla, orient=VERTICAL, command=self.grillaPublishers.yview) scrollGrid.grid(column=3, row=0, sticky=(N, S)) self.grillaPublishers.configure(yscrollcommand=scrollGrid.set) self.grillaPublishers.heading('Id', text='Id') self.grillaPublishers.heading('Nombre', text='Nombre') self.grillaPublishers.config(show='headings') # tree, headings self.botonLookupPublisher = Button(self, text="agregar", command=self.agregarEditorial) self.botonLookupPublisher.grid(row=2, column=3, pady=3, sticky=(E))
def __init__(self, parent, session=None, cnf={}, **kw): Frame.__init__(self, parent, cnf, **kw) config = Config() iconos = Iconos.Iconos() self.pilImagenLookup = iconos.pilImagenLookup self.imageLookup = PIL.ImageTk.PhotoImage(self.pilImagenLookup) self.offset = 0 self.frameParametros = Frame(self) self.frameParametros.grid(row=0, column=0, sticky=(W, E, N, S)) self.listaFiltrada = [] if session is None: self.session = Entidades.Init.Session() else: self.session = session self.comicVineSearcher = ComicVineSearcher(config.getClave('volumes'), session=self.session) self.comicVineSearcher.setEntidad("volumes") self.labelId = Label(self.frameParametros, text="Nombre Volumen: ") self.labelId.grid(row=0, column=0, sticky=(W, E), padx=5, pady=5) self.entradaNombreVolume = Entry(self.frameParametros, width=70) self.entradaNombreVolume.grid(column=1, row=0) Label(self.frameParametros, text="Editorial: ").grid(row=1, column=0, sticky=W, padx=5, pady=5) self.varID = StringVar() self.entradaNombreEditorial = Entry(self.frameParametros, width=30) self.entradaNombreEditorial.grid(row=1, column=1, sticky=W + E, padx=5, pady=5) self.botonBuscar = Button(self.frameParametros, text='buscar', command=self.buscar) self.botonBuscar.grid(row=0, column=3) self.botonBuscar = Button(self.frameParametros, text='buscar mas', command=self.buscarMas) self.botonBuscar.grid(row=0, column=4) self.botonLookupPublisher = Button(self.frameParametros, image=self.imageLookup, command=self.openLookupPublisher) self.botonLookupPublisher.grid(row=1, column=3) self.labelImagen = Label(self, text="cover volumen") self.coverSize = (150, 250) self.labelImagen.grid(column=4, row=1) self.volume = None self.publisher = None # # ##config grilla series self.panelGrilla = Frame(self) self.panelGrilla.grid(column=0, row=1, sticky=(N, S, E, W), padx=5) self.grillaVolumes = ttk.Treeview( self.panelGrilla, columns=('name', 'count_of_issues', 'description', 'Id', 'image', 'publisher', 'start_year'), displaycolumns=('Id', 'name', 'count_of_issues', 'publisher', 'start_year')) self.grillaVolumes.grid(column=0, row=0, columnspan=3, sticky=(N, S, E, W)) self.grillaVolumes.bind( '<<TreeviewSelect>>', self.itemClicked) # the item clicked can be found via tree.focus() scrollGrid = ttk.Scrollbar(self.panelGrilla, orient=VERTICAL, command=self.grillaVolumes.yview) scrollGrid.grid(column=3, row=0, sticky=(N, S, E, W), columnspan=2) self.grillaVolumes.configure(yscrollcommand=scrollGrid.set) self.grillaVolumes.heading('Id', text='Id', command=lambda: self.treeview_sort_column( self.grillaVolumes, 'Id', False)) self.grillaVolumes.heading('name', text='Nombre', command=lambda: self.treeview_sort_column( self.grillaVolumes, 'name', False)) self.grillaVolumes.heading( 'count_of_issues', text='Numeros', command=lambda: self.treeview_sort_column( self.grillaVolumes, 'count_of_issues', False)) self.grillaVolumes.heading('publisher', text='Editorial', command=lambda: self.treeview_sort_column( self.grillaVolumes, 'publisher', False)) self.grillaVolumes.heading( 'start_year', text='Año', command=lambda: self.treeview_sort_column(self.grillaVolumes, 'start_year', False)) self.grillaVolumes.config(show='headings') # tree, headings self.botonLookupPublisher = Button(self, text="agregar", command=self.agregarVolumen) self.botonLookupPublisher.grid(row=0, column=4, pady=3, sticky=(E, W)) self.statusBar = Label(self, text='status', relief=GROOVE, anchor=E) self.statusBar.grid(column=0, row=4, sticky=(E, W), columnspan=5)