def _wahcade_write(pdo_romsets=None, po_file_fp=None): """ Function to write a list of romsets to wahcade list format. See _wahcade_read function for details about wahcade file format. :param pu_file: :type pdo_romsets: dict[unicode, roms._RomSet] :return: """ o_file = codecs.open(po_file_fp.u_path, 'w', 'utf8') for u_romset_name in lists.title_sort(pdo_romsets.keys()): # First we get the romset object o_romset = pdo_romsets[u_romset_name] # Only "full" romsets (the ones found in the database) are written to the wahcade list if o_romset: # Data preparation if o_romset.i_year != 0: u_year = unicode(o_romset.i_year) else: u_year = u'' if o_romset: #print o_romset u_output = u'' u_output += u'%s\n' % o_romset.u_name u_output += u'%s\n' % o_romset.u_desc u_output += u'%s\n' % u_year u_output += u'%s\n' % o_romset.u_auth u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' u_output += u'\n' # CatVer. In origional Wahcade lists it appears as Unknown. I'll leave it empty but # maybe I have to force "unknown" to avoid problems. o_file.write(u_output) o_file.close()
def _hqtools_write(po_dat=None, pdo_romsets=None, po_file_fp=None): """ Function to write a list of RomSets in hqtools format (HQ list, the internal format of this program). :param po_dat: RomSetContainer object (see roms.py). It's used because in the hql format, data about the dat where the roms were found is also stored. :param dict pdo_romsets: :param unicode pu_file: Name of the file. i.e. '/home/john/my_favs.lst' :return: Nothing """ o_csv = csv.ParsedCsv() o_csv.lu_headings = [u'CRC32 (c)', u'NAME'] # Comments lu_comments = [] lu_comments.append(u'%s - List File v1.0' % cons.u_SET_NAME) lu_comments.append(u'Dat Name: %s' % po_dat.u_name) lu_comments.append(u'Dat Desc: %s' % po_dat.u_description) lu_comments.append(u'Dat Ver: %s' % po_dat.u_version) lu_comments.append(u'Dat Com: %s' % po_dat.u_comment) o_csv.lu_comments = lu_comments # TODO: Check out the best way to alphabetically sort unicode texts containing spaces for u_romset_name in lists.title_sort(pdo_romsets.keys()): o_romset = pdo_romsets[u_romset_name] if o_romset: lu_data_line = [o_romset.u_ccrc32, o_romset.u_name] else: lu_data_line = [u'········', u_romset_name] o_csv.append_row(lu_data_line) o_csv.save_to_disk(pu_file=po_file_fp.u_path, pu_sep=u'\t', pu_com=u'#')