Update of /cvsroot/freevo/freevo/src/mediadb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31747

Modified Files:
        __init__.py audio_parser.py db.py debug.py item.py listing.py 
        parser.py video_parser.py 
Added Files:
        generic.py 
Removed Files:
        cache.py 
Log Message:
more improvements

Index: debug.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/debug.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** debug.py    4 Apr 2005 18:28:15 -0000       1.2
--- debug.py    10 Apr 2005 11:20:50 -0000      1.3
***************
*** 1,5 ****
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # mediainfo.py - 
  # 
-----------------------------------------------------------------------------
  # $Id$
--- 1,5 ----
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # debug.py -
  # 
-----------------------------------------------------------------------------
  # $Id$
***************
*** 30,56 ****
  # 
-----------------------------------------------------------------------------
  
- import time
  import sys
- import os
- import stat
- import mmpython
- import pickle
  import cPickle
- import re
- import logging
- import copy
- 
- from mmpython.disc.discinfo import cdrom_disc_id
- 
- import sysconfig
- import config
- import util.fxdparser
- import util.vfs as vfs
- import util.cache as cache
- from util.callback import *
- from listing import Listing
- 
- log = logging.getLogger('mediainfo')
  
  
  def print_data(data, space='    '):
--- 30,37 ----
  # 
-----------------------------------------------------------------------------
  
  import sys
  import cPickle
  
+ from mediadb import *
  
  def print_data(data, space='    '):
***************
*** 74,86 ****
      print
  
- 
- # XXX MEDIAINFO UPDATE XXX
- t1 = time.time()
  l = Listing(sys.argv[1])
! t2 = time.time()
! l.update()
! t3 = time.time()
! print 'time: %s %s' % (t2 - t1, t3 - t1)
! print
  print
  print 'Listing for %s' % l.cache.dirname
--- 55,61 ----
      print
  
  l = Listing(sys.argv[1])
! if l.num_changes:
!     l.update()
  print
  print 'Listing for %s' % l.cache.dirname

Index: parser.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/parser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** parser.py   7 Apr 2005 20:42:11 -0000       1.3
--- parser.py   10 Apr 2005 11:20:50 -0000      1.4
***************
*** 1,2 ****
--- 1,33 ----
+ # -*- coding: iso-8859-1 -*-
+ # 
-----------------------------------------------------------------------------
+ # parser.py - parsing functions to get informations about a file
+ # 
-----------------------------------------------------------------------------
+ # $Id$
+ #
+ # 
-----------------------------------------------------------------------------
+ # Freevo - A Home Theater PC framework
+ # Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
+ #
+ # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+ # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+ #
+ # Please see the file freevo/Docs/CREDITS for a complete list of authors.
+ #
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful, but
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+ # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ # Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License along
+ # with this program; if not, write to the Free Software Foundation, Inc.,
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ #
+ # 
-----------------------------------------------------------------------------
+ 
  # python imports
  import os
***************
*** 90,95 ****
  
      name = name[0].upper() + name[1:]
! 
!     while file.find('_') > 0 and _FILENAME_REGEXP.match(name):
          m = _FILENAME_REGEXP.match(name)
          if m:
--- 121,133 ----
  
      name = name[0].upper() + name[1:]
!     # check which char is the space
!     if name.count('_') == 0 and name.count(' ') == 0:
!         if name.count('.') > 4:
!             # looks like '.' is the space here
!             name = name.replace('.', '_')
!         elif name.count('-') > 4:
!             # looks like '-' is the space here
!             name = name.replace('-', '_')
!     while name.find('_') != -1 and _FILENAME_REGEXP.match(name):
          m = _FILENAME_REGEXP.match(name)
          if m:
***************
*** 108,112 ****
  
  
! def parse(basename, filename, object, quick=False):
      """
      Add additional informations to filename, object.
--- 146,150 ----
  
  
! def parse(basename, filename, object, fast_scan=False):
      """
      Add additional informations to filename, object.
