python-kacl 0.6.0__tar.gz → 0.6.2__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.0/python_kacl.egg-info → python_kacl-0.6.2}/PKG-INFO +1 -1
  2. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/__init__.py +1 -1
  3. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/document.py +13 -0
  4. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/parser.py +11 -0
  5. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/serializer.py +21 -4
  6. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/utils.py +17 -0
  7. {python_kacl-0.6.0 → python_kacl-0.6.2/python_kacl.egg-info}/PKG-INFO +1 -1
  8. {python_kacl-0.6.0 → python_kacl-0.6.2}/setup.py +1 -1
  9. {python_kacl-0.6.0 → python_kacl-0.6.2}/tests/test_kacl.py +33 -0
  10. {python_kacl-0.6.0 → python_kacl-0.6.2}/LICENSE +0 -0
  11. {python_kacl-0.6.0 → python_kacl-0.6.2}/MANIFEST.in +0 -0
  12. {python_kacl-0.6.0 → python_kacl-0.6.2}/README.md +0 -0
  13. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/__main__.py +0 -0
  14. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/changes.py +0 -0
  15. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/config/kacl-default.yml +0 -0
  16. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/config.py +0 -0
  17. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/element.py +0 -0
  18. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/exception.py +0 -0
  19. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/jira_client.py +0 -0
  20. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/kacl_cli.py +0 -0
  21. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/link_provider.py +0 -0
  22. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/validation.py +0 -0
  23. {python_kacl-0.6.0 → python_kacl-0.6.2}/kacl/version.py +0 -0
  24. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/SOURCES.txt +0 -0
  25. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/dependency_links.txt +0 -0
  26. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/entry_points.txt +0 -0
  27. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/not-zip-safe +0 -0
  28. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/requires.txt +0 -0
  29. {python_kacl-0.6.0 → python_kacl-0.6.2}/python_kacl.egg-info/top_level.txt +0 -0
  30. {python_kacl-0.6.0 → python_kacl-0.6.2}/setup.cfg +0 -0
  31. {python_kacl-0.6.0 → python_kacl-0.6.2}/tests/__init__.py +0 -0
  32. {python_kacl-0.6.0 → python_kacl-0.6.2}/tests/snapshot_directory.py +0 -0
  33. {python_kacl-0.6.0 → python_kacl-0.6.2}/tests/test_cli.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-kacl
3
- Version: 0.6.0
3
+ Version: 0.6.2
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
@@ -1,5 +1,5 @@
1
1
  # Version of the python-kacl package
2
- __version__ = "0.6.0"
2
+ __version__ = "0.6.2"
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(
@@ -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()}"
@@ -64,8 +64,25 @@ def convert_markdown_to_jira(markdown_text):
64
64
  url = match.group(2)
65
65
  return f"[{link_text}|{url}]"
66
66
 
67
+ # Convert markdown inline code to JIRA inline code
68
+ def replace_inline_code(match):
69
+ code_text = match.group(1)
70
+ return "{{" + code_text + "}}"
71
+
72
+ # Convert markdown bold text to JIRA bold text
73
+ def replace_bold_text(match):
74
+ bold_text = match.group(1)
75
+ return f"*{bold_text}*"
76
+
67
77
  converted_text = re.sub(
68
78
  r"^(#{1,6})\s+(.*)", replace_heading, markdown_text, flags=re.MULTILINE
69
79
  )
70
80
  converted_text = re.sub(r"\[(.*?)\]\((.*?)\)", replace_link, converted_text)
81
+
82
+ # Apply the inline code conversion
83
+ converted_text = re.sub(r"`(.*?)`", replace_inline_code, converted_text)
84
+
85
+ # Apply the bold text conversion
86
+ converted_text = re.sub(r"\*\*(.*?)\*\*", replace_bold_text, converted_text)
87
+
71
88
  return converted_text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-kacl
3
- Version: 0.6.0
3
+ Version: 0.6.2
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
@@ -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.0"
14
+ version = "0.6.2"
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