commit: 4cce9a19dcbe670a676af89c2362f90411c5c796 Author: Brian Harring <ferringb <AT> gmail <DOT> com> AuthorDate: Mon Dec 26 04:24:06 2022 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Mon Dec 26 17:27:25 2022 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=4cce9a19
Ignore both empty and non-existant repos.conf files. Whilst this should probably matter, all reporting pathways I know of involve "don't yell at the user" this it's probably not optimal to have pathways that "yell at the user". Closes: https://github.com/pkgcore/pkgcore/issues/365 Signed-off-by: Brian Harring <ferringb <AT> gmail.com> Closes: https://github.com/pkgcore/pkgcore/pull/387 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcore/ebuild/portage_conf.py | 8 ++++++-- tests/ebuild/test_portage_conf.py | 7 +------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/pkgcore/ebuild/portage_conf.py b/src/pkgcore/ebuild/portage_conf.py index d2865c0bb..907a1a2dd 100644 --- a/src/pkgcore/ebuild/portage_conf.py +++ b/src/pkgcore/ebuild/portage_conf.py @@ -357,8 +357,10 @@ class PortageConfig(DictMixin): hidden=False, backup=False, ): + had_repo_conf = False try: with open(fp) as f: + had_repo_conf = True defaults, repo_confs = parser.parse_file(f) except PermissionError as e: raise base_errors.PermissionDenied(fp, write=False) from e @@ -375,8 +377,10 @@ class PortageConfig(DictMixin): ) main_defaults.update(defaults) - if not repo_confs: - logger.warning(f"repos.conf: parsing {fp!r}: file is empty") + if not had_repo_conf and not repo_confs: + logger.warning( + "repos.conf: not found, but should exist for modern support" + ) for name, repo_conf in repo_confs.items(): if name in repos: diff --git a/tests/ebuild/test_portage_conf.py b/tests/ebuild/test_portage_conf.py index 395373b85..edb3d89b6 100644 --- a/tests/ebuild/test_portage_conf.py +++ b/tests/ebuild/test_portage_conf.py @@ -5,12 +5,12 @@ import stat import textwrap import pytest +from snakeoil.osutils import pjoin from pkgcore import const from pkgcore import exceptions as base_errors from pkgcore.config import errors as config_errors from pkgcore.ebuild.portage_conf import PortageConfig -from snakeoil.osutils import pjoin load_make_conf = PortageConfig.load_make_conf load_repos_conf = PortageConfig.load_repos_conf @@ -78,11 +78,6 @@ class TestReposConf: with pytest.raises(base_errors.PermissionDenied): load_repos_conf(path) - def test_blank_file(self, tmp_path, caplog): - (path := tmp_path / "file").touch() - load_repos_conf(path) - assert "file is empty" in caplog.text - def test_garbage_file(self, tmp_path): (path := tmp_path / "file").write_bytes(binascii.b2a_hex(os.urandom(10))) with pytest.raises(config_errors.ConfigurationError):
