• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eronnen / procmon-parser / 4246972319

pending completion
4246972319

push

github

GitHub
Add github action for tests (#25)

1495 of 1587 relevant lines covered (94.2%)

0.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.56
/procmon_parser/__init__.py
1
from six import PY2
1✔
2

3
from procmon_parser.configuration import *
1✔
4
from procmon_parser.configuration_format import load_configuration, loads_configuration, dump_configuration, \
1✔
5
    dumps_configuration
6
from procmon_parser.logs import *
1✔
7
from procmon_parser.stream_logs_format import PMLStreamReader
1✔
8

9
__all__ = [
1✔
10
    'ProcmonLogsReader', 'load_configuration', 'loads_configuration', 'dump_configuration', 'dumps_configuration',
11
    'Rule', 'Column', 'RuleAction', 'RuleRelation', 'PMLError'
12
]
13

14

15
class ProcmonLogsReader(object):
1✔
16
    """Reads procmon logs from a stream which in the PML format
1✔
17
    """
18

19
    def __init__(self, f, should_get_stacktrace=True, should_get_details=True):
1✔
20
        """Build a ProcmonLogsReader object from ``f`` (a `.read()``-supporting file-like object).
21
        :param f: ``read`` supporting file-like object
22
        :param should_get_stacktrace: True if the parser should parse the stack traces
23
        :param should_get_details: True if the parser should parse the Detail column information of the event.
24
        """
25
        self._struct_readear = PMLStreamReader(f, should_get_stacktrace, should_get_details)
1✔
26
        self._current_event_index = 0
1✔
27

28
    def __iter__(self):
1✔
29
        return self
1✔
30

31
    def __next__(self):
1✔
32
        if self._current_event_index >= self.__len__():
1✔
33
            raise StopIteration
1✔
34
        current_index = self._current_event_index
1✔
35
        self._current_event_index += 1
1✔
36
        return self[current_index]
1✔
37

38
    if PY2:
1✔
39
        next = __next__
×
40

41
    def __getitem__(self, index):
1✔
42
        return self._struct_readear[index]
1✔
43

44
    def __len__(self):
1✔
45
        return self._struct_readear.number_of_events
1✔
46

47
    def processes(self):
1✔
48
        """Return a list of all the known processes in the log file
49
        """
50
        return self._struct_readear.processes()
1✔
51

52
    def system_details(self):
1✔
53
        """Return the system details of the computer which captured the logs (like Tools -> System Details in Procmon)
54
        """
55
        return self._struct_readear.system_details()
1✔
56

57

58
def read_all_events_from_pml(file):
1✔
59
    """
60
    Helper function that reads all the events from a PML file.
61
    :param file: the path to the PML file or an open file object.
62
    :return: a list of Event objects from the file.
63
    """
64
    if not hasattr(file, 'read'):
×
65
        with open(file, "rb") as f:
×
66
            pml_reader = PMLStreamReader(f)
×
67
            return list(pml_reader)
×
68
    else:
69
        pml_reader = PMLStreamReader(file)
×
70
        return list(pml_reader)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc