def infoManga(manga = Manga): log.info("[Info Manga] %s"%manga.code) fileInfo = "%s%s/%s"%(config.CONST_PATH, manga.uCode, config.CONST_INFO_FILE) #open the file template filein = open( '%s/tpl/info.tpl'%config.CONST_PATH_SRC ) info = VolumenScan.getURLScann(manga) info = str(info).decode('utf-8') lstVol, status = VolumenScan.listaVolumenes(manga) listVol = [] countVol = int(0) countCap = int(0) for vol in lstVol: for cap in vol.capitulos: capStr = str(" > %s"%cap.name).decode('utf-8') listVol.append(capStr) countCap = countCap + 1 listVol.append("------------------------------") listVol.append(vol.name) listVol.append("------------------------------") countVol = countVol + 1 listVol = listVol[::-1] status, volinfo = VolumenScan.getMangaInfo(manga) #read it src = Template( str(filein.read()).decode('utf-8') ) #document data title = str(manga.code).decode('utf-8') cover = str(manga.cover).decode('utf-8') d={ 'title':title, 'list':'\n'.join(listVol) , 'cover' : cover, 'info' : info, 'countCap' : countCap, 'countVol' : countVol, 'status' : status, 'volinfo': volinfo} #do the substitution result = src.substitute(d) result = result.encode('utf-8') log.debug(result) file_ = open(fileInfo, 'w') file_.write(result) file_.close()