python-kacl 0.7.5__py3-none-any.whl → 0.7.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kacl/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Version of the python-kacl package
2
- __version__ = "0.7.5"
2
+ __version__ = "0.7.6"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
kacl/version.py CHANGED
@@ -105,6 +105,24 @@ class KACLVersion(KACLElement):
105
105
  self.__sections[sec.title()] = sec
106
106
  return self.__sections
107
107
 
108
+ def duplicate_sections(self):
109
+ """Returns every section element whose title was already used earlier in this version."""
110
+ if not self.body().strip():
111
+ return []
112
+
113
+ seen = set()
114
+ duplicates = []
115
+ for section in KACLParser.parse_header(
116
+ text=self.body(),
117
+ start_depth=3,
118
+ end_depth=3,
119
+ line_offset=self.line_number(),
120
+ ):
121
+ if section.title() in seen:
122
+ duplicates.append(section)
123
+ seen.add(section.title())
124
+ return duplicates
125
+
108
126
  def changes(self, section):
109
127
  sections = self.sections()
110
128
  if sections and section in sections:
@@ -200,11 +218,23 @@ class KACLVersion(KACLElement):
200
218
  try:
201
219
  sections = self.sections()
202
220
  except ValueError as e:
203
- errors.append(
204
- KACLValidationError(
205
- error_message=str(e), line_number=self.line_number()
221
+ duplicates = self.duplicate_sections()
222
+ if not duplicates:
223
+ errors.append(
224
+ KACLValidationError(
225
+ error_message=str(e), line_number=self.line_number()
226
+ )
227
+ )
228
+ for duplicate in duplicates:
229
+ errors.append(
230
+ KACLValidationError(
231
+ line=duplicate.raw(),
232
+ line_number=duplicate.line_number(),
233
+ error_message=f"Version '{self.version()}' has multiple sections with title '{duplicate.title()}'",
234
+ start_character_pos=0,
235
+ end_character_pos=len(duplicate.raw()),
236
+ )
206
237
  )
207
- )
208
238
  return errors
209
239
 
210
240
  for title, element in sections.items():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.7.5
3
+ Version: 0.7.6
4
4
  Summary: Python module and CLI tool for validating and modifying Changelogs in "keep-a-changelog" format"
5
5
  Author-email: Matthias Schmieder <schmieder.matthias@gmail.com>
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- kacl/__init__.py,sha256=jQQnMp9drah5bhx6AFllMuhAOLMGMsudro18sY77Qxw,667
1
+ kacl/__init__.py,sha256=TSKqPUQPsZJN1hgqqbXv4rRZl2vA0GBEhQFvsmfzHtw,667
2
2
  kacl/__main__.py,sha256=cpulIGoFUJNN5ZW9oUoNN1PnBvrOyJ24xwtpf_yRwgQ,91
3
3
  kacl/changes.py,sha256=Speu1KLMNQVn0U2BMaO8ta4IEaQLTQtpW0IhN0JjGdY,704
4
4
  kacl/config.py,sha256=c2QiP-BriJJwzrw36oigJWKe6t4o6yhmN_nPSL6bcRk,4242
@@ -12,11 +12,11 @@ kacl/parser.py,sha256=EUtRjgaW0beWVqiYaRJ9Rcf6jbuGoTgWzVBdOdUHnv8,2587
12
12
  kacl/serializer.py,sha256=g5eFim8OpSbgyShyFANSwOEbAfJqCNUXaRJtPO79blc,3931
13
13
  kacl/utils.py,sha256=4iWIJVNtv22v0IGXDjuEATPMQsJBr5Ycy9Q2zV2jkHE,2835
14
14
  kacl/validation.py,sha256=b9r_5CyY6Cmi9BePh47IgZ3j64zdVsoB_fFvucieNbw,2125
15
- kacl/version.py,sha256=IDYCWIIXzxdYyMptUAidMgf0SXJqoETFVJ8NVyKgA9A,9526
15
+ kacl/version.py,sha256=Rh0DpHqjrkoPhemWEzRMu11U7DY1f8PvCh30zwggF5I,10692
16
16
  kacl/config/kacl-default.yml,sha256=cXHl_w04SW0HA7OyJMMuaC6DTeXlhI2Sfsx7lygTPf4,1513
17
- python_kacl-0.7.5.dist-info/licenses/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
18
- python_kacl-0.7.5.dist-info/METADATA,sha256=Bi95X698RpQupow4_jv6cPS-cjaXqNIX5ss2YQ2jxT8,42453
19
- python_kacl-0.7.5.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
20
- python_kacl-0.7.5.dist-info/entry_points.txt,sha256=rXqqJKfm6Y7fYfioq_7ay2VWOOM9C-hts1IsoGTtojM,76
21
- python_kacl-0.7.5.dist-info/top_level.txt,sha256=BcmQgo67JyGnVZ3Jc0Ag8hKMGVOqXc8ex01zW4Njw5M,5
22
- python_kacl-0.7.5.dist-info/RECORD,,
17
+ python_kacl-0.7.6.dist-info/licenses/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
18
+ python_kacl-0.7.6.dist-info/METADATA,sha256=4zMhPmNR_e0v0xOFoRZ8wh4r_yN_mwKmSUU9tPuSZ8E,42453
19
+ python_kacl-0.7.6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
20
+ python_kacl-0.7.6.dist-info/entry_points.txt,sha256=rXqqJKfm6Y7fYfioq_7ay2VWOOM9C-hts1IsoGTtojM,76
21
+ python_kacl-0.7.6.dist-info/top_level.txt,sha256=BcmQgo67JyGnVZ3Jc0Ag8hKMGVOqXc8ex01zW4Njw5M,5
22
+ python_kacl-0.7.6.dist-info/RECORD,,