home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / apt / cdrom.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.6 KB  |  70 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Classes related to cdrom handling.'''
  5. import glob
  6. import apt_pkg
  7. from apt.progress import CdromProgress
  8.  
  9. class Cdrom(object):
  10.     '''Support for apt-cdrom like features.
  11.  
  12.     This class has several optional parameters for initialisation, which may
  13.     be used to influence the behaviour of the object:
  14.  
  15.     The optional parameter `progress` is a CdromProgress() subclass, which will
  16.     ask for the correct cdrom, etc. If not specified or None, a CdromProgress()
  17.     object will be used.
  18.  
  19.     The optional parameter `mountpoint` may be used to specify an alternative
  20.     mountpoint.
  21.  
  22.     If the optional parameter `nomount` is True, the cdroms will not be
  23.     mounted. This is the default behaviour.
  24.     '''
  25.     
  26.     def __init__(self, progress = None, mountpoint = None, nomount = True):
  27.         self._cdrom = apt_pkg.GetCdrom()
  28.         if progress is None:
  29.             self._progress = CdromProgress()
  30.         else:
  31.             self._progress = progress
  32.         if mountpoint is not None:
  33.             apt_pkg.Config.Set('Acquire::cdrom::mount', mountpoint)
  34.         
  35.         if nomount:
  36.             apt_pkg.Config.Set('APT::CDROM::NoMount', 'true')
  37.         else:
  38.             apt_pkg.Config.Set('APT::CDROM::NoMount', 'false')
  39.  
  40.     
  41.     def add(self):
  42.         '''Add cdrom to the sources.list.'''
  43.         return self._cdrom.Add(self._progress)
  44.  
  45.     
  46.     def ident(self):
  47.         '''Identify the cdrom.'''
  48.         (res, ident) = self._cdrom.Ident(self._progress)
  49.         if res:
  50.             return ident
  51.  
  52.     
  53.     def inSourcesList(self):
  54.         '''Check if the cdrom is already in the current sources.list.'''
  55.         cd_id = self.ident()
  56.         if cd_id is None:
  57.             return False
  58.         src = glob.glob(apt_pkg.Config.FindDir('Dir::Etc::sourceparts') + '*')
  59.         src.append(apt_pkg.Config.FindFile('Dir::Etc::sourcelist'))
  60.         for fname in src:
  61.             for line in open(fname):
  62.                 if not line.lstrip().startswith('#') and cd_id in line:
  63.                     return True
  64.             
  65.         
  66.         return False
  67.  
  68.     inSourcesList = property(inSourcesList)
  69.  
  70.