Commit 016308cb authored by Iustin Pop's avatar Iustin Pop
Browse files

Simplify utils.ReadFile

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.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent 310fbb64
......@@ -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")
if size is None:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment