From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6F4D5158020 for ; Mon, 26 Dec 2022 17:28:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 342CFE0967; Mon, 26 Dec 2022 17:28:09 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DB802E0967 for ; Mon, 26 Dec 2022 17:28:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 77BAA341106 for ; Mon, 26 Dec 2022 17:28:07 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 9FFB27FB for ; Mon, 26 Dec 2022 17:28:04 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1672075645.4cce9a19dcbe670a676af89c2362f90411c5c796.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: tests/ebuild/, src/pkgcore/ebuild/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/ebuild/portage_conf.py tests/ebuild/test_portage_conf.py X-VCS-Directories: tests/ebuild/ src/pkgcore/ebuild/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 4cce9a19dcbe670a676af89c2362f90411c5c796 X-VCS-Branch: master Date: Mon, 26 Dec 2022 17:28:04 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 43708845-742e-4318-906a-26a813730bf9 X-Archives-Hash: c0f5bb9aaf9b0d48c8f9548c4b514467 commit: 4cce9a19dcbe670a676af89c2362f90411c5c796 Author: Brian Harring gmail com> AuthorDate: Mon Dec 26 04:24:06 2022 +0000 Commit: Arthur Zamarin gentoo 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 gmail.com> Closes: https://github.com/pkgcore/pkgcore/pull/387 Signed-off-by: Arthur Zamarin 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):