public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_config/, pym/portage/repository/, pym/portage/, ...
@ 2011-08-25  2:26 Zac Medico
  0 siblings, 0 replies; 3+ messages in thread
From: Zac Medico @ 2011-08-25  2:26 UTC (permalink / raw
  To: gentoo-commits

commit:     a12c63842b28e29f3bc6718e6d940d5b697f010f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 25 02:25:59 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Aug 25 02:25:59 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a12c6384

python3.2 fixes: ResourceWarning: unclosed file

---
 pym/portage/news.py                                |    7 ++++---
 pym/portage/output.py                              |   12 +++++++++---
 .../package/ebuild/_config/LocationsManager.py     |   10 +++++++---
 pym/portage/repository/config.py                   |    9 +++++++--
 pym/portage/tests/ebuild/test_doebuild_spawn.py    |    4 ++--
 pym/portage/util/__init__.py                       |   13 +++++++++----
 6 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 866e5b0..031e98c 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -250,10 +250,11 @@ class NewsItem(object):
 		return self._valid
 
 	def parse(self):
-		lines = io.open(_unicode_encode(self.path,
+		f = io.open(_unicode_encode(self.path,
 			encoding=_encodings['fs'], errors='strict'),
-			mode='r', encoding=_encodings['content'], errors='replace'
-			).readlines()
+			mode='r', encoding=_encodings['content'], errors='replace')
+		lines = f.readlines()
+		f.close()
 		self.restrictions = {}
 		invalids = []
 		for i, line in enumerate(lines):

diff --git a/pym/portage/output.py b/pym/portage/output.py
index 0e8245f..763d74a 100644
--- a/pym/portage/output.py
+++ b/pym/portage/output.py
@@ -162,11 +162,14 @@ def _parse_color_map(config_root='/', onerror=None):
 		if token[0] in quotes and token[0] == token[-1]:
 			token = token[1:-1]
 		return token
+
+	f = None
 	try:
-		lineno=0
-		for line in io.open(_unicode_encode(myfile,
+		f = io.open(_unicode_encode(myfile,
 			encoding=_encodings['fs'], errors='strict'),
-			mode='r', encoding=_encodings['content'], errors='replace'):
+			mode='r', encoding=_encodings['content'], errors='replace')
+		lineno = 0
+		for line in f:
 			lineno += 1
 
 			commenter_pos = line.find("#")
@@ -226,6 +229,9 @@ def _parse_color_map(config_root='/', onerror=None):
 		elif e.errno == errno.EACCES:
 			raise PermissionDenied(myfile)
 		raise
+	finally:
+		if f is not None:
+			f.close()
 
 def nc_len(mystr):
 	tmp = re.sub(esc_seq + "^m]+m", "", mystr);

diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
index c2b115b..4072ffc 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -89,11 +89,12 @@ class LocationsManager(object):
 	def _addProfile(self, currentPath):
 		parentsFile = os.path.join(currentPath, "parent")
 		eapi_file = os.path.join(currentPath, "eapi")
+		f = None
 		try:
-			eapi = io.open(_unicode_encode(eapi_file,
+			f = io.open(_unicode_encode(eapi_file,
 				encoding=_encodings['fs'], errors='strict'),
-				mode='r', encoding=_encodings['content'], errors='replace'
-				).readline().strip()
+				mode='r', encoding=_encodings['content'], errors='replace')
+			eapi = f.readline().strip()
 		except IOError:
 			pass
 		else:
@@ -102,6 +103,9 @@ class LocationsManager(object):
 					"Profile contains unsupported "
 					"EAPI '%s': '%s'") % \
 					(eapi, os.path.realpath(eapi_file),))
+		finally:
+			if f is not None:
+				f.close()
 		if os.path.exists(parentsFile):
 			parents = grabfile(parentsFile)
 			if not parents:

diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index ac9793e..a12bd7b 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -137,14 +137,19 @@ class RepoConfig(object):
 		Returns repo_name, missing.
 		"""
 		repo_name_path = os.path.join(repo_path, REPO_NAME_LOC)
+		f = None
 		try:
-			return io.open(
+			f = io.open(
 				_unicode_encode(repo_name_path,
 				encoding=_encodings['fs'], errors='strict'),
 				mode='r', encoding=_encodings['repo.content'],
-				errors='replace').readline().strip(), False
+				errors='replace')
+			return f.readline().strip(), False
 		except EnvironmentError:
 			return "x-" + os.path.basename(repo_path), True
+		finally:
+			if f is not None:
+				f.close()
 
 	def info_string(self):
 		"""

diff --git a/pym/portage/tests/ebuild/test_doebuild_spawn.py b/pym/portage/tests/ebuild/test_doebuild_spawn.py
index ed08b2a..cafb16d 100644
--- a/pym/portage/tests/ebuild/test_doebuild_spawn.py
+++ b/pym/portage/tests/ebuild/test_doebuild_spawn.py
@@ -1,4 +1,4 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from portage import os
@@ -50,7 +50,7 @@ class DoebuildSpawnTestCase(TestCase):
 				os.makedirs(settings[x])
 			# Create a fake environment, to pretend as if the ebuild
 			# has been sourced already.
-			open(os.path.join(settings['T'], 'environment'), 'wb')
+			open(os.path.join(settings['T'], 'environment'), 'wb').close()
 
 			scheduler = PollScheduler().sched_iface
 			for phase in ('_internal_test',):

diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 4aa63d5..de3abda 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -534,16 +534,18 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
 	else:
 		expand_map = {}
 	mykeys = {}
+	f = None
 	try:
 		# NOTE: shlex doesn't support unicode objects with Python 2
 		# (produces spurious \0 characters).
 		if sys.hexversion < 0x3000000:
-			content = open(_unicode_encode(mycfg,
-				encoding=_encodings['fs'], errors='strict'), 'rb').read()
+			f = open(_unicode_encode(mycfg,
+				encoding=_encodings['fs'], errors='strict'), 'rb')
 		else:
-			content = open(_unicode_encode(mycfg,
+			f = open(_unicode_encode(mycfg,
 				encoding=_encodings['fs'], errors='strict'), mode='r',
-				encoding=_encodings['content'], errors='replace').read()
+				encoding=_encodings['content'], errors='replace')
+		content = f.read()
 	except IOError as e:
 		if e.errno == PermissionDenied.errno:
 			raise PermissionDenied(mycfg)
@@ -552,6 +554,9 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
 			if e.errno not in (errno.EISDIR,):
 				raise
 		return None
+	finally:
+		if f is not None:
+			f.close()
 
 	# Workaround for avoiding a silent error in shlex that is
 	# triggered by a source statement at the end of the file



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_config/, pym/portage/repository/, pym/portage/, ...
@ 2012-09-21  6:32 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 3+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-09-21  6:32 UTC (permalink / raw
  To: gentoo-commits

commit:     c42ed0f97224091c33edeb79a3719de0b283fa1f
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Fri Sep 21 06:31:13 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Fri Sep 21 06:31:13 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c42ed0f9

Improve allowing of directories on profile level and repository level in EAPI="4-python".

---
 doc/package/ebuild/eapi/4-python.docbook           |    7 +++++--
 pym/portage/eapi.py                                |    3 +++
 .../package/ebuild/_config/LocationsManager.py     |   11 +++++++----
 pym/portage/repository/config.py                   |   10 ++++++----
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/doc/package/ebuild/eapi/4-python.docbook b/doc/package/ebuild/eapi/4-python.docbook
index ec5fd83..c490330 100644
--- a/doc/package/ebuild/eapi/4-python.docbook
+++ b/doc/package/ebuild/eapi/4-python.docbook
@@ -97,7 +97,7 @@
 	<section id='package-ebuild-eapi-4-python-repo-level-config'>
 		<title>Extended Repository-Level Configuration</title>
 		<para>
-			Repository-level configuration in ${repository}/profiles is supported for the following files:
+			Repository-level configuration in ${repository_path}/profiles is supported for the following files:
 			<itemizedlist>
 				<listitem><para>make.defaults</para></listitem>
 				<listitem><para>package.use</para></listitem>
@@ -107,8 +107,11 @@
 				<listitem><para>use.mask</para></listitem>
 			</itemizedlist>
 		</para>
+	</section>
+	<section id='package-ebuild-eapi-4-python-directories'>
+		<title>Directories Allowed for Profile-Level and Repository-Level Configuration</title>
 		<para>
-			By default, the following files in ${repository}/profiles can be also directories:
+			The following files can be directories:
 			<itemizedlist>
 				<listitem><para>package.mask</para></listitem>
 				<listitem><para>package.use</para></listitem>

diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index 4efd4ea..42c108b 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -80,6 +80,9 @@ def eapi_allows_dots_in_use_flags(eapi):
 def eapi_supports_stable_use_forcing_and_masking(eapi):
 	return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi")
 
+def eapi_allows_directories_on_profile_level_and_repository_level(eapi):
+	return eapi in ("4-python",)
+
 _eapi_attrs = collections.namedtuple('_eapi_attrs',
 	'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
 	'iuse_defaults iuse_effective '

diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
index 2200be6..0149ad8 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = (
@@ -13,6 +13,7 @@ import portage
 from portage import os, eapi_is_supported, _encodings, _unicode_encode
 from portage.const import CUSTOM_PROFILE_PATH, GLOBAL_CONFIG_PATH, \
 	PROFILE_PATH, USER_CONFIG_PATH
+from portage.eapi import eapi_allows_directories_on_profile_level_and_repository_level
 from portage.exception import DirectoryNotFound, ParseError
 from portage.localization import _
 from portage.util import ensure_dirs, grabfile, \
@@ -132,6 +133,7 @@ class LocationsManager(object):
 		compat_mode = False
 
 		eapi_file = os.path.join(currentPath, "eapi")
+		eapi = "0"
 		f = None
 		try:
 			f = io.open(_unicode_encode(eapi_file,
@@ -155,9 +157,10 @@ class LocationsManager(object):
 			# protect against nested repositories.  Insane configuration, but the longest
 			# path will be the correct one.
 			repo_loc, layout_data = max(intersecting_repos, key=lambda x:len(x[0]))
-			allow_directories = any(x in _portage1_profiles_allow_directories
-				for x in layout_data['profile-formats'])
-			compat_mode = layout_data['profile-formats'] == ('portage-1-compat',)
+			allow_directories = eapi_allows_directories_on_profile_level_and_repository_level(eapi) or \
+				any(x in _portage1_profiles_allow_directories for x in layout_data['profile-formats'])
+			compat_mode = not eapi_allows_directories_on_profile_level_and_repository_level(eapi) and \
+				layout_data['profile-formats'] == ('portage-1-compat',)
 			allow_parent_colon = any(x in _allow_parent_colon
 				for x in layout_data['profile-formats'])
 

diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 4de49f0..77b016d 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -18,6 +18,7 @@ except ImportError:
 from portage import eclass_cache, os
 from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH,
 	REPO_NAME_LOC, USER_CONFIG_PATH)
+from portage.eapi import eapi_allows_directories_on_profile_level_and_repository_level
 from portage.env.loaders import KeyValuePairFileLoader
 from portage.util import (normalize_path, read_corresponding_eapi_file, shlex_split,
 	stack_lists, writemsg, writemsg_level)
@@ -163,9 +164,10 @@ class RepoConfig(object):
 				'sign-commit', 'sign-manifest', 'thin-manifest', 'update-changelog'):
 				setattr(self, value.lower().replace("-", "_"), layout_data[value])
 
-			self.portage1_profiles = any(x in _portage1_profiles_allow_directories
-				for x in layout_data['profile-formats'])
-			self.portage1_profiles_compat = layout_data['profile-formats'] == ('portage-1-compat',)
+			self.portage1_profiles = eapi_allows_directories_on_profile_level_and_repository_level(eapi) or \
+				any(x in _portage1_profiles_allow_directories for x in layout_data['profile-formats'])
+			self.portage1_profiles_compat = not eapi_allows_directories_on_profile_level_and_repository_level(eapi) and \
+				layout_data['profile-formats'] == ('portage-1-compat',)
 
 	def iter_pregenerated_caches(self, auxdbkeys, readonly=True, force=False):
 		"""
@@ -760,7 +762,7 @@ def parse_layout_conf(repo_location, repo_name=None):
 
 	raw_formats = layout_data.get('profile-formats')
 	if raw_formats is None:
-		if eapi in ('4-python',):
+		if eapi_allows_directories_on_profile_level_and_repository_level(eapi):
 			raw_formats = ('portage-1',)
 		else:
 			raw_formats = ('portage-1-compat',)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_config/, pym/portage/repository/, pym/portage/, ...
@ 2012-10-14  1:35 Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 3+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2012-10-14  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     b7b906fdf49a55621a12798ae21d603d9ca4eb76
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Oct 14 01:33:38 2012 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
CommitDate: Sun Oct 14 01:33:38 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b7b906fd

Bug #434970: Disable some warnings during `emerge --sync`.

---
 pym/_emerge/actions.py                             |    1 +
 pym/_emerge/main.py                                |    2 ++
 pym/portage/__init__.py                            |    2 ++
 .../package/ebuild/_config/LocationsManager.py     |    6 +++---
 pym/portage/repository/config.py                   |    8 +++++---
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 5d1110a..3003afc 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -2468,6 +2468,7 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
 		return 1
 
 	# Reload the whole config from scratch.
+	portage._sync_disabled_warnings = False
 	settings, trees, mtimedb = load_emerge_config(trees=trees)
 	adjust_configs(myopts, trees)
 	root_config = trees[settings['EROOT']]['root_config']

diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index e3557e5..dad144c 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -1655,6 +1655,8 @@ def emerge_main(args=None):
 
 	# Portage needs to ensure a sane umask for the files it creates.
 	os.umask(0o22)
+	if myaction == "sync":
+		portage._sync_disabled_warnings = True
 	settings, trees, mtimedb = load_emerge_config()
 	portdb = trees[settings['EROOT']]['porttree'].dbapi
 	rval = profile_check(trees, myaction)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 695f1ea..9119b25 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -328,6 +328,8 @@ _python_interpreter = os.path.realpath(sys.executable)
 _bin_path = PORTAGE_BIN_PATH
 _pym_path = PORTAGE_PYM_PATH
 
+_sync_disabled_warnings = False
+
 def _shell_quote(s):
 	"""
 	Quote a string in double-quotes and use backslashes to

diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
index c3099d7..1ca2b32 100644
--- a/pym/portage/package/ebuild/_config/LocationsManager.py
+++ b/pym/portage/package/ebuild/_config/LocationsManager.py
@@ -100,9 +100,9 @@ class LocationsManager(object):
 				self._addProfile(os.path.realpath(self.profile_path),
 					repositories, known_repos)
 			except ParseError as e:
-				writemsg(_("!!! Unable to parse profile: '%s'\n") % \
-					self.profile_path, noiselevel=-1)
-				writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
+				if not portage._sync_disabled_warnings:
+					writemsg(_("!!! Unable to parse profile: '%s'\n") % self.profile_path, noiselevel=-1)
+					writemsg("!!! ParseError: %s\n" % str(e), noiselevel=-1)
 				self.profiles = []
 				self.profiles_complex = []
 

diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py
index 83018b8..71f548c 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -15,6 +15,7 @@ try:
 		from configparser import SafeConfigParser
 except ImportError:
 	from ConfigParser import SafeConfigParser, ParsingError
+import portage
 from portage import eclass_cache, os
 from portage.const import (MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH,
 	REPO_NAME_LOC, USER_CONFIG_PATH)
@@ -396,8 +397,8 @@ class RepoConfigLoader(object):
 
 					prepos[repo.name] = repo
 				else:
-					writemsg(_("!!! Invalid PORTDIR_OVERLAY"
-						" (not a dir): '%s'\n") % ov, noiselevel=-1)
+					if not portage._sync_disabled_warnings:
+						writemsg(_("!!! Invalid PORTDIR_OVERLAY (not a dir): '%s'\n") % ov, noiselevel=-1)
 
 		return portdir
 
@@ -521,7 +522,8 @@ class RepoConfigLoader(object):
 				prepos['DEFAULT'].main_repo = ignored_location_map[portdir]
 			else:
 				prepos['DEFAULT'].main_repo = None
-				writemsg(_("!!! main-repo not set in DEFAULT and PORTDIR is empty. \n"), noiselevel=-1)
+				if not portage._sync_disabled_warnings:
+					writemsg(_("!!! main-repo not set in DEFAULT and PORTDIR is empty.\n"), noiselevel=-1)
 
 		self.prepos = prepos
 		self.prepos_order = prepos_order


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-14  1:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-25  2:26 [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/_config/, pym/portage/repository/, pym/portage/, Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2012-09-21  6:32 Arfrever Frehtes Taifersar Arahesis
2012-10-14  1:35 Arfrever Frehtes Taifersar Arahesis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox