From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 88BAE1381F3 for ; Mon, 24 Jun 2013 23:42:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 09F06E09E7; Mon, 24 Jun 2013 23:42:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7F0A8E09E7 for ; Mon, 24 Jun 2013 23:42:54 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 55CDA33D3D7 for ; Mon, 24 Jun 2013 23:42:53 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id F368EE468F for ; Mon, 24 Jun 2013 23:42:51 +0000 (UTC) From: "Arfrever Frehtes Taifersar Arahesis" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arfrever Frehtes Taifersar Arahesis" Message-ID: <1372117357.7f816d02c47b6b9c33a9e793e288f52045544bf6.arfrever@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/repository/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/repository/config.py X-VCS-Directories: pym/portage/repository/ X-VCS-Committer: arfrever X-VCS-Committer-Name: Arfrever Frehtes Taifersar Arahesis X-VCS-Revision: 7f816d02c47b6b9c33a9e793e288f52045544bf6 X-VCS-Branch: master Date: Mon, 24 Jun 2013 23:42:51 +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-Archives-Salt: 6f093fd6-9275-415e-888b-3a4e2728ce71 X-Archives-Hash: 77e41174f44539f6f97e8c658be1e6e9 commit: 7f816d02c47b6b9c33a9e793e288f52045544bf6 Author: Arfrever Frehtes Taifersar Arahesis Apache Org> AuthorDate: Mon Jun 24 23:42:37 2013 +0000 Commit: Arfrever Frehtes Taifersar Arahesis gmail com> CommitDate: Mon Jun 24 23:42:37 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7f816d02 portage.repository.config.RepoConfigLoader: Support io.StringIO in paths argument. --- pym/portage/repository/config.py | 45 ++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index 1923b7e..896527a 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -32,6 +32,9 @@ from portage import _unicode_encode from portage import _encodings from portage import manifest +if sys.hexversion >= 0x3000000: + basestring = str + # Characters prohibited by repoman's file.name check. _invalid_path_char_re = re.compile(r'[^a-zA-Z0-9._\-+:/]') @@ -473,24 +476,30 @@ class RepoConfigLoader(object): source_kwarg = 'filename' for p in paths: - f = None - try: - f = io.open(_unicode_encode(p, - encoding=_encodings['fs'], errors='strict'), - mode='r', encoding=_encodings['repo.content'], - errors='replace') - except EnvironmentError: - pass + if isinstance(p, basestring): + f = None + try: + f = io.open(_unicode_encode(p, + encoding=_encodings['fs'], errors='strict'), + mode='r', encoding=_encodings['repo.content'], + errors='replace') + except EnvironmentError: + pass + else: + # The 'source' keyword argument is needed since + # otherwise ConfigParsier may throw a TypeError because + # it assumes that f.name is a native string rather + # than binary when constructing error messages. + kwargs = {source_kwarg: p} + read_file(f, **portage._native_kwargs(kwargs)) + finally: + if f is not None: + f.close() + elif isinstance(p, io.StringIO): + kwargs = {source_kwarg: ""} + read_file(p, **portage._native_kwargs(kwargs)) else: - # The 'source' keyword argument is needed since - # otherwise ConfigParsier may throw a TypeError because - # it assumes that f.name is a native string rather - # than binary when constructing error messages. - kwargs = {source_kwarg: p} - read_file(f, **portage._native_kwargs(kwargs)) - finally: - if f is not None: - f.close() + raise TypeError("Unsupported type %r of element %r of 'paths' argument" % (type(p), p)) prepos['DEFAULT'] = RepoConfig("DEFAULT", parser.defaults(), local_config=local_config) @@ -574,7 +583,7 @@ class RepoConfigLoader(object): if settings.local_config and paths: writemsg_level(_("Location undefined for " \ "repository '%s' referenced in '%s'\n") % \ - (repo.name, paths[0]), + (repo.name, (paths if len(paths) > 1 else paths[0])), level=logging.ERROR, noiselevel=-1) del prepos[repo_name] else: