Michał Górny committed e112f11

PMPackage: make .environ try both .bz2 and plain environment.

Now PMPackage.environ looks for both environment.bz2 and plain
environment files. It checks which of them is newer, and uses that one.

  • Participants
  • Parent commits 0c7660d

Comments (0)

Files changed (1)

File gentoopm/basepm/

 			return None
 		if os.path.isdir(p):
-			# XXX: look for .bz2 and plain, take the newer one
-			p = os.path.join(p, 'environment.bz2')
+			def _mtime_if_exists(path):
+				try:
+					return os.path.getmtime(path)
+				except OSError:
+					return None
+			files = ('environment.bz2', 'environment')
+			# Take the newer one.
+			fn = sorted(files, key=_mtime_if_exists, reverse=True)[0]
+			p = os.path.join(p, fn)
 		if not os.path.exists(p):
 			return None