public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Gilbert" <floppym@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/, lib/portage/tests/util/
Date: Tue,  7 Jun 2022 23:48:15 +0000 (UTC)	[thread overview]
Message-ID: <1654645676.e22cf80ec99c52c1192ecf99f6b66d1d892f3f86.floppym@gentoo> (raw)

commit:     e22cf80ec99c52c1192ecf99f6b66d1d892f3f86
Author:     David Palao <david.palao <AT> gmail <DOT> com>
AuthorDate: Fri Jun  3 09:13:17 2022 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Jun  7 23:47:56 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e22cf80e

improvement(pylint/black): some formatting issues fixed

Signed-off-by: David Palao <david.palao <AT> gmail.com>
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 lib/portage/tests/util/test_mtimedb.py | 126 ++++++++++++++-------------------
 lib/portage/util/mtimedb.py            |  14 ++--
 2 files changed, 59 insertions(+), 81 deletions(-)

diff --git a/lib/portage/tests/util/test_mtimedb.py b/lib/portage/tests/util/test_mtimedb.py
index 09d72049f..d80b4f1da 100644
--- a/lib/portage/tests/util/test_mtimedb.py
+++ b/lib/portage/tests/util/test_mtimedb.py
@@ -9,7 +9,6 @@ from portage.tests import TestCase
 import portage
 from portage.data import portage_gid, uid
 from portage.util.mtimedb import MtimeDB, _MTIMEDBKEYS
-from portage.exception import DigestException
 
 
 # Some data for the fixtures:
@@ -210,15 +209,12 @@ class MtimeDBTestCase(TestCase):
             _TWO_RESUME_LISTS_JSON,
         )
         for contents in all_fixtures:
-            with patch(
-                "portage.util.mtimedb.open", mock_open(read_data=contents)
-            ):
+            with patch("portage.util.mtimedb.open", mock_open(read_data=contents)):
                 mtimedb = MtimeDB("/path/to/mtimedb")
             self.assertLessEqual(set(mtimedb.keys()), _MTIMEDBKEYS)
 
     def test_default_values(self):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_EMPTY_FILE)):
+        with patch("portage.util.mtimedb.open", mock_open(read_data=_EMPTY_FILE)):
             mtimedb = MtimeDB("/some/path/mtimedb")
         self.assertEqual(mtimedb["starttime"], 0)
         self.assertEqual(mtimedb["version"], "")
@@ -227,88 +223,75 @@ class MtimeDBTestCase(TestCase):
         self.assertEqual(mtimedb["updates"], {})
 
     def test_instances_keep_a_deepcopy_of_clean_data(self):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_ONE_RESUME_LIST_JSON)):
+        with patch(
+            "portage.util.mtimedb.open", mock_open(read_data=_ONE_RESUME_LIST_JSON)
+        ):
             mtimedb = MtimeDB("/some/path/mtimedb")
         self.assertEqual(dict(mtimedb), dict(mtimedb._clean_data))
         self.assertIsNot(mtimedb, mtimedb._clean_data)
 
     def test_load_data_called_at_instance_creation_time(self):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_ONE_RESUME_LIST_JSON)):
