public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/glsa/, pym/gentoolkit/, pym/gentoolkit/equery/, ...
@ 2015-11-24 20:01 Paul Varner
  0 siblings, 0 replies; only message in thread
From: Paul Varner @ 2015-11-24 20:01 UTC (permalink / raw
  To: gentoo-commits

commit:     e90e838718c737a1d41e4b8bc64e9e520d65270b
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 24 19:59:02 2015 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Nov 24 19:59:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e90e8387

Fix the file open() calls to work with Python 2

The generalized file open call needs to look like:
with open(_unicode_encode(path, encoding=_encodings['fs'])) as open_file

 pym/gentoolkit/deprecated/helpers.py      |  4 ++--
 pym/gentoolkit/eclean/exclude.py          |  4 ++--
 pym/gentoolkit/enalyze/rebuild.py         |  2 +-
 pym/gentoolkit/equery/uses.py             |  4 ++--
 pym/gentoolkit/equery/which.py            |  2 +-
 pym/gentoolkit/eshowkw/keywords_header.py |  4 ++--
 pym/gentoolkit/glsa/__init__.py           |  4 ++--
 pym/gentoolkit/helpers.py                 |  6 +++---
 pym/gentoolkit/revdep_rebuild/analyse.py  |  2 +-
 pym/gentoolkit/revdep_rebuild/cache.py    | 14 +++++++-------
 pym/gentoolkit/revdep_rebuild/collect.py  |  6 +++---
 pym/gentoolkit/revdep_rebuild/settings.py |  4 ++--
 12 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/pym/gentoolkit/deprecated/helpers.py b/pym/gentoolkit/deprecated/helpers.py
index c3a72dc..81fa45c 100644
--- a/pym/gentoolkit/deprecated/helpers.py
+++ b/pym/gentoolkit/deprecated/helpers.py
@@ -100,8 +100,8 @@ def find_system_packages(prefilter=None):
 def find_world_packages(prefilter=None):
 	"""Returns a tuple of lists, first list is resolved world packages,
 	seond is unresolved package names."""
-	f = open(_unicode_encode(portage.root+portage.WORLD_FILE),
-		encoding=_encodings['fs'])
+	f = open(_unicode_encode(portage.root+portage.WORLD_FILE,
+		encoding=_encodings['fs']))
 	pkglist = f.readlines()
 	resolved = []
 	unresolved = []

diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py
index 5a13186..d19c1d1 100644
--- a/pym/gentoolkit/eclean/exclude.py
+++ b/pym/gentoolkit/eclean/exclude.py
@@ -82,8 +82,8 @@ def parseExcludeFile(filepath, output):
 		}
 	output("Parsing Exclude file: " + filepath)
 	try:
-		file_ = open(_unicode_encode(filepath), 
-			encoding=_encodings['fs'], mode="r")
+		file_ = open(_unicode_encode(filepath, 
+			encoding=_encodings['fs']), mode="r")
 	except IOError:
 		raise ParseExcludeFileException("Could not open exclusion file: " +
 			filepath)

