Get rid of unnecessary file.readline() calls.

This commit is contained in:
Florian Bruhin 2015-11-10 18:44:42 +01:00
parent d71618031d
commit 374b448e51
3 changed files with 4 additions and 4 deletions

View File

@ -82,7 +82,7 @@ class ExternalEditor(QObject):
encoding = config.get('general', 'editor-encoding')
try:
with open(self._filename, 'r', encoding=encoding) as f:
text = ''.join(f.readlines()) # pragma: no branch
text = f.read() # pragma: no branch
except OSError as e:
# NOTE: Do not replace this with "raise CommandError" as it's
# executed async.

View File

@ -213,9 +213,9 @@ class LineParser(BaseLineParser):
"""Read the data from self._configfile."""
with self._open('r') as f:
if self._binary:
self.data = [line.rstrip(b'\n') for line in f.readlines()]
self.data = [line.rstrip(b'\n') for line in f]
else:
self.data = [line.rstrip('\n') for line in f.readlines()]
self.data = [line.rstrip('\n') for line in f]
def save(self):
"""Save the config file."""

View File

@ -112,7 +112,7 @@ def _release_info():
for fn in glob.glob("/etc/*-release"):
try:
with open(fn, 'r', encoding='utf-8') as f:
data.append((fn, ''.join(f.readlines()))) # pragma: no branch
data.append((fn, f.read())) # pragma: no branch
except OSError:
log.misc.exception("Error while reading {}.".format(fn))
return data