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 4C1F9138247 for ; Tue, 7 Jan 2014 20:40:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AD469E0B71; Tue, 7 Jan 2014 20:40:26 +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 369AFE0B71 for ; Tue, 7 Jan 2014 20:40:26 +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 019FD33D762 for ; Tue, 7 Jan 2014 20:40:25 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5852BE54AB for ; Tue, 7 Jan 2014 20:40:23 +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: <1389127189.5007501b4a166e0e72d5b852ea7a3cb440942b1c.arfrever@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/tests/resolver/ResolverPlayground.py X-VCS-Directories: pym/portage/tests/resolver/ X-VCS-Committer: arfrever X-VCS-Committer-Name: Arfrever Frehtes Taifersar Arahesis X-VCS-Revision: 5007501b4a166e0e72d5b852ea7a3cb440942b1c X-VCS-Branch: master Date: Tue, 7 Jan 2014 20:40:23 +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: c64c3ad5-b2c3-4aab-bd15-492b5cb13133 X-Archives-Hash: 83a1e0022f451ca1184f5d954a9a4d0a commit: 5007501b4a166e0e72d5b852ea7a3cb440942b1c Author: Arfrever Frehtes Taifersar Arahesis Apache Org> AuthorDate: Tue Jan 7 20:39:49 2014 +0000 Commit: Arfrever Frehtes Taifersar Arahesis Apache 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: