--- a/pvl/syslog/file.py Sun Jan 13 04:52:43 2013 +0200
+++ b/pvl/syslog/file.py Sun Jan 13 12:57:30 2013 +0200
@@ -13,11 +13,15 @@
readline() may block once there is no more input available, or may return None for evermore.
There is no fileno(), this is not pollable. At all. Don't even iterate on this with a timeout.
- XXX: should this really return None? Might really be better to raise EOFError.. except that readlines() should return normally at EOF...
+
+ TODO: it would be nice if this raised EOFError (to avoid bugs with polling this infinitely), but at least
+ the first readlines() must complete normally
"""
@classmethod
def open (cls, path, mode='r', **opts) :
+ log.debug("%s", path)
+
return cls(open(path, mode), **opts)
EOL = '\n'
@@ -54,6 +58,7 @@
line = self.readline()
if line is None :
+ log.debug("%s: eof", self)
return
else :
yield line
@@ -80,4 +85,14 @@
self.file.flush()
+ def close (self) :
+ """
+ Close our file. Further operations raise ValueError.
+ """
+
+ log.debug("%s", self)
+ self.file.close()
+ def __str__ (self) :
+ # XXX: optional attr?
+ return self.file.name