markdown-to-confluence 0.2.4__py3-none-any.whl → 0.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-to-confluence
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Publish Markdown files to Confluence wiki
5
5
  Home-page: https://github.com/hunyadi/md2conf
6
6
  Author: Levente Hunyadi
@@ -0,0 +1,21 @@
1
+ md2conf/__init__.py,sha256=0eak9lvskuCqGJnGeno6SHoCiBFAX5IQLHVBx1LV0w8,402
2
+ md2conf/__main__.py,sha256=6iOI28W_d71tlnCMFpZwvkBmBt5-HazlZsz69gS4Oak,6894
3
+ md2conf/api.py,sha256=EZSHbuH5O9fPyW7iLAX0Fqw8njXmvd6sEbgseP-eUUc,16498
4
+ md2conf/application.py,sha256=hmfLiofGulN8zUw2uXuueohCkDh978sqLkoUot928qM,8796
5
+ md2conf/converter.py,sha256=8X8tNELqwAaZYSVvczJl_ZpJL9tu2ImCBXaQBQvGgeM,34413
6
+ md2conf/emoji.py,sha256=w9oiOIxzObAE7HTo3f6aETT1_D3t3yZwr88ynU4ENm0,1924
7
+ md2conf/entities.dtd,sha256=M6NzqL5N7dPs_eUA_6sDsiSLzDaAacrx9LdttiufvYU,30215
8
+ md2conf/matcher.py,sha256=mYMltZOLypK4O-SJugLgicOwUMem67hiNLg_kPFoJkU,3583
9
+ md2conf/mermaid.py,sha256=Tsibd1aOn4hRYv6emQg0hrZMPTkflIeXHVbZ7nQ5lSc,2108
10
+ md2conf/processor.py,sha256=tUt5D4_D3uhofg2Bn23owBJmkVHj4tSll0zI95J6cdk,4243
11
+ md2conf/properties.py,sha256=iVIc0h0XtS3Y2LCywX1C9cvmVQ0WljOMt8pl2MDMVCI,1990
12
+ md2conf/puppeteer-config.json,sha256=-dMTAN_7kNTGbDlfXzApl0KJpAWna9YKZdwMKbpOb60,159
13
+ md2conf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ md2conf/util.py,sha256=ftf60MiW7S7rW45ipWX6efP_Sv2F2qpyIDHrGA0cBiw,743
15
+ markdown_to_confluence-0.2.5.dist-info/LICENSE,sha256=Pv43so2bPfmKhmsrmXFyAvS7M30-1i1tzjz6-dfhyOo,1077
16
+ markdown_to_confluence-0.2.5.dist-info/METADATA,sha256=E7j_aFJ7rT4SOpoUIa40G2QJL_7PjuXBA5JvdANRIdc,12764
17
+ markdown_to_confluence-0.2.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
18
+ markdown_to_confluence-0.2.5.dist-info/entry_points.txt,sha256=F1zxa1wtEObtbHS-qp46330WVFLHdMnV2wQ-ZorRmX0,50
19
+ markdown_to_confluence-0.2.5.dist-info/top_level.txt,sha256=_FJfl_kHrHNidyjUOuS01ngu_jDsfc-ZjSocNRJnTzU,8
20
+ markdown_to_confluence-0.2.5.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
21
+ markdown_to_confluence-0.2.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
md2conf/__init__.py CHANGED
@@ -5,7 +5,7 @@ Parses Markdown files, converts Markdown content into the Confluence Storage For
5
5
  Confluence API endpoints to upload images and content.
6
6
  """
7
7
 
8
- __version__ = "0.2.4"
8
+ __version__ = "0.2.5"
9
9
  __author__ = "Levente Hunyadi"
10
10
  __copyright__ = "Copyright 2022-2024, Levente Hunyadi"
11
11
  __license__ = "MIT"
md2conf/__main__.py CHANGED
@@ -1,3 +1,14 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Parses Markdown files, converts Markdown content into the Confluence Storage Format (XHTML), and invokes
5
+ Confluence API endpoints to upload images and content.
6
+
7
+ Copyright 2022-2024, Levente Hunyadi
8
+
9
+ :see: https://github.com/hunyadi/md2conf
10
+ """
11
+
1
12
  import argparse
2
13
  import logging
3
14
  import os.path
md2conf/api.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import io
2
10
  import json
3
11
  import logging
@@ -491,7 +499,7 @@ class ConfluenceSession:
491
499
  page_id = self.page_exists(title)
492
500
 
493
501
  if page_id is not None:
494
- LOGGER.debug("Retrieving existing page: %d", page_id)
502
+ LOGGER.debug("Retrieving existing page: %s", page_id)
495
503
  return self.get_page(page_id)
496
504
  else:
497
505
  LOGGER.debug("Creating new page with title: %s", title)
md2conf/application.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import logging
2
10
  import os.path
3
11
  from pathlib import Path
@@ -36,6 +44,7 @@ class Application:
36
44
  def synchronize(self, path: Path) -> None:
37
45
  "Synchronizes a single Markdown page or a directory of Markdown pages."
38
46
 
47
+ path = path.resolve(True)
39
48
  if path.is_dir():
40
49
  self.synchronize_directory(path)
41
50
  elif path.is_file():
@@ -46,12 +55,14 @@ class Application:
46
55
  def synchronize_page(self, page_path: Path) -> None:
47
56
  "Synchronizes a single Markdown page with Confluence."
48
57
 
58
+ page_path = page_path.resolve(True)
49
59
  self._synchronize_page(page_path, {})
50
60
 
51
61
  def synchronize_directory(self, local_dir: Path) -> None:
52
62
  "Synchronizes a directory of Markdown pages with Confluence."
53
63
 
54
- LOGGER.info(f"Synchronizing directory: {local_dir}")
64
+ LOGGER.info("Synchronizing directory: %s", local_dir)
65
+ local_dir = local_dir.resolve(True)
55
66
 
56
67
  # Step 1: build index of all page metadata
57
68
  page_metadata: Dict[Path, ConfluencePageMetadata] = {}
@@ -61,7 +72,7 @@ class Application:
61
72
  else None
62
73
  )
63
74
  self._index_directory(local_dir, root_id, page_metadata)
64
- LOGGER.info(f"indexed {len(page_metadata)} page(s)")
75
+ LOGGER.info("Indexed %d page(s)", len(page_metadata))
65
76
 
66
77
  # Step 2: convert each page
67
78
  for page_path in page_metadata.keys():
@@ -74,7 +85,7 @@ class Application:
74
85
  ) -> None:
75
86
  base_path = page_path.parent
76
87
 
77
- LOGGER.info(f"Synchronizing page: {page_path}")
88
+ LOGGER.info("Synchronizing page: %s", page_path)
78
89
  document = ConfluenceDocument(page_path, self.options, page_metadata)
79
90
 
80
91
  if document.id.space_key:
@@ -91,7 +102,7 @@ class Application:
91
102
  ) -> None:
92
103
  "Indexes Markdown files in a directory recursively."
93
104
 
94
- LOGGER.info(f"Indexing directory: {local_dir}")
105
+ LOGGER.info("Indexing directory: %s", local_dir)
95
106
 
96
107
  matcher = Matcher(MatcherOptions(source=".mdignore", extension="md"), local_dir)
97
108
 
@@ -107,22 +118,30 @@ class Application:
107
118
  directories.append(Path(local_dir) / entry.name)
108
119
 
109
120
  # make page act as parent node in Confluence
110
- parent_id: Optional[ConfluenceQualifiedID] = None
121
+ parent_doc: Optional[Path] = None
111
122
  if (Path(local_dir) / "index.md") in files:
112
- parent_id = read_qualified_id(Path(local_dir) / "index.md")
123
+ parent_doc = Path(local_dir) / "index.md"
113
124
  elif (Path(local_dir) / "README.md") in files:
114
- parent_id = read_qualified_id(Path(local_dir) / "README.md")
125
+ parent_doc = Path(local_dir) / "README.md"
115
126
 
116
- if parent_id is None:
127
+ if parent_doc is not None:
128
+ files.remove(parent_doc)
129
+
130
+ metadata = self._get_or_create_page(parent_doc, root_id)
131
+ LOGGER.debug("Indexed parent %s with metadata: %s", parent_doc, metadata)
132
+ page_metadata[parent_doc] = metadata
133
+
134
+ parent_id = read_qualified_id(parent_doc) or root_id
135
+ else:
117
136
  parent_id = root_id
118
137
 
119
138
  for doc in files:
120
139
  metadata = self._get_or_create_page(doc, parent_id)
121
- LOGGER.debug(f"indexed {doc} with metadata: {metadata}")
140
+ LOGGER.debug("Indexed %s with metadata: %s", doc, metadata)
122
141
  page_metadata[doc] = metadata
123
142
 
124
143
  for directory in directories:
125
- self._index_directory(Path(local_dir) / directory, parent_id, page_metadata)
144
+ self._index_directory(directory, parent_id, page_metadata)
126
145
 
127
146
  def _get_or_create_page(
128
147
  self,
@@ -215,7 +234,7 @@ class Application:
215
234
  )
216
235
 
217
236
  content = document.xhtml()
218
- LOGGER.debug(f"generated Confluence Storage Format document:\n{content}")
237
+ LOGGER.debug("Generated Confluence Storage Format document:\n%s", content)
219
238
  self.api.update_page(document.id.page_id, content)
220
239
 
221
240
  def _update_markdown(
md2conf/converter.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  # mypy: disable-error-code="dict-item"
2
10
 
3
11
  import hashlib
@@ -343,7 +351,7 @@ class ConfluenceStorageFormatConverter(NodeVisitor):
343
351
  if is_absolute_url(url):
344
352
  return None
345
353
 
346
- LOGGER.debug(f"found link {url} relative to {self.path}")
354
+ LOGGER.debug("Found link %s relative to %s", url, self.path)
347
355
  relative_url: ParseResult = urlparse(url)
348
356
 
349
357
  if (
@@ -353,7 +361,7 @@ class ConfluenceStorageFormatConverter(NodeVisitor):
353
361
  and not relative_url.params
354
362
  and not relative_url.query
355
363
  ):
356
- LOGGER.debug(f"found local URL: {url}")
364
+ LOGGER.debug("Found local URL: %s", url)
357
365
  if self.options.heading_anchors:
358
366
  # <ac:link ac:anchor="anchor"><ac:link-body>...</ac:link-body></ac:link>
359
367
  target = relative_url.fragment.lstrip("#")
@@ -398,7 +406,7 @@ class ConfluenceStorageFormatConverter(NodeVisitor):
398
406
  raise DocumentError(msg)
399
407
 
400
408
  LOGGER.debug(
401
- f"found link to page {relative_path} with metadata: {link_metadata}"
409
+ "found link to page %s with metadata: %s", relative_path, link_metadata
402
410
  )
403
411
  self.links.append(url)
404
412
 
@@ -417,7 +425,7 @@ class ConfluenceStorageFormatConverter(NodeVisitor):
417
425
  )
418
426
  transformed_url = urlunparse(components)
419
427
 
420
- LOGGER.debug(f"transformed relative URL: {url} to URL: {transformed_url}")
428
+ LOGGER.debug("Transformed relative URL: %s to URL: %s", url, transformed_url)
421
429
  anchor.attrib["href"] = transformed_url
422
430
  return None
423
431
 
md2conf/emoji.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import pathlib
2
10
 
3
11
  import pymdownx.emoji1_db as emoji_db
