return detail
+class FileStatHelper:
+ """Helper to store file handle's C{fstat}.
+
+ Useful in combination with L{ReadFile}'s C{preread} parameter.
+
+ """
+ def __init__(self):
+ """Initializes this class.
+
+ """
+ self.st = None
+
+ def __call__(self, fh):
+ """Calls C{fstat} on file handle.
+
+ """
+ self.st = os.fstat(fh.fileno())
+
+
def ReadFile(file_name, size=-1, preread=None):
"""Reads a file.
for inst in instances])
-class _StatCb:
- """Helper to store file handle's C{fstat}.
-
- """
- def __init__(self):
- """Initializes this class.
-
- """
- self.st = None
-
- def __call__(self, fh):
- """Calls C{fstat} on file handle.
-
- """
- self.st = os.fstat(fh.fileno())
-
-
def _ReadInstanceStatus(filename):
"""Reads an instance status file.
"""
logging.debug("Reading per-group instance status from '%s'", filename)
- statcb = _StatCb()
+ statcb = utils.FileStatHelper()
try:
content = utils.ReadFile(filename, preread=statcb)
except EnvironmentError, err: