public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arfrever Frehtes Taifersar Arahesis" <Arfrever@Apache.Org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/
Date: Tue,  7 Jan 2014 20:40:23 +0000 (UTC)	[thread overview]
Message-ID: <1389127189.5007501b4a166e0e72d5b852ea7a3cb440942b1c.arfrever@gentoo> (raw)

commit:     5007501b4a166e0e72d5b852ea7a3cb440942b1c
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Tue Jan  7 20:39:49 2014 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
CommitDate: Tue Jan  7 20:39:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5007501b

Use with statements.

---
 pym/portage/tests/resolver/ResolverPlayground.py | 100 ++++++++++-------------
 1 file changed, 43 insertions(+), 57 deletions(-)

diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
index 99c66cd..9577743 100644
--- a/pym/portage/tests/resolver/ResolverPlayground.py
+++ b/pym/portage/tests/resolver/ResolverPlayground.py
@@ -116,9 +116,8 @@ class ResolverPlayground(object):
 				pass
 
 			repo_name_file = os.path.join(profile_path, "repo_name")
-			f = open(repo_name_file, "w")
-			f.write("%s\n" % repo)
-			f.close()
+			with open(repo_name_file, "w") as f:
+				f.write("%s\n" % repo)
 
 		return self._repositories[repo]["location"]
 
@@ -158,15 +157,14 @@ class ResolverPlayground(object):
 			except os.error:
 				pass
 
-			f = open(ebuild_path, "w")
-			if copyright_header is not None:
-				f.write(copyright_header)
-			f.write('EAPI="%s"\n' % eapi)
-			for k, v in metadata.items():
-				f.write('%s="%s"\n' % (k, v))
-			if misc_content is not None:
-				f.write(misc_content)
-			f.close()
+			with open(ebuild_path, "w") as f:
+				if copyright_header is not None:
+					f.write(copyright_header)
+				f.write('EAPI="%s"\n' % eapi)
+				for k, v in metadata.items():
+					f.write('%s="%s"\n' % (k, v))
+				if misc_content is not None:
+					f.write(misc_content)
 
 	def _create_ebuild_manifests(self, ebuilds):
 		tmpsettings = config(clone=self.settings)
@@ -271,16 +269,14 @@ class ResolverPlayground(object):
 					categories.add(catsplit(cpv)[0])
 
 			categories_file = os.path.join(profile_dir, "categories")
-			f = open(categories_file, "w")
-			for cat in categories:
-				f.write(cat + "\n")
-			f.close()
+			with open(categories_file, "w") as f:
+				for cat in categories:
+					f.write(cat + "\n")
 
 			#Create $REPO/profiles/license_groups
 			license_file = os.path.join(profile_dir, "license_groups")
-			f = open(license_file, "w")
-			f.write("EULA TEST\n")
-			f.close()
+			with open(license_file, "w") as f:
+				f.write("EULA TEST\n")
 
 			repo_config = repo_configs.get(repo)
 			if repo_config:
@@ -294,10 +290,9 @@ class ResolverPlayground(object):
 						file_name = os.path.join(profile_dir, config_file)
 						if "/" in config_file and not os.path.isdir(os.path.dirname(file_name)):
 							os.makedirs(os.path.dirname(file_name))
-					f = open(file_name, "w")
-					for line in lines:
-						f.write("%s\n" % line)
-					f.close()
+					with open(file_name, "w") as f:
+						for line in lines:
+							f.write("%s\n" % line)
 
 			#Create $profile_dir/eclass (we fail to digest the ebuilds if it's not there)
 			os.makedirs(os.path.join(repo_dir, "eclass"))
@@ -315,25 +310,21 @@ class ResolverPlayground(object):
 
 				if not (profile and "eapi" in profile):
 					eapi_file = os.path.join(sub_profile_dir, "eapi")
-					f = open(eapi_file, "w")
-					f.write("0\n")
-					f.close()
+					with open(eapi_file, "w") as f:
+						f.write("0\n")
 
 				make_defaults_file = os.path.join(sub_profile_dir, "make.defaults")
-				f = open(make_defaults_file, "w")
-				f.write("ARCH=\"x86\"\n")
-				f.write("ACCEPT_KEYWORDS=\"x86\"\n")
-				f.close()
+				with open(make_defaults_file, "w") as f:
+					f.write("ARCH=\"x86\"\n")
+					f.write("ACCEPT_KEYWORDS=\"x86\"\n")
 
 				use_force_file = os.path.join(sub_profile_dir, "use.force")
-				f = open(use_force_file, "w")
-				f.write("x86\n")
-				f.close()
+				with open(use_force_file, "w") as f:
+					f.write("x86\n")
 
 				parent_file = os.path.join(sub_profile_dir, "parent")
-				f = open(parent_file, "w")
-				f.write("..\n")
-				f.close()
+				with open(parent_file, "w") as f:
+					f.write("..\n")
 
 				if profile:
 					for config_file, lines in profile.items():
@@ -341,10 +332,9 @@ class ResolverPlayground(object):
 							raise ValueError("Unknown config file: '%s'" % config_file)
 
 						file_name = os.path.join(sub_profile_dir, config_file)
-						f = open(file_name, "w")
-						for line in lines:
-							f.write("%s\n" % line)
-						f.close()
+						with open(file_name, "w") as f:
+							for line in lines:
+								f.write("%s\n" % line)
 
 				#Create profile symlink
 				os.symlink(sub_profile_dir, os.path.join(user_config_dir, "make.profile"))
@@ -411,10 +401,9 @@ class ResolverPlayground(object):
 				raise ValueError("Unknown config file: '%s'" % config_file)
 
 			file_name = os.path.join(user_config_dir, config_file)
-			f = open(file_name, "w")
-			for line in lines:
-				f.write("%s\n" % line)
-			f.close()
+			with open(file_name, "w") as f:
+				for line in lines:
+					f.write("%s\n" % line)
 
 		#Create /usr/share/portage/config/make.globals
 		make_globals_path = os.path.join(self.eroot,
@@ -444,10 +433,9 @@ class ResolverPlayground(object):
 
 		for sets_file, lines in sets.items():
 			file_name = os.path.join(set_config_dir, sets_file)
-			f = open(file_name, "w")
-			for line in lines:
-				f.write("%s\n" % line)
-			f.close()
+			with open(file_name, "w") as f:
+				for line in lines:
+					f.write("%s\n" % line)
 
 	def _create_world(self, world, world_sets):
 		#Create /var/lib/portage/world
@@ -457,15 +445,13 @@ class ResolverPlayground(object):
 		world_file = os.path.join(var_lib_portage, "world")
 		world_set_file = os.path.join(var_lib_portage, "world_sets")
 
-		f = open(world_file, "w")
-		for atom in world:
-			f.write("%s\n" % atom)
-		f.close()
+		with open(world_file, "w") as f:
+			for atom in world:
+				f.write("%s\n" % atom)
 
-		f = open(world_set_file, "w")
-		for atom in world_sets:
-			f.write("%s\n" % atom)
-		f.close()
+		with open(world_set_file, "w") as f:
+			for atom in world_sets:
+				f.write("%s\n" % atom)
 
 	def _load_config(self):
 
@@ -746,7 +732,7 @@ class ResolverPlaygroundResult(object):
 				self.license_changes[pkg.cpv] = missing_licenses
 
 		if self.depgraph._dynamic_config._slot_conflict_handler is not None:
-			self.slot_collision_solutions  = []
+			self.slot_collision_solutions = []
 			handler = self.depgraph._dynamic_config._slot_conflict_handler
 
 			for change in handler.changes:


             reply	other threads:[~2014-01-07 20:40 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 20:40 Arfrever Frehtes Taifersar Arahesis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-03-04 21:05 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/ Michał Górny
2018-02-26 22:07 Michał Górny
2017-12-16  3:16 Zac Medico
2016-06-26 23:51 Zac Medico
2016-04-29 17:24 Brian Dolbec
2014-09-19  8:52 Zac Medico
2014-09-16  6:35 Brian Dolbec
2014-02-24 20:03 Sebastian Luther
2014-01-07 19:06 Arfrever Frehtes Taifersar Arahesis
2013-12-05 21:51 Arfrever Frehtes Taifersar Arahesis
2013-11-27  7:44 Mike Frysinger
2013-11-27  3:24 Mike Frysinger
2013-11-26 15:11 Brian Dolbec
2013-11-26 13:50 Brian Dolbec
2013-08-22  0:46 Zac Medico
2013-07-30  2:13 Zac Medico
2013-03-04 23:37 Zac Medico
2013-02-14  1:20 Zac Medico
2013-02-12  3:03 Zac Medico
2013-02-12  1:36 Zac Medico
2012-10-26 17:25 Zac Medico
2012-10-26  6:31 Zac Medico
2012-10-26  3:44 Zac Medico
2012-09-26  2:38 Zac Medico
2012-09-26  2:36 Zac Medico
2012-09-26  0:52 Zac Medico
2012-09-25  3:30 Zac Medico
2012-06-23 21:53 Zac Medico
2012-06-21 22:32 Zac Medico
2012-06-20 10:06 Zac Medico
2012-06-20  9:53 Zac Medico
2012-06-14  0:24 Zac Medico
2012-05-13  6:23 Zac Medico
2011-12-11  0:22 Zac Medico
2011-11-07 21:38 Zac Medico
2011-10-02  2:14 Zac Medico
2011-09-22 19:07 Zac Medico
2011-09-22 18:19 Zac Medico
2011-09-18 20:08 Zac Medico
2011-09-11 18:50 Zac Medico
2011-09-05 22:44 Zac Medico
2011-08-29  6:19 Zac Medico
2011-06-04  3:08 Zac Medico
2011-05-30 23:44 Zac Medico
2011-05-30 22:58 Zac Medico
2011-05-23  5:59 Zac Medico
2011-05-23  0:46 Zac Medico
2011-05-22 22:01 Zac Medico
2011-05-22 21:01 Zac Medico
2011-05-22 20:36 Zac Medico
2011-05-22 20:03 Zac Medico
2011-05-22 19:44 Zac Medico
2011-05-22 17:03 Zac Medico
2011-05-22  9:05 Zac Medico
2011-05-21 22:37 Zac Medico
2011-05-21 22:17 Zac Medico
2011-05-21 10:34 Zac Medico
2011-05-21 10:30 Zac Medico
2011-05-21  9:21 Zac Medico
2011-05-21  9:11 Zac Medico
2011-05-21  8:47 Zac Medico
2011-05-21  4:15 Zac Medico
2011-05-21  4:02 Zac Medico
2011-05-21  3:30 Zac Medico
2011-05-21  1:17 Zac Medico
2011-05-21  1:13 Zac Medico
2011-05-21  1:01 Zac Medico
2011-05-21  0:51 Zac Medico
2011-05-17 20:34 Zac Medico
2011-05-04 17:36 Zac Medico
2011-02-17 10:43 Zac Medico
2011-02-13 17:35 Zac Medico
2011-02-13 13:01 Zac Medico
2011-02-13 11:35 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=1389127189.5007501b4a166e0e72d5b852ea7a3cb440942b1c.arfrever@gentoo \
    --to=arfrever@apache.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