***************
*** 116,120 ****
          del object['type']
      mminfo = None
!     if not quick and not object['ext'] in [ 'xml', 'fxd' ]:
          mminfo = mmpython.parse(filename)
      title = getname(filename)
--- 154,158 ----
          del object['type']
      mminfo = None
!     if not fast_scan and not object['ext'] in [ 'xml', 'fxd' ]:
          mminfo = mmpython.parse(filename)
      title = getname(filename)
***************
*** 139,144 ****
              # directory is covering a fxd file
              object['type'] = 'fxd'
!         if not quick:
!             # Create a simple (quick) cache of subdirs to get some basic idea
              # about the files inside the directory
              c = db.Cache(filename)
--- 177,182 ----
              # directory is covering a fxd file
              object['type'] = 'fxd'
!         if not fast_scan:
!             # Create a simple (fast) cache of subdirs to get some basic idea
              # about the files inside the directory
              c = db.Cache(filename)
***************
*** 193,195 ****
      for p in _parser:
          p.cache(listing)
-         
--- 231,232 ----

Index: video_parser.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/video_parser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** video_parser.py     7 Apr 2005 20:42:11 -0000       1.3
--- video_parser.py     10 Apr 2005 11:20:50 -0000      1.4
***************
*** 1,2 ****
--- 1,33 ----
+ # -*- coding: iso-8859-1 -*-
+ # 
-----------------------------------------------------------------------------
+ # video_parser.py - parsing functions for video files
+ # 
-----------------------------------------------------------------------------
+ # $Id$
+ #
+ # 
-----------------------------------------------------------------------------
+ # Freevo - A Home Theater PC framework
+ # Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
+ #
+ # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+ # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+ #
+ # Please see the file freevo/Docs/CREDITS for a complete list of authors.
+ #
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful, but
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+ # CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ # Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License along
+ # with this program; if not, write to the Free Software Foundation, Inc.,
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ #
+ # 
-----------------------------------------------------------------------------
+ 
  def parse(filename, object, mminfo):
      """

Index: db.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/db.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** db.py       7 Apr 2005 20:42:11 -0000       1.4
--- db.py       10 Apr 2005 11:20:50 -0000      1.5
***************
*** 54,61 ****
--- 54,67 ----
  
  class CacheList:
+     """
+     Internal list of all cache objects.
+     """
      def __init__(self):
          self.caches = {}
  
      def get(self, dirname):
+         """
+         Get Cache object for dirname.
+         """
          if dirname in self.caches:
              cache = self.caches[dirname]
***************
*** 67,75 ****
--- 73,86 ----
          return c
  
+ 
      def save(self):
+         """
+         Save all cache files.
+         """
          for cache in self.caches.values():
              cache.save()
  
  
+ 
  # global object
  _cache_list = CacheList()
***************
*** 77,81 ****
  class Cache:
      """
!     A cache object for the mediainfo holding one directory.
      """
      def __init__(self, dirname):
--- 88,92 ----
  class Cache:
      """
!     A cache object for the mediadb holding one directory.
      """
      def __init__(self, dirname):
***************
*** 419,426 ****
  
  def save():
      _cache_list.save()
  
  
  def get(dirname):
      return _cache_list.get(dirname)
- 
--- 430,442 ----
  
  def save():
+     """
+     Save all cache files.
+     """
      _cache_list.save()
  
  
  def get(dirname):
+     """
+     Get cache object for the given dirname.
+     """
      return _cache_list.get(dirname)

Index: item.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/item.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** item.py     7 Apr 2005 20:42:11 -0000       1.3
--- item.py     10 Apr 2005 11:20:50 -0000      1.4
***************
*** 1,5 ****
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # item.py -
  # 
-----------------------------------------------------------------------------
  # $Id$
--- 1,5 ----
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # item.py - an item returned in listings
  # 
-----------------------------------------------------------------------------
  # $Id$
***************
*** 41,59 ****
  
  # get logging object
! log = logging.getLogger('mediainfo')
  
  class ItemInfo:
      def __init__(self, basename, dirname, attr, cache=None):
          if not attr:
              attr = {}
              if basename:
                  attr['ext'] = basename[basename.rfind('.')+1:].lower()
          self.attr = attr
!         self.basename = basename
          self.tmp = {}
          self.mminfo = None
          self.hidden_variables = {}
          self.dirname = dirname
          self.filename = self.dirname + '/' + self.basename
          self.cache = cache
          if self.attr.has_key('url'):
--- 41,70 ----
  
  # get logging object
! log = logging.getLogger('mediadb')
  
  class ItemInfo:
+     """
+     Objcets of this class are returned in the different listing functions.
+     They store mediadb data and extra data only valid in the current session.
+     """
      def __init__(self, basename, dirname, attr, cache=None):
          if not attr:
+             # make sure attr is set to something valid
              attr = {}
              if basename:
                  attr['ext'] = basename[basename.rfind('.')+1:].lower()
+         # attr is the dict that will be stored in the mediadb
          self.attr = attr
!         # tmp data only valid in the current session
          self.tmp = {}
+         # mmpython data for the item
          self.mminfo = None
+         # hidden variables (FIXME)
          self.hidden_variables = {}
+         # some basic attributes
+         self.basename = basename
          self.dirname = dirname
          self.filename = self.dirname + '/' + self.basename
+         # cache this item belongs to (needed for saving)
          self.cache = cache
          if self.attr.has_key('url'):
***************
*** 62,70 ****
--- 73,88 ----
              self.url = 'file://' + self.filename
  
+ 
      def __str__(self):
+         """
+         String function for debugging.
+         """
          return self.basename
  
  
      def __getitem__(self, key):
+         """
+         Get the itnformation 'key' from the item.
+         """
          if key in ('cover', 'audiocover'):
              if self.attr.has_key(key):
***************
*** 80,86 ****
          if self.hidden_variables.has_key(key):
              return self.hidden_variables[key]
-         if not self.attr.has_key('mminfo'):
-             return None
          if self.mminfo == None:
              log.debug('unpickle %s' % self.basename)
              self.mminfo = cPickle.loads(self.attr['mminfo'])
--- 98,105 ----
          if self.hidden_variables.has_key(key):
              return self.hidden_variables[key]
          if self.mminfo == None:
+             # unpickle mmpython data
+             if not self.attr.has_key('mminfo'):
+                 return None
              log.debug('unpickle %s' % self.basename)
              self.mminfo = cPickle.loads(self.attr['mminfo'])
***************
*** 92,95 ****
--- 111,119 ----
  
      def __setitem__(self, key, value):
+         """
+         Set information. If the key is in attr, the data will be stored in
+         the mediadb, else the tmp dict will be used and the information is
+         valid only in this object and won't be saved.
+         """
          if self.attr.has_key(key):
              self.attr[key] = value
***************
*** 102,105 ****
--- 126,132 ----
  
      def has_key(self, key):
+         """
+         Check if 'key' is in the item somewhere.
+         """
          if key in ('cover', 'audiocover'):
              return True
***************
*** 110,116 ****
          if self.hidden_variables.has_key(key):
              return True
-         if not self.attr.has_key('mminfo'):
-             return False
          if self.mminfo == None:
              log.debug('unpickle %s' % self.basename)
              self.mminfo = cPickle.loads(self.attr['mminfo'])
--- 137,144 ----
          if self.hidden_variables.has_key(key):
              return True
          if self.mminfo == None:
+             # unpickle mmpython data
+             if not self.attr.has_key('mminfo'):
+                 return False
              log.debug('unpickle %s' % self.basename)
              self.mminfo = cPickle.loads(self.attr['mminfo'])
***************
*** 122,125 ****
--- 150,156 ----
  
      def keys(self):
+         """
+         Return a list of valid keys.
+         """
          ret = [ 'cover', 'audiocover' ]
          if self.mminfo == None:
***************
*** 137,140 ****
--- 168,174 ----
  
      def store(self, key, value):
+         """
+         Store key/value in the mediadb for later use.
+         """
          self.attr[key] = value
          if self.cache:
***************
*** 145,148 ****
--- 179,187 ----
  
      def store_with_mtime(self, key, value):
+         """
+         Store key/value in the mediadb for later use. The storage depends on
+         the modification of the item. If the item is modified on disc, the
+         data will be deleted.
+         """
          self.attr[key] = value
          if self.cache:
***************
*** 165,168 ****
--- 204,221 ----
          self.hidden_variables = variables
  
+ 
      def delete(self, key):
          pass
+ 
+ 
+     def get_subitem(self, id):
+         """
+         Get a subitem if the given id.
+         """
+         if not self.attr.has_key('subitems'):
+             # create 'subitems' info
+             self.store_with_mtime('subitems', {})
+         if not self.attr['subitems'].has_key(id):
+             self.attr['subitems'][id] = {}
+         info = self.attr['subitems'][id]
+         return ItemInfo(self.basename, self.dirname, info, self.cache)

--- NEW FILE: generic.py ---
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
# generic - Generic 'get' function for mediadb object
# -----------------------------------------------------------------------------
# $Id: generic.py,v 1.1 2005/04/10 11:20:50 dischi Exp $
#
# TODO: o add InfoItem for / and network url
#
# -----------------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al.
#
# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
#
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------------

__all__ = [' get' ]

# python imports
import os
import logging

# mmpython
from mmpython.disc.discinfo import cdrom_disc_id

# freevo imports
import sysconfig
import util

# mediadb imports
from db import FileCache
from item import ItemInfo
from listing import FileListing

# get logging object
log = logging.getLogger('mediadb')


def disc_info(media):
    """
    Return information for the media
    """
    type, id  = cdrom_disc_id(media.devicename)
    if not id:
        # bad disc, e.g. blank disc
        return ItemInfo(None, None, None)
    cachefile = os.path.join(sysconfig.VFS_DIR, 'disc/metadata/%s.db' % id)
    cache = FileCache(media.devicename, cachefile)
    info = ItemInfo('', '', cache.data, cache)
    info.filename = info['mime'][6:] + '://'
    if info['mime'] in ('video/vcd', 'video/dvd'):
        return info

    # Disc is data of some sort. Mount it to get the file info
    util.mount(media.mountdir, force=True)
    if os.path.isdir(os.path.join(media.mountdir, 'VIDEO_TS')) or \
           os.path.isdir(os.path.join(media.mountdir, 'video_ts')):
        # looks like a DVD but is not detected as one, check again
        log.info('Undetected DVD, checking again')
        cache = FileCache(media.devicename, cachefile)
        info = ItemInfo('', '', cache.data, cache)
        info.filename = info['mime'][6:] + '://'
        if info['mime'] in ('video/vcd', 'video/dvd'):
            util.umount(media.mountdir)
            return info
    # save directory listing in item
    info['listing'] = os.listdir(media.mountdir)
    util.umount(media.mountdir)
    # set correct dirname / filename
    info.dirname = media.mountdir
    info.filename = info.dirname + '/' + info.basename
    info.url = 'file://' + info.filename
    return info


def get(filename):
    """
    Get information about filename. Filename can be a real filename, an url
    or a media object for disc detection.
    """
    if hasattr(filename, 'mountdir'):
        # filename is a media object
        return disc_info(filename)
    if filename.startswith('file://'):
        filename = filename[7:]
    if filename != '/':
        # get normal info using directory listing
        listing = FileListing( [ filename ] )
        if listing.num_changes:
            listing.update()
        return listing.get_by_name(os.path.basename(filename))
    # filename is either '/' or an url
    # FIXME: create cache for these types
    return ItemInfo('', '', None)

Index: audio_parser.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/audio_parser.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** audio_parser.py     7 Apr 2005 20:42:11 -0000       1.4
--- audio_parser.py     10 Apr 2005 11:20:50 -0000      1.5
***************
*** 86,90 ****
      else:
          # no changes in all subdirs, looks good
!         if dirinfo['length'] != None and 0:
              # Since 'length' is not None and the info is stored with mtime,
              # no changes in here. Do not parse everything again
--- 86,90 ----
      else:
          # no changes in all subdirs, looks good
!         if dirinfo['length'] != None:
              # Since 'length' is not None and the info is stored with mtime,
              # no changes in here. Do not parse everything again

Index: listing.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/listing.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** listing.py  7 Apr 2005 20:42:11 -0000       1.4
--- listing.py  10 Apr 2005 11:20:50 -0000      1.5
***************
*** 1,5 ****
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # mediainfo.py - 
  # 
-----------------------------------------------------------------------------
  # $Id$
--- 1,5 ----
  # -*- coding: iso-8859-1 -*-
  # 
-----------------------------------------------------------------------------
! # listing.py -
  # 
-----------------------------------------------------------------------------
  # $Id$
***************
*** 43,46 ****
--- 43,51 ----
  
  class Listing:
+     """
+     A directory listing with items from the mediadb. After creating a listing,
+     check the 'num_changes' variable. If it is greater zero, the listing is
+     invalid until update() is called.
+     """
      def __init__(self, dirname):
          try:
***************
*** 63,70 ****
  
  
!     def update(self, callback=None, quick=False):
          if self.num_changes == 0:
              return
!         if quick:
              self.cache.add_missing()
          else:
--- 68,81 ----
  
  
!     def update(self, callback=None, fast=False):
!         """
!         Update the directory listing. This means parsing all changed / new
!         files. If fast is True, only new files will be updated and mmpython
!         checking is disabled. The listing is still not correct then. If
!         callback not not None, callback will be called on each item.
!         """
          if self.num_changes == 0:
              return
!         if fast:
              self.cache.add_missing()
          else:
***************
*** 79,82 ****
--- 90,96 ----
  
      def get_dir(self):
+         """
+         Return all directory items.
+         """
          ret = filter(lambda x: x.attr.has_key('isdir'), self.visible)
          self.visible = filter(lambda x: not x.attr.has_key('isdir'),
***************
*** 86,89 ****
--- 100,106 ----
  
      def remove(self, item_or_name):
+         """
+         Remove the given item from the list of visible items.
+         """
          if isinstance(item_or_name, ItemInfo):
              self.visible.remove(item_or_name)
***************
*** 97,102 ****
--- 114,123 ----
  
      def get_by_name(self, name):
+         """
+         Get an item by name.
+         """
          for item in self.visible:
              if item.basename == name:
+                 self.visible.remove(item)
                  return item
          return None
***************
*** 104,107 ****
--- 125,131 ----
  
      def match_suffix(self, suffix_list):
+         """
+         Return all items with a suffix in the suffix list.
+         """
          visible = self.visible
          self.visible = []
***************
*** 114,117 ****
--- 138,146 ----
  
      def match_type(self, type):
+         """
+         Return all items with the given type. Note: most items have no type
+         set and can't be returned by this function. Use match_suffix in this
+         case.
+         """
          visible = self.visible
          self.visible = []
***************
*** 127,138 ****
  
      def reset(self):
          self.visible = self.data
  
!         
      def __iter__(self):
          return self.visible.__iter__()
!     
  
  class FileListing(Listing):
      def __init__(self, files):
          self.caches = {}
--- 156,178 ----
  
      def reset(self):
+         """
+         Reset listing by setting all items in the directory visible again.
+         """
          self.visible = self.data
  
! 
      def __iter__(self):
+         """
+         Walk through all visible items.
+         """
          return self.visible.__iter__()
! 
! 
! 
  
  class FileListing(Listing):
+     """
+     A listing containing files from different directories.
+     """
      def __init__(self, files):
          self.caches = {}
***************
*** 161,170 ****
              cache.reduce(files)
              self.num_changes += cache.num_changes()
!             
          self.data = []
          if self.num_changes > 0:
              self.visible = []
              return
!             
          for dirname, ( cache, all_files ) in self.caches.items():
              for basename, item in cache.list():
--- 201,210 ----
              cache.reduce(files)
              self.num_changes += cache.num_changes()
! 
          self.data = []
          if self.num_changes > 0:
              self.visible = []
              return
! 
          for dirname, ( cache, all_files ) in self.caches.items():
              for basename, item in cache.list():
***************
*** 175,178 ****
--- 215,221 ----
  
      def update(self, callback=None):
+         """
+         Update the listing.
+         """
          for dirname, ( cache, all_files ) in self.caches.items():
              cache.parse(callback)

Index: __init__.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/mediadb/__init__.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** __init__.py 5 Apr 2005 18:48:17 -0000       1.3
--- __init__.py 10 Apr 2005 11:20:41 -0000      1.4
***************
*** 5,14 ****
  # $Id$
  #
! # TODO: o remove old functions (see below)
! #       o include extendedmeta
! #       o add SQLListing
  #       o maybe preload whole cache? Expire cache?
  #       o add InfoItem for / and network url
- #       o add InfoItem for subditems
  #
  # 
-----------------------------------------------------------------------------
--- 5,11 ----
  # $Id$
  #
! # TODO: o add SQLListing
  #       o maybe preload whole cache? Expire cache?
  #       o add InfoItem for / and network url
  #
  # 
-----------------------------------------------------------------------------
***************
*** 37,89 ****
  # 
-----------------------------------------------------------------------------
  
! # python imports
! import os
! import logging
! 
! # mmpython
! from mmpython.disc.discinfo import cdrom_disc_id
! 
! # freevo imports
! import sysconfig
  
- # mediadb imports
  from db import Cache, FileCache, save
  from item import ItemInfo
  from listing import Listing, FileListing
  from parser import cache, init
! 
! # get logging object
! log = logging.getLogger('mediadb')
  
  # init parsing module
  init()
- 
- def disc_info(media, force=False):
-     """
-     Return information for the media
-     """
-     type, id  = cdrom_disc_id(media.devicename)
-     if not id:
-         # bad disc, e.g. blank disc
-         return ItemInfo(None, None, None)
-     cachefile = os.path.join(sysconfig.VFS_DIR, 'disc/metadata/%s.db' % id)
-     if force and os.path.isfile(cachefile):
-         os.unlink(cachefile)
-     cache = FileCache(media.devicename, cachefile)
-     info = ItemInfo('', '', cache.data, cache)
-     info.filename = info['mime'][6:] + '://'
-     return info
- 
- 
- #
- # FIXME: the following function will be removed in the future
- # also missing the attribute mmdata used by videoitem.py
- #
- 
- def get(filename):
-     # used by directory.py, item.py
-     log.warning('get simple info %s', filename)
-     listing = FileListing( [ filename ] )
-     if listing.num_changes:
-         listing.update()
-     return listing.get_by_name(os.path.basename(filename))
--- 34,46 ----
  # 
-----------------------------------------------------------------------------
  
! __all__ = [ 'Cache', 'FileCache', 'save', 'ItemInfo', 'Listing', 
'FileListing',
!             'cache', 'get' ]
  
  from db import Cache, FileCache, save
  from item import ItemInfo
  from listing import Listing, FileListing
  from parser import cache, init
! from generic import get
  
  # init parsing module
  init()

--- cache.py DELETED ---



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to