Revert "Added the new PKGBUILD for starfields-logparser."

This reverts commit b21df6a09e.
This commit is contained in:
2023-12-15 09:53:28 +02:00
parent b21df6a09e
commit c6d3a00d20
4 changed files with 95 additions and 5 deletions

View File

@@ -0,0 +1,59 @@
#!/usr/bin/python
class BaseOrderedLogParser:
"""
This parser is to be inherited from. It goes through log entries
until it finds an entry it hasn't gone through, in which case it
parses until the end of the entries.
"""
def execute(self):
status = self.retrieve_status()
context_manager = self.get_context_manager()
with context_manager(*self.context_manager_args) as file:
aggregates = self.aggregators_init(file, status)
line = file.readline()
new_flag = False
while (line):
# Only check for a new line if we're not at new entries yet
if not new_flag:
new_flag = self.new_flag_condition(line, status)
# Ignore old entries and only consider new ones
if new_flag:
break_condition = self.parse_line(line, aggregates, status)
if not break_condition:
break
line = file.readline()
self.aggregators_deinit(file, aggregates, status)
self.update_status(aggregates, status)
def get_context_manager(self):
"""
Hook to customize the context manager. Defaults to the file context
manager. The context manager file should have a readline() method
that reads the next "line".
"""
return open
def aggregators_deinit(self, file, aggregates, status):
"""
Hook that runs right before the context manager closes the file. It
comes with the aggregates and the status date so sometimes closing the
status of the parser here makes more sense.
"""
pass
def update_status(self, aggregates, status):
"""
Updates the saved status of the parser.
"""
pass