md2conf/matcher.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import os.path
2
10
  from dataclasses import dataclass
3
11
  from fnmatch import fnmatch
md2conf/mermaid.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import logging
2
10
  import os
3
11
  import os.path
@@ -52,7 +60,7 @@ def render(source: str, output_format: Literal["png", "svg"] = "png") -> bytes:
52
60
  root = os.path.dirname(__file__)
53
61
  if is_docker():
54
62
  cmd.extend(["-p", os.path.join(root, "puppeteer-config.json")])
55
- LOGGER.debug(f"Executing: {' '.join(cmd)}")
63
+ LOGGER.debug("Executing: %s", " ".join(cmd))
56
64
  try:
57
65
  proc = subprocess.Popen(
58
66
  cmd,
md2conf/processor.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import hashlib
2
10
  import logging
3
11
  import os
@@ -30,6 +38,7 @@ class Processor:
30
38
  def process(self, path: Path) -> None:
31
39
  "Processes a single Markdown file or a directory of Markdown files."
32
40
 
41
+ path = path.resolve(True)
33
42
  if path.is_dir():
34
43
  self.process_directory(path)
35
44
  elif path.is_file():
@@ -40,12 +49,13 @@ class Processor:
40
49
  def process_directory(self, local_dir: Path) -> None:
41
50
  "Recursively scans a directory hierarchy for Markdown files."
42
51
 
43
- LOGGER.info(f"Synchronizing directory: {local_dir}")
52
+ LOGGER.info("Synchronizing directory: %s", local_dir)
53
+ local_dir = local_dir.resolve(True)
44
54
 
45
55
  # Step 1: build index of all page metadata
46
56
  page_metadata: Dict[Path, ConfluencePageMetadata] = {}
47
57
  self._index_directory(local_dir, page_metadata)
48
- LOGGER.info(f"indexed {len(page_metadata)} page(s)")
58
+ LOGGER.info("Indexed %d page(s)", len(page_metadata))
49
59
 
50
60
  # Step 2: convert each page
51
61
  for page_path in page_metadata.keys():
@@ -56,6 +66,7 @@ class Processor:
56
66
  ) -> None:
57
67
  "Processes a single Markdown file."
58
68
 
69
+ path = path.resolve(True)
59
70
  document = ConfluenceDocument(path, self.options, page_metadata)
60
71
  content = document.xhtml()
61
72
  with open(path.with_suffix(".csf"), "w", encoding="utf-8") as f:
@@ -68,7 +79,7 @@ class Processor:
68
79
  ) -> None:
69
80
  "Indexes Markdown files in a directory recursively."
70
81
 
71
- LOGGER.info(f"Indexing directory: {local_dir}")
82
+ LOGGER.info("Indexing directory: %s", local_dir)
72
83
 
73
84
  matcher = Matcher(MatcherOptions(source=".mdignore", extension="md"), local_dir)
74
85
 
@@ -85,11 +96,11 @@ class Processor:
85
96
 
86
97
  for doc in files:
87
98
  metadata = self._get_page(doc)
88
- LOGGER.debug(f"indexed {doc} with metadata: {metadata}")
99
+ LOGGER.debug("Indexed %s with metadata: %s", doc, metadata)
89
100
  page_metadata[doc] = metadata
90
101
 
91
102
  for directory in directories:
92
- self._index_directory(Path(local_dir) / directory, page_metadata)
103
+ self._index_directory(directory, page_metadata)
93
104
 
94
105
  def _get_page(self, absolute_path: Path) -> ConfluencePageMetadata:
95
106
  "Extracts metadata from a Markdown file."
@@ -102,7 +113,7 @@ class Processor:
102
113
  if self.options.root_page_id is not None:
103
114
  hash = hashlib.md5(document.encode("utf-8"))
104
115
  digest = "".join(f"{c:x}" for c in hash.digest())
