Code Duplication    Length = 36-43 lines in 2 locations

doorstop/core/item.py 1 location

@@ 1241-1283 (lines=43) @@
1238
                        document.parent, uid)
1239
                    yield DoorstopInfo(msg)
1240
1241
    def _get_issues_tree(self, tree):
1242
        """Yield all the item's issues against its tree."""
1243
        log.debug("getting issues against tree...")
1244
        # Verify an item's links are valid
1245
    
1246
        identifiers = set()
1247
        for uid in self.links:
1248
            try:
1249
                item = tree.find_item(uid)
1250
            except DoorstopError:
1251
                identifiers.add(uid)  # keep the invalid UID
1252
                msg = "linked to unknown item: {}".format(uid)
1253
                yield DoorstopError(msg)
1254
            else:
1255
                # check the linked item
1256
                if not item.active:
1257
                    msg = "linked to inactive item: {}".format(item)
1258
                    yield DoorstopInfo(msg)
1259
                if not item.normative:
1260
                    msg = "linked to non-normative item: {}".format(item)
1261
                    yield DoorstopWarning(msg)
1262
                # check the link status
1263
                
1264
                # wenn bis es bis jetzt noch keinen stamp gibt ... funktioniert allerdings glaube ich nicht ....
1265
                if uid.stamp == Stamp(True):
1266
                    uid.stamp = item.stamp()  #... convert True to a stamp
1267
                
1268
1269
                elif uid.stamp != item.stamp():
1270
                    # 12.12.2019
1271
                    # print('STAMPS FOR LINKS')
1272
                    # print(item.stamp())
1273
                    # print(uid.stamp)
1274
                    # print(uid)
1275
                    if settings.CHECK_SUSPECT_LINKS:
1276
                        msg = "suspect link: {}".format(item)
1277
                        yield DoorstopWarning(msg)
1278
                # reformat the item's UID
1279
                identifier2 = UID(item.uid, stamp=uid.stamp)
1280
                identifiers.add(identifier2)
1281
        # Apply the reformatted item UIDs
1282
        if settings.REFORMAT:
1283
            self._data['links'] = identifiers
1284
1285
    def _get_issues_both(self, document, tree):
1286
        """Yield all the item's issues against its document and tree."""

doorstop/core/validators/item_validator.py 1 location

@@ 153-188 (lines=36) @@
150
                    )
151
                    yield DoorstopInfo(msg)
152
153
    def _get_issues_tree(self, item, tree):
154
        """Yield all the item's issues against its tree."""
155
        log.debug("getting issues against tree...")
156
157
        # Verify an item's links are valid
158
        identifiers = set()
159
        for uid in item.links:
160
            try:
161
                parent = tree.find_item(uid)
162
            except DoorstopError:
163
                identifiers.add(uid)  # keep the invalid UID
164
                msg = "linked to unknown item: {}".format(uid)
165
                yield DoorstopError(msg)
166
            else:
167
                # check the parent item
168
                if not parent.active:
169
                    msg = "linked to inactive item: {}".format(parent)
170
                    yield DoorstopInfo(msg)
171
                if not parent.normative:
172
                    msg = "linked to non-normative item: {}".format(parent)
173
                    yield DoorstopWarning(msg)
174
                # check the link status
175
                if uid.stamp == Stamp(True):
176
                    uid.stamp = parent.stamp()
177
                elif not str(uid.stamp) and settings.STAMP_NEW_LINKS:
178
                    uid.stamp = parent.stamp()
179
                elif uid.stamp != parent.stamp():
180
                    if settings.CHECK_SUSPECT_LINKS:
181
                        msg = "suspect link: {}".format(parent)
182
                        yield DoorstopWarning(msg)
183
                # reformat the item's UID
184
                identifiers.add(UID(parent.uid, stamp=uid.stamp))
185
186
        # Apply the reformatted item UIDs
187
        if settings.REFORMAT:
188
            item.links = identifiers
189
190
    def _get_issues_both(self, item, document, tree, skip):
191
        """Yield all the item's issues against its document and tree."""