The documentation for file objects' read method states that if the size
is "negative or ommitted", all data is read; thus we can simplify it to
have size=-1 by default and not have the if test.
---
 lib/utils.py |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index 91baa88..f08e75c 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -1226,21 +1226,18 @@ def EnsureDirs(dirs):
       raise errors.GenericError("%s is not a directory" % dir_name)
 
 
-def ReadFile(file_name, size=None):
+def ReadFile(file_name, size=-1):
   """Reads a file.
 
-  @type size: None or int
-  @param size: Read at most size bytes
+  @type size: int
+  @param size: Read at most size bytes (if negative, entire file)
   @rtype: str
   @return: the (possibly partial) content of the file
 
   """
   f = open(file_name, "r")
   try:
-    if size is None:
-      return f.read()
-    else:
-      return f.read(size)
+    return f.read(size)
   finally:
     f.close()
 
-- 
1.6.5.3

Reply via email to