python-kacl 0.6.3__tar.gz → 0.6.5__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 (34) hide show
  1. {python_kacl-0.6.3/python_kacl.egg-info → python_kacl-0.6.5}/PKG-INFO +1 -1
  2. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/__init__.py +1 -1
  3. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/kacl_cli.py +8 -1
  4. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/serializer.py +19 -11
  5. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/version.py +2 -2
  6. {python_kacl-0.6.3 → python_kacl-0.6.5/python_kacl.egg-info}/PKG-INFO +1 -1
  7. {python_kacl-0.6.3 → python_kacl-0.6.5}/python_kacl.egg-info/SOURCES.txt +0 -2
  8. {python_kacl-0.6.3 → python_kacl-0.6.5}/python_kacl.egg-info/entry_points.txt +1 -0
  9. python_kacl-0.6.5/python_kacl.egg-info/top_level.txt +1 -0
  10. {python_kacl-0.6.3 → python_kacl-0.6.5}/setup.py +8 -3
  11. {python_kacl-0.6.3 → python_kacl-0.6.5}/tests/test_cli.py +74 -0
  12. {python_kacl-0.6.3 → python_kacl-0.6.5}/tests/test_kacl.py +17 -8
  13. python_kacl-0.6.3/python_kacl.egg-info/top_level.txt +0 -2
  14. python_kacl-0.6.3/tests/__init__.py +0 -1
  15. python_kacl-0.6.3/tests/snapshot_directory.py +0 -42
  16. {python_kacl-0.6.3 → python_kacl-0.6.5}/LICENSE +0 -0
  17. {python_kacl-0.6.3 → python_kacl-0.6.5}/MANIFEST.in +0 -0
  18. {python_kacl-0.6.3 → python_kacl-0.6.5}/README.md +0 -0
  19. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/__main__.py +0 -0
  20. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/changes.py +0 -0
  21. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/config/kacl-default.yml +0 -0
  22. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/config.py +0 -0
  23. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/document.py +0 -0
  24. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/element.py +0 -0
  25. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/exception.py +0 -0
  26. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/jira_client.py +0 -0
  27. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/link_provider.py +0 -0
  28. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/parser.py +0 -0
  29. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/utils.py +0 -0
  30. {python_kacl-0.6.3 → python_kacl-0.6.5}/kacl/validation.py +0 -0
  31. {python_kacl-0.6.3 → python_kacl-0.6.5}/python_kacl.egg-info/dependency_links.txt +0 -0
  32. {python_kacl-0.6.3 → python_kacl-0.6.5}/python_kacl.egg-info/not-zip-safe +0 -0
  33. {python_kacl-0.6.3 → python_kacl-0.6.5}/python_kacl.egg-info/requires.txt +0 -0
  34. {python_kacl-0.6.3 → python_kacl-0.6.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.6.3
3
+ Version: 0.6.5
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.3"
2
+ __version__ = "0.6.5"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
@@ -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,30 +11,37 @@ 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)
20
20
 
21
21
  data.append(self.__serialize_header(document.header()))
22
- data.append(document.header().body())
22
+ # check if the body starts with a newline. if not add one
23
+ if document.header().body().startswith("\n"):
24
+ data.append(document.header().body())
25
+ else:
26
+ data.append("\n" + document.header().body())
23
27
 
24
- link_references = []
25
28
  for version in document.versions():
26
29
  data.extend([self.__serialize_version(version), ""])
27
30
  if version.has_link_reference():
28
31
  link_references.append(self.__serialize_link_reference(version))
29
32
 
30
- data.extend(link_references)
33
+ elif isinstance(document, KACLVersion):
34
+ data.extend([self.__serialize_version(document), ""])
31
35
 
32
- if data[-1] != "":
33
- data.append("")
36
+ if document.has_link_reference():
37
+ link_references.append(self.__serialize_link_reference(document))
34
38
 
35
- return "\n".join(data)
36
- elif isinstance(document, KACLVersion):
37
- return self.__serialize_version(document)
39
+ data.extend(link_references)
40
+
41
+ if data[-1] != "":
42
+ data.append("")
43
+
44
+ return "\n".join(data)
38
45
 
39
46
  def __serialize_metadata(self, metadata):
40
47
  if not metadata:
@@ -64,11 +71,12 @@ class KACLMarkdownSerializer:
64
71
  return f"# {obj.title()}"
65
72
 
66
73
  def __serialize_version(self, obj):
67
- lines = [self.__serialize_header(obj)]
74
+ lines = [self.__serialize_header(obj), ""]
68
75
  for title, changes in obj.sections().items():
69
76
  lines.extend(
70
77
  [
71
78
  self.__serialize_header(changes),
79
+ "",
72
80
  self.__serialize_list(changes.items()),
73
81
  "",
74
82
  ]
@@ -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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.6.3
3
+ Version: 0.6.5
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
@@ -25,7 +25,5 @@ python_kacl.egg-info/entry_points.txt
25
25
  python_kacl.egg-info/not-zip-safe
26
26
  python_kacl.egg-info/requires.txt
27
27
  python_kacl.egg-info/top_level.txt
28
- tests/__init__.py
29
- tests/snapshot_directory.py
30
28
  tests/test_cli.py
31
29
  tests/test_kacl.py
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
+ kacl = kacl.kacl_cli:start
2
3
  kacl-cli = kacl.kacl_cli:start
@@ -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.3"
14
+ version = "0.6.5"
15
15
 
16
16
  version = f"{version}{os.environ.get('PIP_VERSION_POSTFIX', '')}"
17
17
 
@@ -33,9 +33,14 @@ setup(
33
33
  url="https://gitlab.com/schmieder.matthias/python-kacl.git",
34
34
  author="Matthias Schmieder",
35
35
  author_email="schmieder.matthias@gmail.com",
36
- entry_points={"console_scripts": ["kacl-cli = kacl.kacl_cli:start"]},
36
+ entry_points={
37
+ "console_scripts": [
38
+ "kacl-cli = kacl.kacl_cli:start",
39
+ "kacl = kacl.kacl_cli:start",
40
+ ]
41
+ },
37
42
  license="MIT",
38
- packages=find_packages(),
43
+ packages=find_packages(exclude=["tests", "tests.*"]),
39
44
  include_package_data=True,
40
45
  python_requires=">=3.9",
41
46
  install_requires=requirements,
@@ -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)
@@ -45,6 +45,15 @@ class TestKacl(TestCase):
45
45
  changelog_reference_lines = changelog_reference.split("\n")
46
46
 
47
47
  self.assertEqual(len(changelog_dump_lines), len(changelog_reference_lines))
48
+
49
+ for i in range(len(changelog_dump_lines)):
50
+ if changelog_dump_lines[i] != changelog_reference_lines[i]:
51
+ print(
52
+ f"Line {i + 1} differs:\n"
53
+ f"Dump: {changelog_dump_lines[i]}\n"
54
+ f"Reference: {changelog_reference_lines[i]}"
55
+ )
56
+
48
57
  self.assertEqual(changelog_dump, changelog_reference)
49
58
 
50
59
  def test_add_change(self):
@@ -231,8 +240,8 @@ class TestKacl(TestCase):
231
240
  def test_release_with_increment(self):
232
241
  tests = {
233
242
  "major": "2.0.0",
234
- "minor": "1.1.0",
235
- "patch": "1.0.1",
243
+ "minor": "1.2.0",
244
+ "patch": "1.1.2",
236
245
  }
237
246
  changelog_file = os.path.join(
238
247
  os.path.dirname(os.path.realpath(__file__)), "data/CHANGELOG.md"
@@ -263,9 +272,9 @@ class TestKacl(TestCase):
263
272
  def test_release_with_increment_extension(self):
264
273
  tests = {
265
274
  "major": "2.0.0",
266
- "minor": "1.1.0",
267
- "patch": "1.0.1",
268
- "post": "1.0.0-post.1",
275
+ "minor": "1.2.0",
276
+ "patch": "1.1.2",
277
+ "post": "1.1.1-post.1",
269
278
  }
270
279
  changelog_file = os.path.join(
271
280
  os.path.dirname(os.path.realpath(__file__)), "data/CHANGELOG.md"
@@ -285,9 +294,9 @@ class TestKacl(TestCase):
285
294
  def test_release_with_increment_extension_hotfix(self):
286
295
  tests = {
287
296
  "major": "2.0.0",
288
- "minor": "1.1.0",
289
- "patch": "1.0.1",
290
- "post": "1.0.0-hotfix.1",
297
+ "minor": "1.2.0",
298
+ "patch": "1.1.2",
299
+ "post": "1.1.1-hotfix.1",
291
300
  }
292
301
  changelog_file = os.path.join(
293
302
  os.path.dirname(os.path.realpath(__file__)), "data/CHANGELOG.md"
@@ -1,2 +0,0 @@
1
- kacl
2
- tests
@@ -1 +0,0 @@
1
- __version__ = "0.4.51"
@@ -1,42 +0,0 @@
1
- import os
2
- from pathlib import Path
3
-
4
-
5
- def snapshot_directory(
6
- snapshot,
7
- directory_path,
8
- dir_excludes=[".git"],
9
- file_excludes=[],
10
- sanitize_callbacks={},
11
- ):
12
- snapshot_dir = {}
13
-
14
- for root, dirs, files in os.walk(directory_path, topdown=True):
15
- dirs[:] = [d for d in dirs if d not in dir_excludes]
16
-
17
- for file in files:
18
- if file in file_excludes:
19
- continue
20
- current = snapshot_dir
21
- parts = Path(root).relative_to(directory_path).parts
22
- for part in parts:
23
- current = current.setdefault(part, {})
24
-
25
- file_path = os.path.join(root, f"{file}")
26
- if __is_binary(file_path):
27
- content = open(file_path, "rb").read()
28
- else:
29
- content = open(file_path, "r").read()
30
-
31
- if file in sanitize_callbacks:
32
- callback = sanitize_callbacks[file]
33
- content = callback(content)
34
-
35
- current[f"{file}.snap"] = content
36
-
37
- snapshot.assert_match_dir(snapshot_dir, "snapshots")
38
-
39
-
40
- def __is_binary(file_path):
41
- textchars = bytearray({7, 8, 9, 10, 12, 13, 27} | set(range(0x20, 0x100)) - {0x7F})
42
- return bool(open(file_path, "rb").read(1024).translate(None, textchars))
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