Update of /cvsroot/freevo/freevo/src/games
In directory sc8-pr-cvs1:/tmp/cvs-serv456

Modified Files:
        mame_cache.py mame_types.py 
Log Message:
Removing the need for the rominfo program.  Now we parse the output of
xmame --listinfo directly and build a list of all supported MAME roms.
This should only need to be updated when you upgrade xmame and you should
remove your existing romlist-n.pickled.


Index: mame_cache.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/games/mame_cache.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** mame_cache.py       24 Apr 2003 19:56:11 -0000      1.5
--- mame_cache.py       20 Jun 2003 01:33:56 -0000      1.6
***************
*** 10,13 ****
--- 10,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.6  2003/06/20 01:33:56  rshortt
+ # Removing the need for the rominfo program.  Now we parse the output of
+ # xmame --listinfo directly and build a list of all supported MAME roms.
+ # This should only need to be updated when you upgrade xmame and you should
+ # remove your existing romlist-n.pickled.
+ #
  # Revision 1.5  2003/04/24 19:56:11  dischi
  # comment cleanup for 1.3.2-pre4
***************
*** 66,69 ****
--- 72,77 ----
  import re
  
+ from gui.PopupBox import PopupBox
+ 
  # Set to 1 for debug output
  DEBUG = config.DEBUG
***************
*** 111,115 ****
          mameRomList = mame_types.MameRomList()
  
!     pickle.dump(mameRomList, open(config.MAME_CACHE, 'w'))
      
  
--- 119,129 ----
          mameRomList = mame_types.MameRomList()
  
!     try: 
!         pickle.dump(mameRomList, open(config.MAME_CACHE, 'w'), 1)
!     except:
!         print 'strange cPickle error...try pickle'
!       import pickle as pypickle
!       pypickle.dump(mameRomList, open(config.MAME_CACHE, 'w'), 1)
! 
      
  
***************
*** 119,202 ****
  # the cache has any relevant information.
  #
! def updateMameRomList(mame_files):
!     mameRomList = getMameRomList()
! 
!     cache = mameRomList.getMameRoms()
! 
!     # We can use the trashme propery to uncache roms
!     # that we no longer care about.
!     for rom in cache.values():
!         if rom.getTrashme == 1:
!             del cache[rom.getFilename()]
! 
!     for mame_file in mame_files:
!         # Now we only have to run rominfo if we do not know
!         # about the rom in question.
! 
!         if not cache.has_key(mame_file):
! 
!             # If there is a real game title available 
!             # title will get overwritten.
!             title = os.path.splitext(os.path.basename(mame_file))[0]
! 
!             dirname = '' # not supported yet
!             image = None
! 
!             # This replace stuff is a bit crude, someone may like to clean
!             # it up.  The popen will barf on these characters if they
!             # are not escaped.
!             ri_args = string.replace(mame_file, " ", "\ ")
!             ri_args = string.replace(ri_args, "(", "\(")
!             ri_args = string.replace(ri_args, ")", "\)")
! 
!             rominfo = os.popen('./src/games/rominfo/rominfo ' + ri_args, 'r')
!             matched = 0
!             partial = 0
! 
!             for line in rominfo.readlines():
!                 if string.find(line, 'Error:') != -1:
!                     print 'MAME:rominfosrc: "%s"' % line.strip()
!                     print 'we do not care about (Error): %s' % mame_file
!                     continue
!                 if string.find(line, 'ERROR:') != -1:
!                     print 'MAME:rominfosrc: "%s"' % line.strip()
!                     print 'we do not care about (ERROR): %s' % mame_file
!                     continue
!                 if string.find(line, 'KNOWN:') != -1:
!                     print 'MAME:rominfosrc: "%s"' % line.strip()
!                     matched = 1
!                 if string.find(line, 'PARTIAL:') != -1:
!                     print 'MAME:rominfosrc: "%s"' % line.strip()
!                     partial = 1
!                 if string.find(line, 'DESCRIPTION:') != -1:
!                     # If we have a real title we will use that 
!                     # instead of the filename.
!                     title = line.strip()
!                     print 'MAME:rominfosrc: "%s"' % title
!                     title = string.replace(title, 'DESCRIPTION:  ', '')
! 
!             rominfo.close()
  
  
!             if matched == 1 or partial == 1:
!                 # find image for this file
!                 if os.path.isfile(os.path.splitext(mame_file)[0] + ".png"):
!                     image = os.path.splitext(mame_file)[0] + ".png"
!                 elif os.path.isfile(os.path.splitext(mame_file)[0] + ".jpg"):
!                     image = os.path.splitext(mame_file)[0] + ".jpg"
  
!             newRom = mame_types.MameRom()
  
!             newRom.setTitle(title)
!             newRom.setFilename(mame_file)
!             newRom.setDirname(dirname)
!             newRom.setMatched(matched)
!             newRom.setPartial(partial)
!             newRom.setImageFile(image)
!     
!             # Add the new rom to the cache.
!             cache[mame_file] = newRom
  
!     # Update our cache and save it.
      mameRomList.setMameRoms(cache)
      saveMameRomList(mameRomList)
--- 133,171 ----
  # the cache has any relevant information.
  #
! def updateMameRomList():
  
+     try:
+         listinfo = os.popen(config.MAME_CMD + ' --listinfo', 'r')
+     except:
+         print 'Unable to get mame listinfo.'
+       return FALSE
  
!     newRom = mame_types.MameRom()
!     cache = {}
  
!     for line in listinfo.readlines():
!         if re.compile("^\tname").match(line):
!             newRom.name = re.compile("^\tname (.*)").match(line).group(1)
!         elif re.compile("^\tdescription").match(line):
!             newRom.description = re.compile("^\tdescription 
(.*)").match(line).group(1)[1:-1]
!         elif re.compile("^\tyear").match(line):
!             newRom.year = re.compile("^\tyear (.*)").match(line).group(1)
!         elif re.compile("^\tmanufacturer").match(line):
!             newRom.manufacturer = re.compile("^\tmanufacturer 
(.*)").match(line).group(1)[1:-1]
!         elif re.compile("^\tcloneof").match(line):
!             newRom.cloneof = re.compile("^\tcloneof (.*)").match(line).group(1)
!         elif re.compile("^\tromof").match(line):
!             newRom.romof = re.compile("^\tromof (.*)").match(line).group(1)
!         elif re.compile("^game \(").match(line):
!             # We've reached a new game so dump everthing we have so far
!             if newRom.name:
!                 # add the new rom to the cache.
!                 cache[newRom.name] = newRom
!                 # make a new mameRom
!                 newRom = mame_types.MameRom()
  
!     listinfo.close()
  
!     mameRomList = mame_types.MameRomList()
      mameRomList.setMameRoms(cache)
      saveMameRomList(mameRomList)
***************
*** 212,226 ****
      rm_files = []
  
!     # make sure the rom list is up to date.
!     updateMameRomList(mame_files)
      mameRomList = getMameRomList()
      roms = mameRomList.getMameRoms()
  
!     # for romkey in roms.keys():
!     for romkey in mame_files:
!         if roms.has_key(romkey):
!             rom = roms[romkey]
!             items += [(rom.getTitle(), rom.getFilename(), rom.getImageFile())]
!             rm_files.append(romkey)
      
      return (rm_files, items)
--- 181,200 ----
      rm_files = []
  
!     # Only build the cache if it doesn't exis.
!     if not os.path.isfile(config.MAME_CACHE):
!         waitmsg = PopupBox(text='Generating MAME cache, please wait.')
!       waitmsg.show()
!         updateMameRomList()
!       waitmsg.destroy()
! 
      mameRomList = getMameRomList()
      roms = mameRomList.getMameRoms()
  
!     for romfile in mame_files:
!         key = os.path.splitext(os.path.basename(romfile))[0]
!         if roms.has_key(key):
!             rom = roms[key]
!             items += [(rom.description, romfile, None)]
!             rm_files.append(romfile)
      
      return (rm_files, items)

Index: mame_types.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/games/mame_types.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** mame_types.py       24 Apr 2003 19:56:12 -0000      1.3
--- mame_types.py       20 Jun 2003 01:33:56 -0000      1.4
***************
*** 11,14 ****
--- 11,20 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.4  2003/06/20 01:33:56  rshortt
+ # Removing the need for the rominfo program.  Now we parse the output of
+ # xmame --listinfo directly and build a list of all supported MAME roms.
+ # This should only need to be updated when you upgrade xmame and you should
+ # remove your existing romlist-n.pickled.
+ #
  # Revision 1.3  2003/04/24 19:56:12  dischi
  # comment cleanup for 1.3.2-pre4
***************
*** 50,54 ****
  # The file format version number. It must be updated when incompatible
  # changes are made to the file format.
! TYPES_VERSION = 1
  
  # Set to 1 for debug output
--- 56,60 ----
  # The file format version number. It must be updated when incompatible
  # changes are made to the file format.
! TYPES_VERSION = 2
  
  # Set to 1 for debug output
***************
*** 61,71 ****
  class MameRom:
  
!     filename = ''
!     dirname = ''
!     title = ''
!     imageFile = ''
!     partial = 0
!     matched = 0
!     trashme = 0
  
      def getFilename(self):
--- 67,80 ----
  class MameRom:
  
!     def __init__(self):
!         self.filename = ''
!         self.title = ''
!         self.name = ''
!         self.description = ''
!         self.year = ''
!         self.manufacturer = ''
!         self.cloneof = ''
!         self.romof = ''
! 
  
      def getFilename(self):




-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to