commit: 6fb8ee74b3f334a7e2d82ce674a4b98e49f78b06
Author: Kenneth Raplee <kenrap <AT> kennethraplee <DOT> com>
AuthorDate: Tue Mar 22 07:54:21 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Mar 27 23:06:43 2022 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6fb8ee74
Use dict expressions instead of looping or dict()
Signed-off-by: Kenneth Raplee <kenrap <AT> kennethraplee.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/checksum.py | 10 ++++------
lib/portage/eclass_cache.py | 5 +----
lib/portage/getbinpkg.py | 22 +++++++++++++---------
3 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
index d7e800c47..72d20525a 100644
--- a/lib/portage/checksum.py
+++ b/lib/portage/checksum.py
@@ -367,9 +367,7 @@ def _perform_md5_merge(x, **kwargs):
def perform_all(x, calc_prelink=0):
- mydict = {}
- for k in hashfunc_keys:
- mydict[k] = perform_checksum(x, k, calc_prelink)[0]
+ mydict = {k: perform_checksum(x, k, calc_prelink)[0] for k in
hashfunc_keys}
return mydict
@@ -458,11 +456,11 @@ def _apply_hash_filter(digests, hash_filter):
break
if modified:
- digests = dict(
- (k, v)
+ digests = {
+ k: v
for (k, v) in digests.items()
if k == "size" or k in verifiable_hash_types
- )
+ }
return digests
diff --git a/lib/portage/eclass_cache.py b/lib/portage/eclass_cache.py
index 2545ed9b2..c4c783168 100644
--- a/lib/portage/eclass_cache.py
+++ b/lib/portage/eclass_cache.py
@@ -169,10 +169,7 @@ class cache:
return d
def get_eclass_data(self, inherits):
- ec_dict = {}
- for x in inherits:
- ec_dict[x] = self.eclasses[x]
-
+ ec_dict = {x: self.eclasses[x] for x in inherits}
return ec_dict
@property
diff --git a/lib/portage/getbinpkg.py b/lib/portage/getbinpkg.py
index bf99fd2be..f357a91df 100644
--- a/lib/portage/getbinpkg.py
+++ b/lib/portage/getbinpkg.py
@@ -55,20 +55,24 @@ def make_metadata_dict(data):
)
myid, _myglob = data
-
- mydict = {}
- for k_bytes in portage.xpak.getindex_mem(myid):
- k = _unicode_decode(
- k_bytes, encoding=_encodings["repo.content"], errors="replace"
+ metadata = (
+ (
+ k_bytes,
+ _unicode_decode(
+ k_bytes, encoding=_encodings["repo.content"], errors="replace"
+ ),
)
- if k not in _all_metadata_keys and k != "CATEGORY":
- continue
- v = _unicode_decode(
+ for k_bytes in portage.xpak.getindex_mem(myid)
+ )
+ mydict = {
+ k: _unicode_decode(
portage.xpak.getitem(data, k_bytes),
encoding=_encodings["repo.content"],
errors="replace",
)
- mydict[k] = v
+ for k_bytes, k in metadata
+ if k in _all_metadata_keys or k == "CATEGORY"
+ }
return mydict