aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Raplee <kenrap@kennethraplee.com>2022-04-01 18:27:30 -0700
committerSam James <sam@gentoo.org>2022-04-04 20:04:41 +0100
commitbf66319d572fbe00bea0c65001da57ee5f9c154a (patch)
treeae5c44cade0ea85b7c3ab646312dd555231f7552
parentInline key-value insertions as dict expressions with key-value pairs (diff)
downloadportage-bf66319d572fbe00bea0c65001da57ee5f9c154a.tar.gz
portage-bf66319d572fbe00bea0c65001da57ee5f9c154a.tar.bz2
portage-bf66319d572fbe00bea0c65001da57ee5f9c154a.zip
Replace obscure lambdas with closures for clarity
Signed-off-by: Kenneth Raplee <kenrap@kennethraplee.com> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--lib/portage/manifest.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/portage/manifest.py b/lib/portage/manifest.py
index 3555e08de..4dca536e4 100644
--- a/lib/portage/manifest.py
+++ b/lib/portage/manifest.py
@@ -395,30 +395,30 @@ class Manifest:
# it always rounds down. Note that stat_result.st_mtime will round
# up from 0.999999999 to 1.0 when precision is lost during conversion
# from nanosecond resolution to float.
- max_mtime = None
- _update_max = (
- lambda st: max_mtime
- if max_mtime is not None and max_mtime > st[stat.ST_MTIME]
- else st[stat.ST_MTIME]
- )
- _stat = (
- lambda path: preserved_stats[path]
- if path in preserved_stats
- else os.stat(path)
- )
+ def _update_max(max_mtime, st):
+ stat_mtime = st[stat.ST_MTIME]
+ if max_mtime:
+ return max(max_mtime, stat_mtime)
+
+ def _stat(path):
+ if path in preserved_stats:
+ return preserved_stats[path]
+ else:
+ return os.stat(path)
+
+ max_mtime = None
for stat_result in preserved_stats.values():
- max_mtime = _update_max(stat_result)
+ max_mtime = _update_max(max_mtime, stat_result)
for entry in entries:
if entry.type == "DIST":
continue
- abs_path = (
- os.path.join(self.pkgdir, "files", entry.name)
- if entry.type == "AUX"
- else os.path.join(self.pkgdir, entry.name)
- )
- max_mtime = _update_max(_stat(abs_path))
+ files = ""
+ if entry.type == "AUX":
+ files = "files"
+ abs_path = os.path.join(self.pkgdir, files, entry.name)
+ max_mtime = _update_max(max_mtime, _stat(abs_path))
if not self.thin:
# Account for changes to all relevant nested directories.
@@ -435,7 +435,7 @@ class Manifest:
# report such problems).
pass
else:
- max_mtime = _update_max(_stat(parent_dir))
+ max_mtime = _update_max(max_mtime, _stat(parent_dir))
if max_mtime is not None:
for path in preserved_stats: