utils.py 1.2 KB

1234567891011121314151617181920212223242526272829
  1. class FileProxyMixin(object):
  2. """
  3. A mixin class used to forward file methods to an underlaying file
  4. object. The internal file object has to be called "file"::
  5. class FileProxy(FileProxyMixin):
  6. def __init__(self, file):
  7. self.file = file
  8. """
  9. encoding = property(lambda self: self.file.encoding)
  10. fileno = property(lambda self: self.file.fileno)
  11. flush = property(lambda self: self.file.flush)
  12. isatty = property(lambda self: self.file.isatty)
  13. newlines = property(lambda self: self.file.newlines)
  14. read = property(lambda self: self.file.read)
  15. readinto = property(lambda self: self.file.readinto)
  16. readline = property(lambda self: self.file.readline)
  17. readlines = property(lambda self: self.file.readlines)
  18. seek = property(lambda self: self.file.seek)
  19. softspace = property(lambda self: self.file.softspace)
  20. tell = property(lambda self: self.file.tell)
  21. truncate = property(lambda self: self.file.truncate)
  22. write = property(lambda self: self.file.write)
  23. writelines = property(lambda self: self.file.writelines)
  24. xreadlines = property(lambda self: self.file.xreadlines)
  25. def __iter__(self):
  26. return iter(self.file)