combox

split and encrypted files between online file storage providers
git clone git://git.ricketyspace.net/combox.git
Log | Files | Refs

commit df9497d7c18a6dc7e7a284b7087765ca464e8a6b
parent 49ea6f4a2fc4588b298329dd75c76cbc56b59562
Author: Siddharth Ravikumar <sravik@bgsu.edu>
Date:   Fri, 16 Oct 2015 23:20:06 -0400

refactored read_file function combox.file module.

Thanks https://stackoverflow.com/questions/8009882/how-to-read-large-file-line-by-line-in-python

Diffstat:
combox/file.py | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/combox/file.py b/combox/file.py @@ -344,14 +344,11 @@ def read_file(filename): filename: Absolute pathname of the file. """ file_ = None - try: - file_ = open(filename, 'rb') - except IOError: - print "ERROR: opening %s" % (filename) - exit(1) + content = '' - content = file_.read() - file_.close() + with open(filename, 'rb') as f: + for line in f: + content = content + line return content