python-kacl 0.6.1__tar.gz → 0.6.3__tar.gz

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.
Files changed (33) hide show
  1. {python_kacl-0.6.1/python_kacl.egg-info → python_kacl-0.6.3}/PKG-INFO +13 -2
  2. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/__init__.py +1 -1
  3. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/document.py +15 -0
  4. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/parser.py +11 -0
  5. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/serializer.py +21 -4
  6. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/version.py +1 -1
  7. {python_kacl-0.6.1 → python_kacl-0.6.3/python_kacl.egg-info}/PKG-INFO +13 -2
  8. {python_kacl-0.6.1 → python_kacl-0.6.3}/setup.py +1 -1
  9. {python_kacl-0.6.1 → python_kacl-0.6.3}/tests/test_kacl.py +33 -0
  10. {python_kacl-0.6.1 → python_kacl-0.6.3}/LICENSE +0 -0
  11. {python_kacl-0.6.1 → python_kacl-0.6.3}/MANIFEST.in +0 -0
  12. {python_kacl-0.6.1 → python_kacl-0.6.3}/README.md +0 -0
  13. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/__main__.py +0 -0
  14. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/changes.py +0 -0
  15. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/config/kacl-default.yml +0 -0
  16. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/config.py +0 -0
  17. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/element.py +0 -0
  18. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/exception.py +0 -0
  19. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/jira_client.py +0 -0
  20. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/kacl_cli.py +0 -0
  21. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/link_provider.py +0 -0
  22. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/utils.py +0 -0
  23. {python_kacl-0.6.1 → python_kacl-0.6.3}/kacl/validation.py +0 -0
  24. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/SOURCES.txt +0 -0
  25. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/dependency_links.txt +0 -0
  26. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/entry_points.txt +0 -0
  27. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/not-zip-safe +0 -0
  28. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/requires.txt +0 -0
  29. {python_kacl-0.6.1 → python_kacl-0.6.3}/python_kacl.egg-info/top_level.txt +0 -0
  30. {python_kacl-0.6.1 → python_kacl-0.6.3}/setup.cfg +0 -0
  31. {python_kacl-0.6.1 → python_kacl-0.6.3}/tests/__init__.py +0 -0
  32. {python_kacl-0.6.1 → python_kacl-0.6.3}/tests/snapshot_directory.py +0 -0
  33. {python_kacl-0.6.1 → python_kacl-0.6.3}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.6.1
3
+ Version: 0.6.3
4
4
  Summary: Python module and CLI tool for validating and modifying Changelogs in "keep-a-changelog" format"
5
5
  Home-page: https://gitlab.com/schmieder.matthias/python-kacl.git
6
6
  Author: Matthias Schmieder
@@ -19,6 +19,17 @@ Requires-Dist: semver
19
19
  Requires-Dist: gitpython
20
20
  Requires-Dist: pyyaml
21
21
  Requires-Dist: jira
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
22
33
 
23
34
  # python-kacl
24
35
 
@@ -1,5 +1,5 @@
1
1
  # Version of the python-kacl package
2
- __version__ = "0.6.1"
2
+ __version__ = "0.6.3"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
@@ -27,6 +27,7 @@ class KACLDocument:
27
27
  headers=None,
28
28
  versions=None,
29
29
  link_references=None,
30
+ meta_data=None,
30
31
  config=KACLConfig(),
31
32
  ):
32
33
  self.__data = data
@@ -35,6 +36,7 @@ class KACLDocument:
35
36
  self.__link_references = link_references
36
37
  if not self.__link_references:
37
38
  self.__link_references = dict()
39
+ self.__meta_data = meta_data
38
40
  self.config = config
39
41
 
40
42
  def validate(self):
@@ -561,6 +563,14 @@ class KACLDocument:
561
563
  """
562
564
  return self.__versions
563
565
 
566
+ def metadata(self):
567
+ """Returns the metadata as dict or None if not available
568
+
569
+ Returns:
570
+ [dict|None] -- metadata of the document
571
+ """
572
+ return self.__meta_data
573
+
564
574
  @staticmethod
565
575
  def init():
566
576
  return KACLDocument.parse(
@@ -591,6 +601,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
591
601
  data_lf
592
602
  )
593
603
 
604
+ meta_data = KACLParser.parse_metadata(data_lf)
605
+
594
606
  changelog_body = data_lf
595
607
  if link_reference_begin:
596
608
  changelog_body = data_lf[:link_reference_begin]
@@ -611,6 +623,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
611
623
  headers=headers,
612
624
  versions=versions,
613
625
  link_references=link_references,
626
+ meta_data=meta_data,
614
627
  )
615
628
 
616
629
  def __get_link_provider(
@@ -652,6 +665,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
652
665
  "ERROR: Could not determine project url. Update your config or run within a valid git repository"
653
666
  )
654
667
 
668
+ host_url = host_url.removesuffix(".git")
669
+
655
670
  return LinkProvider(
656
671
  host_url=host_url,
657
672
  compare_versions_template=compare_versions_template,
@@ -1,5 +1,7 @@
1
1
  import re
2
2
 
3
+ import yaml
4
+
3
5
  from kacl.element import KACLElement
4
6
 
5
7
 
@@ -67,3 +69,12 @@ class KACLParser:
67
69
  m = re.search(regex, text)
68
70
  if m:
69
71
  return m.group().strip()
72
+
73
+ @staticmethod
74
+ def parse_metadata(text):
75
+ meta_data_parts = text.split("---")
76
+
77
+ if not text.startswith("---") or len(meta_data_parts) < 3:
78
+ return None
79
+
80
+ return yaml.safe_load(meta_data_parts[1])
@@ -1,3 +1,5 @@
1
+ import yaml
2
+
1
3
  from kacl.changes import KACLChanges
2
4
  from kacl.document import KACLDocument
3
5
  from kacl.element import KACLElement
@@ -10,10 +12,14 @@ class KACLMarkdownSerializer:
10
12
 
11
13
  def serialize(self, document):
12
14
  if isinstance(document, KACLDocument):
13
- data = [
14
- self.__serialize_header(document.header()),
15
- document.header().body(),
16
- ]
15
+ data = []
16
+
17
+ serialized_metadata = self.__serialize_metadata(document.metadata())
18
+ if serialized_metadata:
19
+ data.extend(serialized_metadata)
20
+
21
+ data.append(self.__serialize_header(document.header()))
22
+ data.append(document.header().body())
17
23
 
18
24
  link_references = []
19
25
  for version in document.versions():
@@ -30,6 +36,17 @@ class KACLMarkdownSerializer:
30
36
  elif isinstance(document, KACLVersion):
31
37
  return self.__serialize_version(document)
32
38
 
39
+ def __serialize_metadata(self, metadata):
40
+ if not metadata:
41
+ return None
42
+
43
+ metadata_lines = ["---"]
44
+ metadata_lines.extend(yaml.dump(metadata).rstrip().split("\n"))
45
+
46
+ metadata_lines.append("---")
47
+
48
+ return metadata_lines
49
+
33
50
  def __serialize_header(self, obj):
34
51
  if isinstance(obj, KACLChanges):
35
52
  return f"### {obj.title()}"
@@ -149,7 +149,7 @@ class KACLVersion(KACLElement):
149
149
  line_number=self.line_number(),
150
150
  start_character_pos=start_pos,
151
151
  end_character_pos=end_pos,
152
- error_message=")Version is not a valid semantic version.",
152
+ error_message="Version is not a valid semantic version.",
153
153
  )
154
154
  )
155
155
  return errors
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.6.1
3
+ Version: 0.6.3
4
4
  Summary: Python module and CLI tool for validating and modifying Changelogs in "keep-a-changelog" format"
5
5
  Home-page: https://gitlab.com/schmieder.matthias/python-kacl.git
6
6
  Author: Matthias Schmieder
@@ -19,6 +19,17 @@ Requires-Dist: semver
19
19
  Requires-Dist: gitpython
20
20
  Requires-Dist: pyyaml
21
21
  Requires-Dist: jira
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
22
33
 
23
34
  # python-kacl
24
35
 
@@ -11,7 +11,7 @@ this_directory = path.abspath(path.dirname(__file__))
11
11
  with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
12
12
  long_description = f.read()
13
13
 
14
- version = "0.6.1"
14
+ version = "0.6.3"
15
15
 
16
16
  version = f"{version}{os.environ.get('PIP_VERSION_POSTFIX', '')}"
17
17
 
@@ -444,3 +444,36 @@ def test_get_issues(tmp_path):
444
444
 
445
445
  issues = changelog.get_associated_issues(version=changelog.current_version())
446
446
  assert len(issues["jira"]) == 5
447
+
448
+
449
+ def test_simple_metadata(tmp_path):
450
+ changelog_file = os.path.join(
451
+ os.path.dirname(os.path.realpath(__file__)),
452
+ "data/CHANGELOG_with_simple_metadata.md",
453
+ )
454
+ changelog = kacl.load(changelog_file)
455
+ assert changelog.is_valid()
456
+
457
+ changelog.release(increment="major")
458
+
459
+ content = kacl.dump(changelog)
460
+
461
+ assert "---\ntitle: CHANGELOG\n---\n" in str(content)
462
+
463
+
464
+ def test_complex_metadata(tmp_path):
465
+ changelog_file = os.path.join(
466
+ os.path.dirname(os.path.realpath(__file__)),
467
+ "data/CHANGELOG_with_complex_metadata.md",
468
+ )
469
+ changelog = kacl.load(changelog_file)
470
+ assert changelog.is_valid()
471
+
472
+ changelog.release(increment="major")
473
+
474
+ content = kacl.dump(changelog)
475
+
476
+ assert (
477
+ "---\nlist:\n- entry1\n- additional: true\n key: value\ntitle: CHANGELOG\n---\n"
478
+ in str(content)
479
+ )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes