Code Duplication    Length = 26-27 lines in 2 locations

doorstop/core/validators/item_validator.py 1 location

@@ 15-41 (lines=27) @@
12
class ItemValidator:
13
    """Class for validation of Item objects."""
14
15
    def validate(self, item, skip=None, document_hook=None, item_hook=None):
16
        """Check the object for validity.
17
18
        :param item: item to validate
19
        :param skip: list of document prefixes to skip
20
        :param document_hook: function to call for custom document
21
            validation
22
        :param item_hook: function to call for custom item validation
23
24
        :return: indication that the object is valid
25
26
        """
27
        valid = True
28
        # Display all issues
29
        for issue in self.get_issues(
30
            item, skip=skip, document_hook=document_hook, item_hook=item_hook
31
        ):
32
            if isinstance(issue, DoorstopInfo) and not settings.WARN_ALL:
33
                log.info(issue)
34
            elif isinstance(issue, DoorstopWarning) and not settings.ERROR_ALL:
35
                log.warning(issue)
36
            else:
37
                assert isinstance(issue, DoorstopError)
38
                log.error(issue)
39
                valid = False
40
        # Return the result
41
        return valid
42
43
    def get_issues(
44
        self, item, skip=None, document_hook=None, item_hook=None

doorstop/core/base.py 1 location

@@ 125-150 (lines=26) @@
122
class BaseValidatable(metaclass=abc.ABCMeta):
123
    """Abstract Base Class for objects that can be validated."""
124
125
    def validate(self, skip=None, document_hook=None, item_hook=None):
126
        """Check the object for validity.
127
128
        :param skip: list of document prefixes to skip
129
        :param document_hook: function to call for custom document
130
            validation
131
        :param item_hook: function to call for custom item validation
132
133
        :return: indication that the object is valid
134
135
        """
136
        valid = True
137
        # Display all issues
138
        for issue in self.get_issues(
139
            skip=skip, document_hook=document_hook, item_hook=item_hook
140
        ):
141
            if isinstance(issue, DoorstopInfo) and not settings.WARN_ALL:
142
                log.info(issue)
143
            elif isinstance(issue, DoorstopWarning) and not settings.ERROR_ALL:
144
                log.warning(issue)
145
            else:
146
                assert isinstance(issue, DoorstopError)
147
                log.error(issue)
148
                valid = False
149
        # Return the result
150
        return valid
151
152
    @abc.abstractmethod
153
    def get_issues(self, skip=None, document_hook=None, item_hook=None):