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

Hekxsler / pudding / 18468262725

13 Oct 2025 02:00PM UTC coverage: 85.586% (+2.8%) from 82.779%
18468262725

push

github

web-flow
[writer]: fix value being None as a string

1045 of 1221 relevant lines covered (85.59%)

0.86 hits per line

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

93.55
pudding/reader/reader.py
1
"""Module defining Reader class."""
2

3
import logging
1✔
4

5
from re import Match, Pattern
1✔
6

7
from ..processor.triggers import Trigger
1✔
8

9
logger = logging.getLogger(__name__)
1✔
10

11

12
class Reader:
1✔
13
    """Base Reader class.
14

15
    :var current_pos: Current position in content.
16
    :var last_match: Last Match object or None if regex did not match.
17
    """
18

19
    current_pos = 0
1✔
20
    last_match: Match[str] | None = None
1✔
21

22
    def __init__(self, content: str) -> None:
1✔
23
        """Init class."""
24
        self.content = content
1✔
25
        self.endpos = len(content)
1✔
26

27
    @property
1✔
28
    def eof(self) -> bool:
1✔
29
        """Boolean if end of content has been reached."""
30
        return self.current_pos >= self.endpos
1✔
31

32
    @property
1✔
33
    def current_line_number(self) -> int:
1✔
34
        """Line number of the current position."""
35
        return self.content.count("\n", None, self.current_pos) + 1
×
36

37
    def _match(self, regex: Pattern[str]) -> Match[str] | None:
1✔
38
        """Try matching a regex to the content ahead and set the result as last_match.
39

40
        :param regex: The pattern to match.
41
        :returns: The match or None if it did not match.
42
        """
43
        logger.debug("Trying to match /%s/", regex.pattern)
1✔
44
        if self.eof:
1✔
45
            return None
1✔
46
        self.last_match = regex.match(self.content, self.current_pos)
1✔
47
        return self.last_match
1✔
48

49
    def find(self, regex: Pattern[str]) -> Match[str] | None:
1✔
50
        """Try finding a match for the regex in the content ahead."""
51
        return self._match(regex)
×
52

53
    def match(self, regex: Pattern[str]) -> Match[str] | None:
1✔
54
        """Try matching a regex to the content ahead and advance."""
55
        match = self._match(regex)
1✔
56
        if match is not None:
1✔
57
            self.current_pos += len(match.group(0))
1✔
58
        return match
1✔
59

60
    def test_trigger(self, trigger: Trigger) -> bool:
1✔
61
        """Test if a trigger matches.
62

63
        :param trigger: The trigger object.
64
        :returns: Boolean if trigger matches.
65
        """
66
        return trigger.match.match(self.content, self.current_pos) is not None
1✔
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