python-kacl 0.6.2__tar.gz → 0.6.4__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.2/python_kacl.egg-info → python_kacl-0.6.4}/PKG-INFO +13 -2
  2. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/__init__.py +1 -1
  3. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/document.py +2 -0
  4. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/kacl_cli.py +8 -1
  5. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/serializer.py +12 -9
  6. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/version.py +3 -3
  7. {python_kacl-0.6.2 → python_kacl-0.6.4/python_kacl.egg-info}/PKG-INFO +13 -2
  8. {python_kacl-0.6.2 → python_kacl-0.6.4}/setup.py +1 -1
  9. {python_kacl-0.6.2 → python_kacl-0.6.4}/tests/test_cli.py +74 -0
  10. {python_kacl-0.6.2 → python_kacl-0.6.4}/LICENSE +0 -0
  11. {python_kacl-0.6.2 → python_kacl-0.6.4}/MANIFEST.in +0 -0
  12. {python_kacl-0.6.2 → python_kacl-0.6.4}/README.md +0 -0
  13. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/__main__.py +0 -0
  14. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/changes.py +0 -0
  15. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/config/kacl-default.yml +0 -0
  16. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/config.py +0 -0
  17. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/element.py +0 -0
  18. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/exception.py +0 -0
  19. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/jira_client.py +0 -0
  20. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/link_provider.py +0 -0
  21. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/parser.py +0 -0
  22. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/utils.py +0 -0
  23. {python_kacl-0.6.2 → python_kacl-0.6.4}/kacl/validation.py +0 -0
  24. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/SOURCES.txt +0 -0
  25. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/dependency_links.txt +0 -0
  26. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/entry_points.txt +0 -0
  27. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/not-zip-safe +0 -0
  28. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/requires.txt +0 -0
  29. {python_kacl-0.6.2 → python_kacl-0.6.4}/python_kacl.egg-info/top_level.txt +0 -0
  30. {python_kacl-0.6.2 → python_kacl-0.6.4}/setup.cfg +0 -0
  31. {python_kacl-0.6.2 → python_kacl-0.6.4}/tests/__init__.py +0 -0
  32. {python_kacl-0.6.2 → python_kacl-0.6.4}/tests/snapshot_directory.py +0 -0
  33. {python_kacl-0.6.2 → python_kacl-0.6.4}/tests/test_kacl.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.2
3
+ Version: 0.6.4
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.2"
2
+ __version__ = "0.6.4"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
@@ -665,6 +665,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
665
665
  "ERROR: Could not determine project url. Update your config or run within a valid git repository"
666
666
  )
667
667
 
668
+ host_url = host_url.removesuffix(".git")
669
+
668
670
  return LinkProvider(
669
671
  host_url=host_url,
670
672
  compare_versions_template=compare_versions_template,
@@ -177,7 +177,12 @@ def next(ctx, version):
177
177
  @cli.command()
178
178
  @click.pass_context
179
179
  @click.argument("version", type=str)
180
- def get(ctx, version):
180
+ @click.option(
181
+ "--no-link",
182
+ is_flag=True,
183
+ help="This option suppresses a link, even if available.",
184
+ )
185
+ def get(ctx, version, no_link):
181
186
  """Returns a given version from the Changelog."""
182
187
  kacl_changelog = load_changelog(ctx)
183
188
 
@@ -185,6 +190,8 @@ def get(ctx, version):
185
190
  kacl_version = kacl_changelog.get(version)
186
191
 
187
192
  if kacl_version:
193
+ if no_link:
194
+ kacl_version.set_link(None)
188
195
  kacl_changelog_content = kacl.dump(kacl_version)
189
196
  click.echo(kacl_changelog_content)
190
197
  else:
@@ -11,9 +11,9 @@ class KACLMarkdownSerializer:
11
11
  pass
12
12
 
13
13
  def serialize(self, document):
14
+ data = []
15
+ link_references = []
14
16
  if isinstance(document, KACLDocument):
15
- data = []
16
-
17
17
  serialized_metadata = self.__serialize_metadata(document.metadata())
18
18
  if serialized_metadata:
19
19
  data.extend(serialized_metadata)
@@ -21,20 +21,23 @@ class KACLMarkdownSerializer:
21
21
  data.append(self.__serialize_header(document.header()))
22
22
  data.append(document.header().body())
23
23
 
24
- link_references = []
25
24
  for version in document.versions():
26
25
  data.extend([self.__serialize_version(version), ""])
27
26
  if version.has_link_reference():
28
27
  link_references.append(self.__serialize_link_reference(version))
29
28
 
30
- data.extend(link_references)
29
+ elif isinstance(document, KACLVersion):
30
+ data.extend([self.__serialize_version(document), ""])
31
31
 
32
- if data[-1] != "":
33
- data.append("")
32
+ if document.has_link_reference():
33
+ link_references.append(self.__serialize_link_reference(document))
34
34
 
35
- return "\n".join(data)
36
- elif isinstance(document, KACLVersion):
37
- return self.__serialize_version(document)
35
+ data.extend(link_references)
36
+
37
+ if data[-1] != "":
38
+ data.append("")
39
+
40
+ return "\n".join(data)
38
41
 
39
42
  def __serialize_metadata(self, metadata):
40
43
  if not metadata:
@@ -47,9 +47,9 @@ class KACLVersion(KACLElement):
47
47
  return self.__link_reference.body()
48
48
 
49
49
  def set_link(self, link):
50
- if isinstance(link, KACLElement):
50
+ if not link or isinstance(link, KACLElement):
51
51
  self.__link_reference = link
52
- elif link is not None:
52
+ else:
53
53
  self.__link_reference = KACLElement(title=self.version(), body=link)
54
54
 
55
55
  def has_link_reference(self):
@@ -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.2
3
+ Version: 0.6.4
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.2"
14
+ version = "0.6.4"
15
15
 
16
16
  version = f"{version}{os.environ.get('PIP_VERSION_POSTFIX', '')}"
17
17
 
@@ -416,3 +416,77 @@ def test_add_comments(tmp_path):
416
416
  catch_exceptions=False,
417
417
  )
418
418
  assert result.exit_code == 0, result.output
419
+
420
+
421
+ @freeze_time("2023-01-01")
422
+ def test_get_no_link_available(tmp_path, snapshot):
423
+ runner = CliRunner()
424
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
425
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
426
+
427
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
428
+ result = runner.invoke(
429
+ cli,
430
+ [
431
+ "-c",
432
+ os.path.join(resources_dir, "extension-config.yml"),
433
+ "-f",
434
+ changelog_file,
435
+ "get",
436
+ "2.0.0",
437
+ ],
438
+ catch_exceptions=False,
439
+ )
440
+ assert result.exit_code == 0, result.output
441
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
442
+ file.write(result.output)
443
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)
444
+
445
+
446
+ def test_get_link_available(tmp_path, snapshot):
447
+ runner = CliRunner()
448
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
449
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
450
+
451
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
452
+ result = runner.invoke(
453
+ cli,
454
+ [
455
+ "-c",
456
+ os.path.join(resources_dir, "extension-config.yml"),
457
+ "-f",
458
+ changelog_file,
459
+ "get",
460
+ "1.0.0",
461
+ ],
462
+ catch_exceptions=False,
463
+ )
464
+ assert result.exit_code == 0, result.output
465
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
466
+ file.write(result.output)
467
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)
468
+
469
+
470
+ def test_get_suppress_available_link(tmp_path, snapshot):
471
+ runner = CliRunner()
472
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
473
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
474
+
475
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
476
+ result = runner.invoke(
477
+ cli,
478
+ [
479
+ "-c",
480
+ os.path.join(resources_dir, "extension-config.yml"),
481
+ "-f",
482
+ changelog_file,
483
+ "get",
484
+ "--no-link",
485
+ "1.0.0",
486
+ ],
487
+ catch_exceptions=False,
488
+ )
489
+ assert result.exit_code == 0, result.output
490
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
491
+ file.write(result.output)
492
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes