1 |
commit: 6fb8ee74b3f334a7e2d82ce674a4b98e49f78b06 |
2 |
Author: Kenneth Raplee <kenrap <AT> kennethraplee <DOT> com> |
3 |
AuthorDate: Tue Mar 22 07:54:21 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Mar 27 23:06:43 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6fb8ee74 |
7 |
|
8 |
Use dict expressions instead of looping or dict() |
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/checksum.py | 10 ++++------ |
14 |
lib/portage/eclass_cache.py | 5 +---- |
15 |
lib/portage/getbinpkg.py | 22 +++++++++++++--------- |
16 |
3 files changed, 18 insertions(+), 19 deletions(-) |
17 |
|
18 |
diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py |
19 |
index d7e800c47..72d20525a 100644 |
20 |
--- a/lib/portage/checksum.py |
21 |
+++ b/lib/portage/checksum.py |
22 |
@@ -367,9 +367,7 @@ def _perform_md5_merge(x, **kwargs): |
23 |
|
24 |
|
25 |
def perform_all(x, calc_prelink=0): |
26 |
- mydict = {} |
27 |
- for k in hashfunc_keys: |
28 |
- mydict[k] = perform_checksum(x, k, calc_prelink)[0] |
29 |
+ mydict = {k: perform_checksum(x, k, calc_prelink)[0] for k in hashfunc_keys} |
30 |
return mydict |
31 |
|
32 |
|
33 |
@@ -458,11 +456,11 @@ def _apply_hash_filter(digests, hash_filter): |
34 |
break |
35 |
|
36 |
if modified: |
37 |
- digests = dict( |
38 |
- (k, v) |
39 |
+ digests = { |
40 |
+ k: v |
41 |
for (k, v) in digests.items() |
42 |
if k == "size" or k in verifiable_hash_types |
43 |
- ) |
44 |
+ } |
45 |
|
46 |
return digests |
47 |
|
48 |
|
49 |
diff --git a/lib/portage/eclass_cache.py b/lib/portage/eclass_cache.py |
50 |
index 2545ed9b2..c4c783168 100644 |
51 |
--- a/lib/portage/eclass_cache.py |
52 |
+++ b/lib/portage/eclass_cache.py |
53 |
@@ -169,10 +169,7 @@ class cache: |
54 |
return d |
55 |
|
56 |
def get_eclass_data(self, inherits): |
57 |
- ec_dict = {} |
58 |
- for x in inherits: |
59 |
- ec_dict[x] = self.eclasses[x] |
60 |
- |
61 |
+ ec_dict = {x: self.eclasses[x] for x in inherits} |
62 |
return ec_dict |
63 |
|
64 |
@property |
65 |
|
66 |
diff --git a/lib/portage/getbinpkg.py b/lib/portage/getbinpkg.py |
67 |
index bf99fd2be..f357a91df 100644 |
68 |
--- a/lib/portage/getbinpkg.py |
69 |
+++ b/lib/portage/getbinpkg.py |
70 |
@@ -55,20 +55,24 @@ def make_metadata_dict(data): |
71 |
) |
72 |
|
73 |
myid, _myglob = data |
74 |
- |
75 |
- mydict = {} |
76 |
- for k_bytes in portage.xpak.getindex_mem(myid): |
77 |
- k = _unicode_decode( |
78 |
- k_bytes, encoding=_encodings["repo.content"], errors="replace" |
79 |
+ metadata = ( |
80 |
+ ( |
81 |
+ k_bytes, |
82 |
+ _unicode_decode( |
83 |
+ k_bytes, encoding=_encodings["repo.content"], errors="replace" |
84 |
+ ), |
85 |
) |
86 |
- if k not in _all_metadata_keys and k != "CATEGORY": |
87 |
- continue |
88 |
- v = _unicode_decode( |
89 |
+ for k_bytes in portage.xpak.getindex_mem(myid) |
90 |
+ ) |
91 |
+ mydict = { |
92 |
+ k: _unicode_decode( |
93 |
portage.xpak.getitem(data, k_bytes), |
94 |
encoding=_encodings["repo.content"], |
95 |
errors="replace", |
96 |
) |
97 |
- mydict[k] = v |
98 |
+ for k_bytes, k in metadata |
99 |
+ if k in _all_metadata_keys or k == "CATEGORY" |
100 |
+ } |
101 |
|
102 |
return mydict |