X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fpython-systemd%2Fjournal.py;h=d0bcd24d1501aa8b800083259947c9320dd4ae36;hp=8fd1bb357c199bb32e488d17ffef08f204a65011;hb=fd587c876d480863d56bbbdc5e9fcf7e735d98f3;hpb=0a0c35d151570cca5ccd30befaa19c87b9c8c92d diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py index 8fd1bb357..d0bcd24d1 100644 --- a/src/python-systemd/journal.py +++ b/src/python-systemd/journal.py @@ -33,7 +33,8 @@ from syslog import (LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG) from ._journal import __version__, sendv, stream_fd from ._reader import (_Reader, NOP, APPEND, INVALIDATE, - LOCAL_ONLY, RUNTIME_ONLY, SYSTEM_ONLY, + LOCAL_ONLY, RUNTIME_ONLY, + SYSTEM, SYSTEM_ONLY, CURRENT_USER, _get_catalog) from . import id128 as _id128 @@ -123,7 +124,7 @@ class Reader(_Reader): See systemd.journal-fields(7) for more info on typical fields found in the journal. """ - def __init__(self, flags=0, path=None, converters=None): + def __init__(self, flags=0, path=None, files=None, converters=None): """Create an instance of Reader, which allows filtering and return of journal entries. @@ -149,7 +150,7 @@ class Reader(_Reader): Reader implements the context manager protocol: the journal will be closed when exiting the block. """ - super(Reader, self).__init__(flags, path) + super(Reader, self).__init__(flags, path, files) if _sys.version_info >= (3,3): self.converters = _ChainMap() if converters is not None: @@ -191,18 +192,18 @@ class Reader(_Reader): """ return self - if _sys.version_info >= (3,): - def __next__(self): - """Part of iterator protocol. - Returns self.get_next(). - """ - return self.get_next() - else: - def next(self): - """Part of iterator protocol. - Returns self.get_next(). - """ - return self.get_next() + def __next__(self): + """Part of iterator protocol. + Returns self.get_next() or raises StopIteration. + """ + ans = self.get_next() + if ans: + return ans + else: + raise StopIteration() + + if _sys.version_info < (3,): + next = __next__ def add_match(self, *args, **kwargs): """Add one or more matches to the filter journal log entries.