1 |
commit: bf66319d572fbe00bea0c65001da57ee5f9c154a |
2 |
Author: Kenneth Raplee <kenrap <AT> kennethraplee <DOT> com> |
3 |
AuthorDate: Sat Apr 2 01:27:30 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 4 19:04:41 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bf66319d |
7 |
|
8 |
Replace obscure lambdas with closures for clarity |
9 |
|
10 |
Signed-off-by: Kenneth Raplee <kenrap <AT> kennethraplee.com> |
11 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
12 |
|
13 |
lib/portage/manifest.py | 38 +++++++++++++++++++------------------- |
14 |
1 file changed, 19 insertions(+), 19 deletions(-) |
15 |
|
16 |
diff --git a/lib/portage/manifest.py b/lib/portage/manifest.py |
17 |
index 3555e08de..4dca536e4 100644 |
18 |
--- a/lib/portage/manifest.py |
19 |
+++ b/lib/portage/manifest.py |
20 |
@@ -395,30 +395,30 @@ class Manifest: |
21 |
# it always rounds down. Note that stat_result.st_mtime will round |
22 |
# up from 0.999999999 to 1.0 when precision is lost during conversion |
23 |
# from nanosecond resolution to float. |
24 |
- max_mtime = None |
25 |
- _update_max = ( |
26 |
- lambda st: max_mtime |
27 |
- if max_mtime is not None and max_mtime > st[stat.ST_MTIME] |
28 |
- else st[stat.ST_MTIME] |
29 |
- ) |
30 |
- _stat = ( |
31 |
- lambda path: preserved_stats[path] |
32 |
- if path in preserved_stats |
33 |
- else os.stat(path) |
34 |
- ) |
35 |
|
36 |
+ def _update_max(max_mtime, st): |
37 |
+ stat_mtime = st[stat.ST_MTIME] |
38 |
+ if max_mtime: |
39 |
+ return max(max_mtime, stat_mtime) |
40 |
+ |
41 |
+ def _stat(path): |
42 |
+ if path in preserved_stats: |
43 |
+ return preserved_stats[path] |
44 |
+ else: |
45 |
+ return os.stat(path) |
46 |
+ |
47 |
+ max_mtime = None |
48 |
for stat_result in preserved_stats.values(): |
49 |
- max_mtime = _update_max(stat_result) |
50 |
+ max_mtime = _update_max(max_mtime, stat_result) |
51 |
|
52 |
for entry in entries: |
53 |
if entry.type == "DIST": |
54 |
continue |
55 |
- abs_path = ( |
56 |
- os.path.join(self.pkgdir, "files", entry.name) |
57 |
- if entry.type == "AUX" |
58 |
- else os.path.join(self.pkgdir, entry.name) |
59 |
- ) |
60 |
- max_mtime = _update_max(_stat(abs_path)) |
61 |
+ files = "" |
62 |
+ if entry.type == "AUX": |
63 |
+ files = "files" |
64 |
+ abs_path = os.path.join(self.pkgdir, files, entry.name) |
65 |
+ max_mtime = _update_max(max_mtime, _stat(abs_path)) |
66 |
|
67 |
if not self.thin: |
68 |
# Account for changes to all relevant nested directories. |
69 |
@@ -435,7 +435,7 @@ class Manifest: |
70 |
# report such problems). |
71 |
pass |
72 |
else: |
73 |
- max_mtime = _update_max(_stat(parent_dir)) |
74 |
+ max_mtime = _update_max(max_mtime, _stat(parent_dir)) |
75 |
|
76 |
if max_mtime is not None: |
77 |
for path in preserved_stats: |