+        with patch(
+            "portage.util.mtimedb.open", mock_open(read_data=_ONE_RESUME_LIST_JSON)
+        ):
             mtimedb = MtimeDB("/some/path/mtimedb")
         self.assertEqual(
             mtimedb["info"],
             {
-		"/usr/share/binutils-data/x86_64-pc-linux-gnu/2.37/info": (
-                    1711787325),
-		"/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/info": (
-                    1735158257),
-		"/usr/share/info": 1650633847
-	    }
+                "/usr/share/binutils-data/x86_64-pc-linux-gnu/2.37/info": (1711787325),
+                "/usr/share/gcc-data/x86_64-pc-linux-gnu/11.2.0/info": (1735158257),
+                "/usr/share/info": 1650633847,
+            },
         )
         self.assertEqual(
             mtimedb["ldpath"],
             {
-		"/lib": 1748456830,
-		"/lib64": 1750523381,
-		"/usr/lib": 1750461195,
-		"/usr/lib/llvm/13/lib64": 1747003135,
-		"/usr/lib/rust/lib": 1750461173,
-		"/usr/lib64": 1750881821,
-		"/usr/local/lib": 1711784303,
-		"/usr/local/lib64": 1711784303
-	    }
+                "/lib": 1748456830,
+                "/lib64": 1750523381,
+                "/usr/lib": 1750461195,
+                "/usr/lib/llvm/13/lib64": 1747003135,
+                "/usr/lib/rust/lib": 1750461173,
+                "/usr/lib64": 1750881821,
+                "/usr/local/lib": 1711784303,
+                "/usr/local/lib64": 1711784303,
+            },
         )
         self.assertEqual(
             mtimedb["resume"],
             {
-		"favorites": [
-			"@world"
-		],
-		"mergelist": [
-			[
-				"ebuild",
-				"/",
-				"some-cat/some-package-1.2.3-r4",
-				"merge"
-			],
-			[
-				"ebuild",
-				"/",
-				"another-cat/another-package-4.3.2-r1",
-				"merge"
-			]
-		],
-		"myopts": {
-			"--buildpkg": True,
-			"--deep": True,
-			"--getbinpkg": True,
-			"--keep-going": True,
-			"--newuse": True,
-			"--quiet": True,
-			"--regex-search-auto": "y",
-			"--update": True,
-			"--usepkg": True,
-			"--verbose": True
-		}
-	    }
+                "favorites": ["@world"],
+                "mergelist": [
+                    ["ebuild", "/", "some-cat/some-package-1.2.3-r4", "merge"],
+                    ["ebuild", "/", "another-cat/another-package-4.3.2-r1", "merge"],
+                ],
+                "myopts": {
+                    "--buildpkg": True,
+                    "--deep": True,
+                    "--getbinpkg": True,
+                    "--keep-going": True,
+                    "--newuse": True,
+                    "--quiet": True,
+                    "--regex-search-auto": "y",
+                    "--update": True,
+                    "--usepkg": True,
+                    "--verbose": True,
+                },
+            },
         )
         self.assertEqual(mtimedb["starttime"], 0)
         self.assertEqual(
             mtimedb["updates"],
             {
-		"/var/db/repos/gentoo/profiles/updates/1Q-2022": 1747854791,
-		"/var/db/repos/gentoo/profiles/updates/2Q-2022": 1752846209,
-		"/var/db/repos/gentoo/profiles/updates/4Q-2021": 1742787797
-	    }
+                "/var/db/repos/gentoo/profiles/updates/1Q-2022": 1747854791,
+                "/var/db/repos/gentoo/profiles/updates/2Q-2022": 1752846209,
+                "/var/db/repos/gentoo/profiles/updates/4Q-2021": 1742787797,
+            },
         )
         self.assertEqual(mtimedb["version"], "3.0.30")
 
     @patch("portage.util.mtimedb.MtimeDB._MtimeDB__write_to_disk")
     def test_commit_writes_to_disk_if_needed_and_possible(self, pwrite2disk):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_EMPTY_FILE)):
+        with patch("portage.util.mtimedb.open", mock_open(read_data=_EMPTY_FILE)):
             mtimedb = MtimeDB("/some/path/mtimedb")
         mtimedb.commit()
         pwrite2disk.assert_not_called()
@@ -320,8 +303,7 @@ class MtimeDBTestCase(TestCase):
 
     @patch("portage.util.mtimedb.MtimeDB._MtimeDB__write_to_disk")
     def test_commit_does_not_write_to_disk_if_no_file(self, pwrite2disk):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_EMPTY_FILE)):
+        with patch("portage.util.mtimedb.open", mock_open(read_data=_EMPTY_FILE)):
             mtimedb = MtimeDB("/some/path/mtimedb")
         mtimedb["updates"]["/long/path/1Q-2021"] = 1739992409
         mtimedb.filename = None
@@ -330,15 +312,15 @@ class MtimeDBTestCase(TestCase):
 
     @patch("portage.util.mtimedb.MtimeDB._MtimeDB__write_to_disk")
     def test_commit_does_not_write_to_disk_if_no_changes(self, pwrite2disk):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_EMPTY_FILE)):