105
- LOGGER.info(f"Identifier '{digest}' assigned to page: {absolute_path}")
116
+ LOGGER.info("Identifier %s assigned to page: %s", digest, absolute_path)
106
117
  qualified_id = ConfluenceQualifiedID(digest)
107
118
  else:
108
119
  raise ValueError("required: page ID for local output")
md2conf/properties.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import os
2
10
  from typing import Dict, Optional
3
11
 
md2conf/util.py CHANGED
@@ -1,3 +1,11 @@
1
+ """
2
+ Publish Markdown files to Confluence wiki.
3
+
4
+ Copyright 2022-2024, Levente Hunyadi
5
+
6
+ :see: https://github.com/hunyadi/md2conf
7
+ """
8
+
1
9
  import sys
2
10
 
3
11
  if sys.version_info >= (3, 9):
@@ -1,21 +0,0 @@
1
- md2conf/__init__.py,sha256=zCKYQvETObXjgxGYFlwiftPJL64cqwfEW3PGriejyh4,402
2
- md2conf/__main__.py,sha256=_qUspNQmQdhpH4Myh9vXDcauPyUx_FyEzNtaW_c8ytY,6601
3
- md2conf/api.py,sha256=bP3Kp4PsGQrPyQMOs-MwE2Znl1ewuKNslMCv7AtXIT0,16366
4
- md2conf/application.py,sha256=f5O-EUTXh-SO4P57rgqfwBbbX-A8S_n7PM4HW9AsMLc,8277
5
- md2conf/converter.py,sha256=H9OdaLb_JXAYIa5eEwVmJN75ESWarplq2LRo30gWur4,34271
6
- md2conf/emoji.py,sha256=2vMZlLD4m2X6MB-Fjv_GDzEUelb_sg4UBtF463d_p90,1792
7
- md2conf/entities.dtd,sha256=M6NzqL5N7dPs_eUA_6sDsiSLzDaAacrx9LdttiufvYU,30215
8
- md2conf/matcher.py,sha256=bZMX_GTXuEeKqIPDES8KqAqTBiesKfSH9rwbNFkD25A,3451
9
- md2conf/mermaid.py,sha256=u2pSKaLrvB3yeDciVO9mIfUT2dbVVfTALYLBaIgaJ-Y,1975
10
- md2conf/processor.py,sha256=bdwSEnxuvWsZd34_KcvLqigM8GHnll9fc-hf1VQ_5aI,4010
11
- md2conf/properties.py,sha256=2l1tW8HmnrEsXN4-Dtby2tYJQTG1MirRpM3H6ykjQ4c,1858
12
- md2conf/puppeteer-config.json,sha256=-dMTAN_7kNTGbDlfXzApl0KJpAWna9YKZdwMKbpOb60,159
13
- md2conf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- md2conf/util.py,sha256=mghtBv5c0vOBHi5CxjBh4LZbjQ0Cu0h_vB30RN4N8Bk,611
15
- markdown_to_confluence-0.2.4.dist-info/LICENSE,sha256=Pv43so2bPfmKhmsrmXFyAvS7M30-1i1tzjz6-dfhyOo,1077
16
- markdown_to_confluence-0.2.4.dist-info/METADATA,sha256=vjvF6LP_5tQAKY9ACKkmAllQDlqjyJuSg_W7bBKct5Y,12764
17
- markdown_to_confluence-0.2.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
18
- markdown_to_confluence-0.2.4.dist-info/entry_points.txt,sha256=F1zxa1wtEObtbHS-qp46330WVFLHdMnV2wQ-ZorRmX0,50
19
- markdown_to_confluence-0.2.4.dist-info/top_level.txt,sha256=_FJfl_kHrHNidyjUOuS01ngu_jDsfc-ZjSocNRJnTzU,8
20
- markdown_to_confluence-0.2.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
21
- markdown_to_confluence-0.2.4.dist-info/RECORD,,