[Python-checkins] python/dist/src/Lib/plat-mac pimp.py,1.24,1.25

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Sun, 01 Jun 2003 13:57:15 -0700


Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv21274

Modified Files:
	pimp.py 
Log Message:
Added two keys to database format: User-install-skips is an array of pathname
prefixes, any file that is skipped during a per-user install that matches
this set is *not* an error; Systemwide-only is a boolean that says the
package cannot be installer per-user.


Index: pimp.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/pimp.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** pimp.py	1 Jun 2003 20:03:40 -0000	1.24
--- pimp.py	1 Jun 2003 20:57:12 -0000	1.25
***************
*** 79,83 ****
          self._renames = renames
                  
!     def unpack(self, archive, output=None):
          return None
          
--- 79,83 ----
          self._renames = renames
                  
!     def unpack(self, archive, output=None, package=None):
          return None
          
***************
*** 87,91 ****
      _can_rename = False
      
!     def unpack(self, archive, output=None):
          cmd = self.argument % archive
          if _cmd(output, self._dir, cmd):
--- 87,91 ----
      _can_rename = False
      
!     def unpack(self, archive, output=None, package=None):
          cmd = self.argument % archive
          if _cmd(output, self._dir, cmd):
***************
*** 97,101 ****
      _can_rename = True
      
!     def unpack(self, archive, output=None):
          tf = tarfile.open(archive, "r")
          members = tf.getmembers()
--- 97,101 ----
      _can_rename = True
      
!     def unpack(self, archive, output=None, package=None):
          tf = tarfile.open(archive, "r")
          members = tf.getmembers()
***************
*** 133,139 ****
          if skip:
              names = [member.name for member in skip if member.name[-1] != '/']
              if names:
                  return "Not all files were unpacked: %s" % " ".join(names)
!         
  ARCHIVE_FORMATS = [
      (".tar.Z", PimpTarUnpacker, None),
--- 133,141 ----
          if skip:
              names = [member.name for member in skip if member.name[-1] != '/']
+             if package:
+                 names = package.filterExpectedSkips(names)
              if names:
                  return "Not all files were unpacked: %s" % " ".join(names)
!                         
  ARCHIVE_FORMATS = [
      (".tar.Z", PimpTarUnpacker, None),
***************
*** 181,184 ****
--- 183,189 ----
              self.installLocations = []
          self.installDir = installDir
+         
+     def isUserInstall(self):
+         return self.installDir != DEFAULT_INSTALLDIR
  
      def check(self):
***************
*** 371,375 ****
      "Post-install-command",
      "Prerequisites",
!     "MD5Sum"
  ]
  
--- 376,382 ----
      "Post-install-command",
      "Prerequisites",
!     "MD5Sum",
!     "User-install-skips",
!     "Systemwide-only",
  ]
  
***************
*** 395,398 ****
--- 402,406 ----
      def homepage(self): return self._dict.get('Home-page')
      def downloadURL(self): return self._dict.get('Download-URL')
+     def systemwideOnly(self): return self._dict.get('Systemwide-only')
      
      def fullname(self):
***************
*** 486,489 ****
--- 494,501 ----
                  "%s: This package cannot be installed automatically (no Download-URL field)" %
                      self.fullname())]
+         if self.systemwideOnly() and self._db.preferences.isUserInstall():
+             return [(None,
+                 "%s: This package can only be installed system-wide" %
+                     self.fullname())]
          if not self._dict.get('Prerequisites'):
              return []
***************
*** 618,621 ****
--- 630,649 ----
                      sys.path.append(line)           
  
+     def filterExpectedSkips(self, names):
+         """Return a list that contains only unpexpected skips"""
+         if not self._db.preferences.isUserInstall():
+             return names
+         expected_skips = self._dict.get('User-install-skips')
+         if not expected_skips:
+             return names
+         newnames = []
+         for name in names:
+             for skip in expected_skips:
+                 if name[:len(skip)] == skip:
+                     break
+             else:
+                 newnames.append(name)
+         return newnames
+ 
  class PimpPackage_binary(PimpPackage):
  
***************
*** 660,664 ****
                  
          unpacker = unpackerClass(arg, dir="/", renames=install_renames)
!         rv = unpacker.unpack(self.archiveFilename, output=output)
          if rv:
              return rv
--- 688,692 ----
                  
          unpacker = unpackerClass(arg, dir="/", renames=install_renames)
!         rv = unpacker.unpack(self.archiveFilename, output=output, package=self)
          if rv:
              return rv