+        with patch("portage.util.mtimedb.open", mock_open(read_data=_EMPTY_FILE)):
             mtimedb = MtimeDB("/some/path/mtimedb")
         mtimedb.commit()
         pwrite2disk.assert_not_called()
 
     def test_is_readonly_attribute(self):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_ONE_RESUME_LIST_JSON)):
+        with patch(
+            "portage.util.mtimedb.open", mock_open(read_data=_ONE_RESUME_LIST_JSON)
+        ):
             mtimedb = MtimeDB("/some/path/mtimedb")
         self.assertFalse(mtimedb.is_readonly)
 
@@ -349,8 +331,9 @@ class MtimeDBTestCase(TestCase):
         self.assertFalse(mtimedb.is_readonly)
 
     def test_make_readonly(self):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_ONE_RESUME_LIST_JSON)):
+        with patch(
+            "portage.util.mtimedb.open", mock_open(read_data=_ONE_RESUME_LIST_JSON)
+        ):
             mtimedb = MtimeDB("/some/path/mtimedb")
         mtimedb.make_readonly()
         self.assertTrue(mtimedb.is_readonly)
@@ -359,8 +342,9 @@ class MtimeDBTestCase(TestCase):
     @patch("portage.util.mtimedb.apply_secpass_permissions")
     @patch("portage.util.mtimedb.atomic_ofstream")
     def test_write_to_disk(self, matomic_ofstream, mapply_perms):
-        with patch("portage.util.mtimedb.open",
-                   mock_open(read_data=_ONE_RESUME_LIST_JSON)):
+        with patch(
+            "portage.util.mtimedb.open", mock_open(read_data=_ONE_RESUME_LIST_JSON)
+        ):
             mtimedb = MtimeDB("/some/path/mtimedb")
         d = {"z": "zome", "a": "AAA"}
         encoding = portage._encodings["repo.content"]

diff --git a/lib/portage/util/mtimedb.py b/lib/portage/util/mtimedb.py
index 497c01e05..098350526 100644
--- a/lib/portage/util/mtimedb.py
+++ b/lib/portage/util/mtimedb.py
@@ -71,9 +71,7 @@ class MtimeDB(dict):
             if getattr(e, "errno", None) in (errno.ENOENT, errno.EACCES):
                 pass
             else:
-                writemsg(
-                    _(f"!!! Error loading '{filename}': {e}\n"), noiselevel=-1
-                )
+                writemsg(_(f"!!! Error loading '{filename}': {e}\n"), noiselevel=-1)
         finally:
             if f is not None:
                 f.close()
@@ -83,8 +81,7 @@ class MtimeDB(dict):
             try:
                 d = json.loads(
                     _unicode_decode(
-                        content, encoding=_encodings["repo.content"],
-                        errors="strict"
+                        content, encoding=_encodings["repo.content"], errors="strict"
                     )
                 )
             except SystemExit:
@@ -101,10 +98,7 @@ class MtimeDB(dict):
                 except SystemExit:
                     raise
                 except Exception:
-                    writemsg(
-                        _(f"!!! Error loading '{filename}': {e}\n"),
-                        noiselevel=-1
-                    )
+                    writemsg(_(f"!!! Error loading '{filename}': {e}\n"), noiselevel=-1)
 
         if "old" in d:
             d["updates"] = d["old"]
@@ -117,7 +111,7 @@ class MtimeDB(dict):
         for k in ("info", "ldpath", "updates"):
             d.setdefault(k, {})
 
-        for k in (set(d.keys())-_MTIMEDBKEYS):
+        for k in set(d.keys()) - _MTIMEDBKEYS:
             writemsg(_(f"Deleting invalid mtimedb key: {k}\n"))
             del d[k]
         self.update(d)


             reply	other threads:[~2022-06-07 23:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 23:48 Mike Gilbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-02-22 15:36 [gentoo-commits] proj/portage:master commit in: lib/portage/util/, lib/portage/tests/util/ Zac Medico
2022-12-31 13:33 Sam James
2022-06-07 23:48 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2022-06-07 23:48 Mike Gilbert
2019-01-16  8:33 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1654645676.e22cf80ec99c52c1192ecf99f6b66d1d892f3f86.floppym@gentoo \
    --to=floppym@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox