Completed
Pull Request — develop (#399)
by
unknown
04:59
created

doorstop.core.item.Item.heading()   A

Complexity

Conditions 5

Size

Total Lines 8
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 8
rs 9.3333
c 0
b 0
f 0
cc 5
nop 2
1
# SPDX-License-Identifier: LGPL-3.0-only
2
3
"""Representation of an item in a document."""
4
5
import functools
6
import os
7
from typing import Any, List
8
9
import pyficache
10
11
from doorstop import common, settings
12
from doorstop.common import DoorstopError
13
from doorstop.core import editor
14
from doorstop.core.base import (
15
    BaseFileObject,
16
    add_item,
17
    auto_load,
18
    auto_save,
19
    delete_item,
20
    edit_item,
21
)
22
from doorstop.core.reference_finder import ReferenceFinder
23
from doorstop.core.types import UID, Level, Prefix, Stamp, Text, to_bool
24
from doorstop.core.yaml_validator import YamlValidator
25
26
log = common.logger(__name__)
27
28
29
def _convert_to_yaml(indent, prefix, value):
30
    """Convert value to YAML output format.
31
32
    :param indent: the indentation level
33
    :param prefix: the length of the prefix before the value, e.g. '- ' for
34
    lists or 'key: ' for keys
35
    :param value: the value to convert
36
37
    :return: the value converted to YAML output format
38
39
    """
40
    if isinstance(value, str):
41
        length = indent + prefix + len(value)
42
        if length > settings.MAX_LINE_LENGTH or '\n' in value:
43
            value = Text.save_text(value.strip())
44
        else:
45
            value = str(value)  # line is short enough as a string
46
    elif isinstance(value, list):
47
        value = [_convert_to_yaml(indent, 2, v) for v in value]
48
    elif isinstance(value, dict):
49
        value = {
50
            k: _convert_to_yaml(indent + 2, len(k) + 2, v) for k, v in value.items()
51
        }
52
    return value
53
54
55
def requires_tree(func):
56
    """Require a tree reference."""
57
58
    @functools.wraps(func)
59
    def wrapped(self, *args, **kwargs):
60
        if not self.tree:
61
            name = func.__name__
62
            log.critical("`{}` can only be called with a tree".format(name))
63
            return None
64
        return func(self, *args, **kwargs)
65
66
    return wrapped
67
68
69
class Item(BaseFileObject):  # pylint: disable=R0902
70
    """Represents an item file with linkable text."""
71
72
    EXTENSIONS = '.yml', '.yaml'
73
74
    DEFAULT_LEVEL = Level('1.0')
75
    DEFAULT_ACTIVE = True
76
    DEFAULT_NORMATIVE = True
77
    DEFAULT_DERIVED = False
78
    DEFAULT_REVIEWED = Stamp()
79
    DEFAULT_TEXT = Text()
80
    DEFAULT_REF = ""
81
    DEFAULT_HEADER = Text()
82
83
    def __init__(self, document, path, root=os.getcwd(), **kwargs):
84
        """Initialize an item from an existing file.
85
86
        :param path: path to Item file
87
        :param root: path to root of project
88
89
        """
90
        super().__init__()
91
        # Ensure the path is valid
92
        if not os.path.isfile(path):
93
            raise DoorstopError("item does not exist: {}".format(path))
94
        # Ensure the filename is valid
95
        filename = os.path.basename(path)
96
        name, ext = os.path.splitext(filename)
97
        try:
98
            UID(name).check()
99
        except DoorstopError:
100
            msg = "invalid item filename: {}".format(filename)
101
            raise DoorstopError(msg) from None
102
        # Ensure the file extension is valid
103
        if ext.lower() not in self.EXTENSIONS:
104
            msg = "'{0}' extension not in {1}".format(path, self.EXTENSIONS)
105
            raise DoorstopError(msg)
106
        # Initialize the item
107
        self.path = path
108
        self.root: str = root
109
        self.document = document
110
        self.tree = kwargs.get('tree')
111
        self.auto = kwargs.get('auto', Item.auto)
112
        self.reference_finder = ReferenceFinder()
113
        self.yaml_validator = YamlValidator()
114
        # Set default values
115
        self._data['level'] = Item.DEFAULT_LEVEL
116
        self._data['active'] = Item.DEFAULT_ACTIVE
117
        self._data['normative'] = Item.DEFAULT_NORMATIVE
118
        self._data['derived'] = Item.DEFAULT_DERIVED
119
        self._data['reviewed'] = Item.DEFAULT_REVIEWED
120
        self._data['text'] = Item.DEFAULT_TEXT
121
        self._data['ref'] = Item.DEFAULT_REF
122
        self._data['references'] = None
123
        self._data['links'] = set()
124
        if settings.ENABLE_HEADERS:
125
            self._data['header'] = Item.DEFAULT_HEADER
126
127
    def __repr__(self):
128
        return "Item('{}')".format(self.path)
129
130
    def __str__(self):
131
        if common.verbosity < common.STR_VERBOSITY:
132
            return str(self.uid)
133
        else:
134
            return "{} ({})".format(self.uid, self.relpath)
135
136
    def __lt__(self, other):
137
        if self.level == other.level:
138
            return self.uid < other.uid
139
        else:
140
            return self.level < other.level
141
142
    @staticmethod
143
    @add_item
144
    def new(
145
        tree, document, path, root, uid, level=None, auto=None
146
    ):  # pylint: disable=R0913
147
        """Create a new item.
148
149
        :param tree: reference to the tree that contains this item
150
        :param document: reference to document that contains this item
151
152
        :param path: path to directory for the new item
153
        :param root: path to root of the project
154
        :param uid: UID for the new item
155
156
        :param level: level for the new item
157
        :param auto: automatically save the item
158
159
        :raises: :class:`~doorstop.common.DoorstopError` if the item
160
            already exists
161
162
        :return: new :class:`~doorstop.core.item.Item`
163
164
        """
165
        UID(uid).check()
166
        filename = str(uid) + Item.EXTENSIONS[0]
167
        path2 = os.path.join(path, filename)
168
        # Create the initial item file
169
        log.debug("creating item file at {}...".format(path2))
170
        Item._create(path2, name='item')
171
        # Initialize the item
172
        item = Item(document, path2, root=root, tree=tree, auto=False)
173
        item.level = level if level is not None else item.level  # type: ignore
174
        if auto or (auto is None and Item.auto):
175
            item.save()
176
        # Return the item
177
        return item
178
179
    def _set_attributes(self, attributes):
180
        """Set the item's attributes."""
181
        self.yaml_validator.validate_item_yaml(attributes)
182
        for key, value in attributes.items():
183
            if key == 'level':
184
                value = Level(value)
185
            elif key == 'active':
186
                value = to_bool(value)
187
            elif key == 'normative':
188
                value = to_bool(value)
189
            elif key == 'derived':
190
                value = to_bool(value)
191
            elif key == 'reviewed':
192
                value = Stamp(value)
193
            elif key == 'text':
194
                value = Text(value)
195
            elif key == 'ref':
196
                value = value.strip()
197
            elif key == 'references':
198
                if value is None:
199
                    continue
200
201
                stripped_value = []
202
                for ref_dict in value:
203
                    ref_type = ref_dict['type']
204
                    ref_path = ref_dict['path']
205
                    stripped_value.append({"type": ref_type, "path": ref_path.strip()})
206
                value = stripped_value
207
            elif key == 'links':
208
                value = set(UID(part) for part in value)
209
            elif key == 'header':
210
                value = Text(value)
211
            self._data[key] = value
212
213
    def load(self, reload=False):
214
        """Load the item's properties from its file."""
215
        if self._loaded and not reload:
216
            return
217
        log.debug("loading {}...".format(repr(self)))
218
        # Read text from file
219
        text = self._read(self.path)
220
        # Parse YAML data from text
221
        data = self._load(text, self.path)
222
        # Store parsed data
223
        self._set_attributes(data)
224
        # Set meta attributes
225
        self._loaded = True
226
227
    @edit_item
228
    def save(self):
229
        """Format and save the item's properties to its file."""
230
        log.debug("saving {}...".format(repr(self)))
231
        # Format the data items
232
        data = self._yaml_data()
233
        # Dump the data to YAML
234
        text = self._dump(data)
235
        # Save the YAML to file
236
        self._write(text, self.path)
237
        # Set meta attributes
238
        self._loaded = True
239
        self.auto = True
240
241
    # properties #############################################################
242
243
    def _yaml_data(self):
244
        """Get all the item's data formatted for YAML dumping."""
245
        data = {}
246
        for key, value in self._data.items():
247
            if key == 'level':
248
                value = value.yaml
249
            elif key == 'text':
250
                value = value.yaml
251
            elif key == 'header':
252
                # Handle for case if the header is undefined in YAML
253
                if hasattr(value, 'yaml'):
254
                    value = value.yaml
255
                else:
256
                    value = ''
257
            elif key == 'ref':
258
                value = value.strip()
259
            elif key == 'references':
260
                if value is None:
261
                    continue
262
                stripped_value = []
263
                for el in value:
264
                    stripped_value.append({"type": "file", "path": el["path"].strip()})
265
                value = stripped_value
266
            elif key == 'links':
267
                value = [{str(i): i.stamp.yaml} for i in sorted(value)]
268
            elif key == 'reviewed':
269
                value = value.yaml
270
            else:
271
                value = _convert_to_yaml(0, len(key) + 2, value)
272
            data[key] = value
273
        return data
274
275
    @property  # type: ignore
276
    @auto_load
277
    def data(self):
278
        """Load and get all the item's data formatted for YAML dumping."""
279
        return self._yaml_data()
280
281
    @property
282
    def uid(self):
283
        """Get the item's UID."""
284
        filename = os.path.basename(self.path)
285
        return UID(os.path.splitext(filename)[0])
286
287
    @property
288
    def prefix(self):
289
        """Get the item UID's prefix."""
290
        return self.uid.prefix
291
292
    @property
293
    def number(self):
294
        """Get the item UID's number."""
295
        return self.uid.number
296
297
    @property  # type: ignore
298
    @auto_load
299
    def level(self):
300
        """Get the item's level."""
301
        return self._data['level']
302
303
    @level.setter  # type: ignore
304
    @auto_save
305
    def level(self, value):
306
        """Set the item's level."""
307
        self._data['level'] = Level(value)
308
309
    @property
310
    def depth(self):
311
        """Get the item's heading order based on it's level."""
312
        return len(self.level)
313
314
    @property  # type: ignore
315
    @auto_load
316
    def active(self):
317
        """Get the item's active status.
318
319
        An inactive item will not be validated. Inactive items are
320
        intended to be used for:
321
322
        - future requirements
323
        - temporarily disabled requirements or tests
324
        - externally implemented requirements
325
        - etc.
326
327
        """
328
        return self._data['active']
329
330
    @active.setter  # type: ignore
331
    @auto_save
332
    def active(self, value):
333
        """Set the item's active status."""
334
        self._data['active'] = to_bool(value)
335
336
    @property  # type: ignore
337
    @auto_load
338
    def derived(self):
339
        """Get the item's derived status.
340
341
        A derived item does not have links to items in its parent
342
        document, but should still be linked to by items in its child
343
        documents.
344
345
        """
346
        return self._data['derived']
347
348
    @derived.setter  # type: ignore
349
    @auto_save
350
    def derived(self, value):
351
        """Set the item's derived status."""
352
        self._data['derived'] = to_bool(value)
353
354
    @property  # type: ignore
355
    @auto_load
356
    def normative(self):
357
        """Get the item's normative status.
358
359
        A non-normative item should not have or be linked to.
360
        Non-normative items are intended to be used for:
361
362
        - headings
363
        - comments
364
        - etc.
365
366
        """
367
        return self._data['normative']
368
369
    @normative.setter  # type: ignore
370
    @auto_save
371
    def normative(self, value):
372
        """Set the item's normative status."""
373
        self._data['normative'] = to_bool(value)
374
375
    @property
376
    def heading(self):
377
        """Indicate if the item is a heading.
378
379
        Headings have a level that ends in zero and are non-normative.
380
381
        """
382
        return self.level.heading and not self.normative
383
384
    @heading.setter  # type: ignore
385
    @auto_save
386
    def heading(self, value):
387
        """Set the item's heading status."""
388
        heading = to_bool(value)
389
        if heading and not self.heading:
390
            self.level.heading = True
391
            self.normative = False
392
        elif not heading and self.heading:
393
            self.level.heading = False
394
            self.normative = True
395
396
    @property  # type: ignore
397
    @auto_load
398
    def cleared(self):
399
        """Indicate if no links are suspect."""
400
        for uid, item in self._get_parent_uid_and_item():
401
            if uid.stamp != item.stamp():
402
                return False
403
        return True
404
405
    @property  # type: ignore
406
    @auto_load
407
    def reviewed(self):
408
        """Indicate if the item has been reviewed."""
409
        stamp = self.stamp(links=True)
410
        if self._data['reviewed'] == Stamp(True):
411
            self._data['reviewed'] = stamp
412
        return self._data['reviewed'] == stamp
413
414
    @reviewed.setter  # type: ignore
415
    @auto_save
416
    def reviewed(self, value):
417
        """Set the item's review status."""
418
        self._data['reviewed'] = Stamp(value)
419
420
    @property  # type: ignore
421
    @auto_load
422
    def text(self):
423
        """Get the item's text."""
424
        return self._data['text']
425
426
    @text.setter  # type: ignore
427
    @auto_save
428
    def text(self, value):
429
        """Set the item's text."""
430
        self._data['text'] = Text(value)
431
432
    @property  # type: ignore
433
    @auto_load
434
    def header(self):
435
        """Get the item's header."""
436
        if settings.ENABLE_HEADERS:
437
            return self._data['header']
438
        return None
439
440
    @header.setter  # type: ignore
441
    @auto_save
442
    def header(self, value):
443
        """Set the item's header."""
444
        if settings.ENABLE_HEADERS:
445
            self._data['header'] = Text(value)
446
447
    @property  # type: ignore
448
    @auto_load
449
    def ref(self):
450
        """Get the item's external file reference.
451
452
        An external reference can be part of a line in a text file or
453
        the filename of any type of file.
454
455
        """
456
        return self._data['ref']
457
458
    @ref.setter  # type: ignore
459
    @auto_save
460
    def ref(self, value):
461
        """Set the item's external file reference."""
462
        self._data['ref'] = str(value) if value else ""
463
464
    @property  # type: ignore
465
    @auto_load
466
    def references(self):
467
        """Get the item's external file references.
468
469
        An external reference can be part of a line in a text file or
470
        the filename of any type of file.
471
472
        """
473
        return self._data['references']
474
475
    @references.setter  # type: ignore
476
    @auto_save
477
    def references(self, value):
478
        """Set the item's external file reference."""
479
        if value is not None:
480
            assert isinstance(value, list)
481
        self._data['references'] = value
482
483
    @property  # type: ignore
484
    @auto_load
485
    def links(self):
486
        """Get a list of the item UIDs this item links to."""
487
        return sorted(self._data['links'])
488
489
    @links.setter  # type: ignore
490
    @auto_save
491
    def links(self, value):
492
        """Set the list of item UIDs this item links to."""
493
        self._data['links'] = set(UID(v) for v in value)
494
495
    @property
496
    def parent_links(self):
497
        """Get a list of the item UIDs this item links to."""
498
        return self.links  # alias
499
500
    @parent_links.setter
501
    def parent_links(self, value):
502
        """Set the list of item UIDs this item links to."""
503
        self.links = value  # alias
504
505
    @requires_tree
506
    def _get_parent_uid_and_item(self):
507
        """Yield UID and item of all links of this item."""
508
        for uid in self.links:
509
            try:
510
                item = self.tree.find_item(uid)
511
            except DoorstopError:
512
                item = UnknownItem(uid)
513
                log.warning(item.exception)
514
            yield uid, item
515
516
    @property
517
    def parent_items(self):
518
        """Get a list of items that this item links to."""
519
        return [item for uid, item in self._get_parent_uid_and_item()]
520
521
    @property  # type: ignore
522
    @requires_tree
523
    def parent_documents(self):
524
        """Get a list of documents that this item's document should link to.
525
526
        .. note::
527
528
           A document only has one parent.
529
530
        """
531
        try:
532
            return [self.tree.find_document(self.document.prefix)]
533
        except DoorstopError:
534
            log.warning(Prefix.UNKNOWN_MESSAGE.format(self.document.prefix))
535
            return []
536
537
    # actions ################################################################
538
539
    @auto_save
540
    def set_attributes(self, attributes):
541
        """Set the item's attributes and save them."""
542
        self._set_attributes(attributes)
543
544
    @auto_save
545
    def edit(self, tool=None, edit_all=True):
546
        """Open the item for editing.
547
548
        :param tool: path of alternate editor
549
        :param edit_all: True to edit the whole item,
550
            False to only edit the text.
551
552
        """
553
        # Lock the item
554
        if self.tree:
555
            self.tree.vcs.lock(self.path)
556
        # Edit the whole file in an editor
557
        if edit_all:
558
            editor.edit(self.path, tool=tool)
559
        # Edit only the text part in an editor
560
        else:
561
            # Edit the text in a temporary file
562
            edited_text = editor.edit_tmp_content(
563
                title=str(self.uid), original_content=str(self.text), tool=tool
564
            )
565
            # Save the text in the actual item file
566
            self.text = edited_text
567
            self.save()
568
569
        # Force reloaded
570
        self._loaded = False
571
572
    @auto_save
573
    def link(self, value):
574
        """Add a new link to another item UID.
575
576
        :param value: item or UID
577
578
        """
579
        uid = UID(value)
580
        log.info("linking to '{}'...".format(uid))
581
        self._data['links'].add(uid)
582
583
    @auto_save
584
    def unlink(self, value):
585
        """Remove an existing link by item UID.
586
587
        :param value: item or UID
588
589
        """
590
        uid = UID(value)
591
        try:
592
            self._data['links'].remove(uid)
593
        except KeyError:
594
            log.warning("link to {0} does not exist".format(uid))
595
596
    def is_reviewed(self):
597
        return self._data['reviewed']
598
599
    def set_links(self, links):
600
        self._data['links'] = links
601
602
    @requires_tree
603
    def find_ref(self):
604
        """Get the external file reference and line number.
605
606
        :raises: :class:`~doorstop.common.DoorstopError` when no
607
            reference is found
608
609
        :return: relative path to file or None (when no reference
610
            set),
611
            line number (when found in file) or None (when found as
612
            filename) or None (when no reference set)
613
614
        """
615
        # Return immediately if no external reference
616
        if not self.ref:
617
            log.debug("no external reference to search for")
618
            return None, None
619
        # Update the cache
620
        if not settings.CACHE_PATHS:
621
            pyficache.clear_file_cache()
622
        # Search for the external reference
623
        return self.reference_finder.find_ref(self.ref, self.tree, self.path)
624
625
    @requires_tree
626
    def find_references(self):
627
        """Get the array of references. Check each references before returning.
628
629
        :raises: :class:`~doorstop.common.DoorstopError` when no
630
            reference is found
631
632
        :return: relative path to file or None (when no reference
633
            set),
634
            line number (when found in file) or None (when found as
635
            filename) or None (when no reference set)
636
637
        """
638
        if not self.references:
639
            log.debug("no external reference to search for")
640
            return []
641
        if not settings.CACHE_PATHS:
642
            pyficache.clear_file_cache()
643
        for ref_item in self.references:
644
            path = ref_item["path"]
645
            self.reference_finder.find_file_reference(path, self.root, self.tree, path)
646
        return self.references
647
648
    def _find_external_file_ref(self, ref_path):
649
        log.debug("searching for ref '{}'...".format(ref_path))
650
        ref_full_path = os.path.join(self.root, ref_path)
651
652
        for path, filename, relpath in self.tree.vcs.paths:
653
            # Skip the item's file while searching
654
            if path == self.path:
655
                continue
656
            if path == ref_full_path:
657
                return True
658
659
        msg = "external reference not found: {}".format(ref_path)
660
        raise DoorstopError(msg)
661
662
    def find_child_links(self, find_all=True):
663
        """Get a list of item UIDs that link to this item (reverse links).
664
665
        :param find_all: find all items (not just the first) before returning
666
667
        :return: list of found item UIDs
668
669
        """
670
        items, _ = self.find_child_items_and_documents(find_all=find_all)
671
        identifiers = [item.uid for item in items]
672
        return identifiers
673
674
    child_links = property(find_child_links)
675
676
    def find_child_items(self, find_all=True):
677
        """Get a list of items that link to this item.
678
679
        :param find_all: find all items (not just the first) before returning
680
681
        :return: list of found items
682
683
        """
684
        items, _ = self.find_child_items_and_documents(find_all=find_all)
685
        return items
686
687
    child_items = property(find_child_items)
688
689
    def find_child_documents(self):
690
        """Get a list of documents that should link to this item's document.
691
692
        :return: list of found documents
693
694
        """
695
        _, documents = self.find_child_items_and_documents(find_all=False)
696
        return documents
697
698
    child_documents = property(find_child_documents)
699
700
    def find_child_items_and_documents(self, document=None, tree=None, find_all=True):
701
        """Get lists of child items and child documents.
702
703
        :param document: document containing the current item
704
        :param tree: tree containing the current item
705
        :param find_all: find all items (not just the first) before returning
706
707
        :return: list of found items, list of all child documents
708
709
        """
710
        child_items: List[Item] = []
711
        child_documents: List[Any] = []  # `List[Document]`` creats an import cycle
712
        document = document or self.document
713
        tree = tree or self.tree
714
        if not document or not tree:
715
            return child_items, child_documents
716
        # Find child objects
717
        log.debug("finding item {}'s child objects...".format(self))
718
        for document2 in tree:
719
            if document2.parent == document.prefix:
720
                child_documents.append(document2)
721
                # Search for child items unless we only need to find one
722
                if not child_items or find_all:
723
                    for item2 in document2:
724
                        if self.uid in item2.links:
725
                            if not item2.active:
726
                                item2 = UnknownItem(item2.uid)
727
                                log.warning(item2.exception)
728
                                child_items.append(item2)
729
                            else:
730
                                child_items.append(item2)
731
                                if not find_all and item2.active:
732
                                    break
733
        # Display found links
734
        if child_items:
735
            if find_all:
736
                joined = ', '.join(str(i) for i in child_items)
737
                msg = "child items: {}".format(joined)
738
            else:
739
                msg = "first child item: {}".format(child_items[0])
740
            log.debug(msg)
741
            joined = ', '.join(str(d) for d in child_documents)
742
            log.debug("child documents: {}".format(joined))
743
        return sorted(child_items), child_documents
744
745
    @auto_load
746
    def stamp(self, links=False):
747
        """Hash the item's key content for later comparison."""
748
        values = [self.uid, self.text, self.ref]
749
750
        if self.references:
751
            values.append(self.references)
752
753
        if links:
754
            values.extend(self.links)
755
        for key in self.document.extended_reviewed:
756
            if key in self._data:
757
                values.append(self._dump(self._data[key]))
758
            else:
759
                log.warning(
760
                    "{}: missing extended reviewed attribute: {}".format(self.uid, key)
761
                )
762
        return Stamp(*values)
763
764
    @auto_save
765
    def clear(self, parents=None):
766
        """Clear suspect links."""
767
        log.info("clearing suspect links...")
768
        for uid, item in self._get_parent_uid_and_item():
769
            if not parents or uid in parents:
770
                uid.stamp = item.stamp()
771
772
    @auto_save
773
    def review(self):
774
        """Mark the item as reviewed."""
775
        log.info("marking item as reviewed...")
776
        self._data['reviewed'] = self.stamp(links=True)
777
778
    @delete_item
779
    def delete(self, path=None):
780
        """Delete the item."""
781
782
783
class UnknownItem:
784
    """Represents an unknown item, which doesn't have a path."""
785
786
    UNKNOWN_PATH = '???'  # string to represent an unknown path
787
788
    normative = False  # do not include unknown items in traceability
789
    level = Item.DEFAULT_LEVEL
790
791
    def __init__(self, value, spec=Item):
792
        self._uid = UID(value)
793
        self._spec = dir(spec)  # list of attribute names for warnings
794
        msg = UID.UNKNOWN_MESSAGE.format(k='', u=self.uid)
795
        self.exception = DoorstopError(msg)
796
797
    def __str__(self):
798
        return Item.__str__(self)
799
800
    def __getattr__(self, name):
801
        if name in self._spec:
802
            log.debug(self.exception)
803
        return self.__getattribute__(name)
804
805
    def __lt__(self, other):
806
        return self.uid < other.uid
807
808
    @property
809
    def uid(self):
810
        """Get the item's UID."""
811
        return self._uid
812
813
    prefix = Item.prefix
814
    number = Item.number
815
816
    @property
817
    def relpath(self):
818
        """Get the unknown item's relative path string."""
819
        return "@{}{}".format(os.sep, self.UNKNOWN_PATH)
820
821
    def stamp(self):  # pylint: disable=R0201
822
        """Return an empty stamp."""
823
        return Stamp(None)
824