| | |
- TailInterface
-
- Tailer
- TailedFile
class TailInterface |
| |
An interface for file watching. |
| |
Methods defined here:
- __init__(self, *files, **kw)
- Files is a list of files to watch. Keyword arguments include:
interval (for the interval at which the file should be poll()ed
for pollloop() and initial for the initial end of the file.
Setting initial to zero will make it read the entire file on
the first poll() and any subsequent additions for the poll()s
after that.
- poll(self)
- If any files have grown, return a tuple containing the filename and
new text. If no files have changed, we return None
- pollloop(self, callback)
- Continously watches the files for changes, sleeping for
'interval' amount of seconds in between (see __init__). If there
are any changes, it will call the callback with two arguments:
the filename and new text.
Data and non-method functions defined here:
- __doc__ = 'An interface for file watching.'
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
- __module__ = 'Tailer'
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
|
class TailedFile |
| |
An object representing an object being tailed and it's current state |
| |
Methods defined here:
- __init__(self, filename, initial=None)
- Filename is the name of the file to watch. initial is the
size where where should start watching from. Omitting initial
will result in watching changes from the end of the file.
- __len__(self)
- Returns the size of the file
- __str__(self)
- Returns the filename of the file
- poll(self)
- Returns a string of the new text in the file if there is any.
If there isn't, it returns None. If the file shrinks (for whatever
reason), it will start watching from the new end of the file.
Data and non-method functions defined here:
- __doc__ = "An object representing an object being tailed and it's current state"
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
- __module__ = 'Tailer'
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
|
class Tailer(TailInterface) |
| |
An object that watches one or more files for additions. You can
either call it whenever you want with poll(), or use pollloop()
to call it regularly. |
| |
Methods defined here:
- __init__(self, *files, **kw)
- Given a list of files and some keyword arguments, constructs
an object which will watch the files for additions. The optional
keyword 'interval' affects the frequency at which pollloop()
will check the files. Keywords arguments will be passed along
to the TailedFiles.
- multipoll(self)
- Returns a list of changes in files. It returns a list of
(filename, newtext) tuples. If there are no changes, it will
return the empty list.
- poll(self)
- If any files have grown, return a tuple containing the
filename and new text. If no files have changed, we return None.
Note that this function is a generator so that it will (try to)
give each file equal treatment in polling.
- pollloop(self, callback)
- Continously watches the files for changes, sleeping for
'interval' amount of seconds in between (see __init__). If there
are any changes, it will call the callback with two arguments:
the filename and new text.
Data and non-method functions defined here:
- __doc__ = 'An object that watches one or more files for add...ll(), or use pollloop()\n to call it regularly.'
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
- __module__ = 'Tailer'
- str(object) -> string
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
| |