home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / AppInstall / Util.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  2.4 KB  |  78 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import warnings
  5. warnings.filterwarnings('ignore', 'apt API not stable yet', FutureWarning)
  6. import apt
  7. import os
  8. (COL_NAME, COL_ITEM, COL_POPCON) = range(3)
  9.  
  10. class MyCache(apt.Cache):
  11.     
  12.     def __init__(self, progress = None):
  13.         apt.Cache.__init__(self, progress)
  14.         pipe = os.popen('dpkg --print-architecture')
  15.         self._arch = pipe.read().strip()
  16.         del pipe
  17.  
  18.     
  19.     def pkgDependsOn(self, pkgname, depends_name):
  20.         ''' check if a given pkg depends on a given dependencie '''
  21.         if not self.has_key(pkgname):
  22.             return False
  23.         
  24.         pkg = self[pkgname]
  25.         candver = self._depcache.GetCandidateVer(pkg._pkg)
  26.         if candver == None:
  27.             return False
  28.         
  29.         dependslist = candver.DependsList
  30.         for dep in dependslist.keys():
  31.             if dep == 'Depends' or dep == 'PreDepends':
  32.                 for depVerList in dependslist[dep]:
  33.                     for z in depVerList:
  34.                         for tpkg in z.AllTargets():
  35.                             if depends_name == tpkg.ParentPkg.Name:
  36.                                 return True
  37.                                 continue
  38.                         
  39.                     
  40.                 
  41.         
  42.         return False
  43.  
  44.     
  45.     def clean(self):
  46.         self._depcache.Init()
  47.  
  48.     
  49.     def getArch(self):
  50.         ''' Return the cpu architecture of the system'''
  51.         return self._arch
  52.  
  53.  
  54.  
  55. def xmlescape(s):
  56.     escape = escape
  57.     import xml.sax.saxutils
  58.     if s == None:
  59.         return ''
  60.     else:
  61.         return escape(s)
  62.  
  63.  
  64. def iterate_list_store(store, it):
  65.     ''' iterate over a gtk tree-model, returns a gtk.TreeIter for each element
  66.     '''
  67.     if not it:
  68.         raise StopIteration
  69.     
  70.     yield it
  71.     while True:
  72.         it = store.iter_next(it)
  73.         if it == None:
  74.             raise StopIteration
  75.         
  76.         yield it
  77.  
  78.