diff --git a/pym/gentoolkit/enalyze/rebuild.py b/pym/gentoolkit/enalyze/rebuild.py
index 3f9527a..11feb31 100644
--- a/pym/gentoolkit/enalyze/rebuild.py
+++ b/pym/gentoolkit/enalyze/rebuild.py
@@ -352,7 +352,7 @@ class Rebuild(ModuleBase):
 		"""
 		if  not self.options["quiet"]:
 			print('   - Saving file: %s' %filepath)
-		with open(_unicode_encode(filepath), encoding=_encodings['fs'], mode="w") as output:
+		with open(_unicode_encode(filepath, encoding=_encodings['fs']), mode="w") as output:
 			output.write('\n'.join(data))
 		print("   - Done")
 

diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py
index 7717710..79ed00f 100644
--- a/pym/gentoolkit/equery/uses.py
+++ b/pym/gentoolkit/equery/uses.py
@@ -136,7 +136,7 @@ def get_global_useflags():
 	# Get global USE flag descriptions
 	try:
 		path = os.path.join(settings["PORTDIR"], 'profiles', 'use.desc')
-		with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file:
+		with open(_unicode_encode(path, encoding=_encodings['fs'])) as open_file:
 			for line in open_file:
 				if line.startswith('#'):
 					continue
@@ -156,7 +156,7 @@ def get_global_useflags():
 	for path in glob(os.path.join(settings["PORTDIR"],
 		'profiles', 'desc', '*.desc')):
 		try:
-			with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file:
+			with open(_unicode_encode(path, encoding=_encodings['fs'])) as open_file:
 				for line in open_file:
 					if line.startswith('#'):
 						continue

diff --git a/pym/gentoolkit/equery/which.py b/pym/gentoolkit/equery/which.py
index ea03b90..0d30a8d 100644
--- a/pym/gentoolkit/equery/which.py
+++ b/pym/gentoolkit/equery/which.py
@@ -62,7 +62,7 @@ def print_help(with_description=True):
 
 def print_ebuild(ebuild_path):
 	"""Output the ebuild to std_out"""
-	with open(_unicode_encode(ebuild_path), encoding=_encodings['fs']) as f:
+	with open(_unicode_encode(ebuild_path, encoding=_encodings['fs'])) as f:
 		lines = f.readlines()
 		print("\n\n")
 		print("".join(lines))

diff --git a/pym/gentoolkit/eshowkw/keywords_header.py b/pym/gentoolkit/eshowkw/keywords_header.py
index 9ca0364..7bf71d0 100644
--- a/pym/gentoolkit/eshowkw/keywords_header.py
+++ b/pym/gentoolkit/eshowkw/keywords_header.py
@@ -31,7 +31,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
 
 	try:
 		arch_list = os.path.join(portdir, 'profiles', 'arch.list')
-		with open(_unicode_encode(arch_list), encoding=_encodings['fs']) as f:
+		with open(_unicode_encode(arch_list, encoding=_encodings['fs'])) as f:
 			for line in f:
 				line = line.split('#', 1)[0].strip()
 				if line:
@@ -47,7 +47,7 @@ def load_profile_data(portdir=None, repo='gentoo'):
 			None: 3,
 		}
 		profiles_list = os.path.join(portdir, 'profiles', 'profiles.desc')
-		with open(_unicode_encode(profiles_list), encoding=_encodings['fs']) as f:
+		with open(_unicode_encode(profiles_list, encoding=_encodings['fs'])) as f:
 			for line in f:
 				line = line.split('#', 1)[0].split()
 				if line:

diff --git a/pym/gentoolkit/glsa/__init__.py b/pym/gentoolkit/glsa/__init__.py
index 0d670b7..30a5ae2 100644
--- a/pym/gentoolkit/glsa/__init__.py
+++ b/pym/gentoolkit/glsa/__init__.py
@@ -704,8 +704,8 @@ class Glsa:
 		@returns:	None
 		"""
 		if not self.isInjected():
-			checkfile = open(_unicode_encode(self.config["CHECKFILE"]),
-				encoding=_encodings['fs'], mode="a+")
+			checkfile = open(_unicode_encode(self.config["CHECKFILE"],
+				encoding=_encodings['fs']), mode="a+")
 			checkfile.write(self.nr+"\n")
 			checkfile.close()
 		return None

diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index f9da6cd..b7314b9 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -194,8 +194,8 @@ class ChangeLog(object):
 
 		result = []
 		partial_entries = []
-		with open(_unicode_encode(self.changelog_path), 
-			encoding=_encodings['fs'], errors="replace") as log:
+		with open(_unicode_encode(self.changelog_path, 
+			encoding=_encodings['fs'], errors="replace")) as log:
 			for line in log:
 				if line.startswith('#'):
 					continue
@@ -464,7 +464,7 @@ def get_bintree_cpvs(predicate=None):
 def print_file(path):
 	"""Display the contents of a file."""
 
-	with open(_unicode_encode(path), encoding=_encodings['fs'], mode="rb") as open_file:
+	with open(_unicode_encode(path, encoding=_encodings['fs']), mode="rb") as open_file:
 		lines = open_file.read()
 		pp.uprint(lines.strip())
 

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 0f89b03..056e421 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -83,7 +83,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 		if not os.path.exists(_file):
 			continue
 
-		for line in open(_unicode_encode(_file), encoding=_encodings['fs'], mode='r').readlines():
+		for line in open(_unicode_encode(_file, encoding=_encodings['fs']), mode='r').readlines():
 			line = line.strip()
 			if line.startswith('dependency_libs='):
 				match = re.match("dependency_libs='([^']+)'", line)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 31ee2c9..36f0f72 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -30,8 +30,8 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		}
 	try:
 		for key,val in ret.items():
-			_file = open(_unicode_encode(os.path.join(temp_path, key)),
-				encoding=_encodings['fs'])
+			_file = open(_unicode_encode(os.path.join(temp_path, key),
+				encoding=_encodings['fs']))
 			for line in _file.readlines():
 				val.add(line.strip())
 			#libraries.remove('\n')
@@ -54,14 +54,14 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		os.makedirs(temp_path)
 
 	try:
-		_file = open(_unicode_encode(os.path.join(temp_path, 'timestamp')),
-			encoding=_encodings['fs'], mode='w')
+		_file = open(_unicode_encode(os.path.join(temp_path, 'timestamp'),
+			encoding=_encodings['fs']), mode='w')
 		_file.write(str(int(time.time())))
 		_file.close()
 
 		for key,val in to_save.items():
-			_file = open(_unicode_encode(os.path.join(temp_path, key)),
-				encoding=_encodings['fs'], mode='w')
+			_file = open(_unicode_encode(os.path.join(temp_path, key),
+				encoding=_encodings['fs']), mode='w')
 			for line in val:
 				_file.write(line + '\n')
 			_file.close()
@@ -89,7 +89,7 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600,
 		return False
 
 	try:
-		_file = open(_unicode_encode(timestamp_path), encoding=_encodings['fs'])
+		_file = open(_unicode_encode(timestamp_path, encoding=_encodings['fs']))
 		timestamp = int(_file.readline())
 		_file .close()
 	except Exception as ex:

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 758bcf7..1b406e8 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -35,7 +35,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 
 	for conf in conf_file:
 		try:
-			with open(_unicode_encode(conf), encoding=_encodings['fs']) as _file:
+			with open(_unicode_encode(conf, encoding=_encodings['fs'])) as _file:
 				for line in _file.readlines():
 					line = line.strip()
 					if line.startswith('#'):
@@ -76,8 +76,8 @@ def prepare_search_dirs(logger, settings):
 
 	#try:
 	with open(_unicode_encode(os.path.join(
-		portage.root, settings['DEFAULT_ENV_FILE'])),
-		encoding=_encodings['fs'], mode='r') as _file:
+		portage.root, settings['DEFAULT_ENV_FILE']),
+		encoding=_encodings['fs']), mode='r') as _file:
 		for line in _file.readlines():
 			line = line.strip()
 			match = re.match("^export (ROOT)?PATH='([^']+)'", line)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 257bd3a..e9a021a 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -137,8 +137,8 @@ def parse_revdep_config(revdep_confdir):
 	masked_files = os.environ.get('LD_LIBRARY_MASK', '')
 
 	for _file in os.listdir(revdep_confdir):
-		for line in open(_unicode_encode(os.path.join(revdep_confdir, _file)),
-				encoding=_encodings['fs']):
+		for line in open(_unicode_encode(os.path.join(revdep_confdir, _file),
+				encoding=_encodings['fs'])):
 			line = line.strip()
 			#first check for comment, we do not want to regex all lines
 			if not line.startswith('#'):


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-24 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 20:01 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/glsa/, pym/gentoolkit/, pym/gentoolkit/equery/, Paul Varner

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