Get a unique reference if there are duplicates.
(self, reference: str, found: bool = False)
| 134 | self.used_refs = set() |
| 135 | |
| 136 | def unique_ref(self, reference: str, found: bool = False) -> str: |
| 137 | """ Get a unique reference if there are duplicates. """ |
| 138 | if not found: |
| 139 | return reference |
| 140 | |
| 141 | original_ref = reference |
| 142 | while reference in self.used_refs: |
| 143 | ref, rest = reference.split(self.get_separator(), 1) |
| 144 | m = RE_REF_ID.match(ref) |
| 145 | if m: |
| 146 | reference = '%s%d%s%s' % (m.group(1), int(m.group(2))+1, self.get_separator(), rest) |
| 147 | else: |
| 148 | reference = '%s%d%s%s' % (ref, 2, self.get_separator(), rest) |
| 149 | |
| 150 | self.used_refs.add(reference) |
| 151 | if original_ref in self.found_refs: |
| 152 | self.found_refs[original_ref] += 1 |
| 153 | else: |
| 154 | self.found_refs[original_ref] = 1 |
| 155 | return reference |
| 156 | |
| 157 | def findFootnotesPlaceholder( |
| 158 | self, root: etree.Element |
no test coverage detected