Skip to content

Commit 442e293

Browse files
authored
4 review 220126 (#5)
* adding 'about' graphical docu * adding download via clicking on the name in the table * add last index
1 parent c322774 commit 442e293

7 files changed

Lines changed: 347 additions & 161 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.venv/
22
/.idea/
33
/readers/
4+
/docs/atch/server/
5+
*bkp

docs/atch/about.drawio.pdf

208 KB
Binary file not shown.

docs/atch/about.drawio.svg

Lines changed: 4 additions & 0 deletions
Loading

docs/index.html

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

presents/about.drawio

Lines changed: 159 additions & 0 deletions
Large diffs are not rendered by default.

profile_manager/__main__.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import os
3+
import shutil
34
import sys
5+
from typing import BinaryIO, cast
46
from importlib.resources import files
57
from pathlib import Path
68

@@ -41,6 +43,11 @@ def build_index():
4143
reader_entry = {}
4244

4345
profile_dir = Path(__file__).parent.parent.joinpath('profiles/public')
46+
base_path = pyprojroot.find_root(pyprojroot.has_dir("build"))
47+
docs_profile_dir = Path(base_path, "docs", "atch", "server", "profiles")
48+
docs_reader_dir = Path(base_path, "docs", "atch", "server", "readers")
49+
os.makedirs(docs_profile_dir, exist_ok=True)
50+
os.makedirs(docs_reader_dir, exist_ok=True)
4451
md_file = MdUtils(file_name='index', title=program_name)
4552
# Additional Markdown syntax...
4653
md_file.new_paragraph(f"{program_name} is a very powerful python file converter "
@@ -58,6 +65,16 @@ def build_index():
5865

5966
# works for Path and Traversable
6067
reader_name = reader.name.rsplit(".", 1)[0]
68+
reader_target = docs_reader_dir / reader.name
69+
if isinstance(reader, Path):
70+
shutil.copy2(reader, reader_target)
71+
else:
72+
with reader.open("rb") as source, open(reader_target, "wb") as dest:
73+
# noinspection PyTypeChecker
74+
shutil.copyfileobj(
75+
cast(BinaryIO, source), cast(BinaryIO, dest)
76+
)
77+
reader_link = f"<a href=\"atch/server/readers/{reader.name}\" download>{reader.name}</a>"
6178

6279
reader_entry = {
6380
"class name": my_ast[0],
@@ -66,7 +83,7 @@ def build_index():
6683
"check": my_ast[3].strip() if my_ast[3] else "",
6784
}
6885

69-
readers_dict[reader_name] = reader_entry
86+
readers_dict[reader_link] = reader_entry
7087

7188
except Exception as e:
7289
print(f"Skipping {reader.name}: {e}")
@@ -79,7 +96,7 @@ def build_index():
7996
md_file.new_inline_link(link="https://github.com/ComPlat/chemotion-converter-app",
8097
text="converter app backend") + ".")
8198

82-
table_header = ["file name"]
99+
table_header = ["file name (click to download from this GitHub.io mirror)"]
83100
if reader_entry:
84101
table_header += list(reader_entry.keys())
85102
dict_to_md_table(md_file, table_header, readers_dict)
@@ -111,16 +128,20 @@ def build_index():
111128
"identifiers": get_identifiers(json_profile)
112129
}
113130

114-
# Save to the main dictionary
115-
profiles_dict[profile_id] = profile_entry
131+
# Copy profile JSON to docs and link to the local docs path
132+
shutil.copy2(profile, docs_profile_dir / profile.name)
133+
profile_link = (
134+
f"<a href=\"atch/server/profiles/{profile_id}.json\" download>{profile_id}</a>"
135+
)
136+
profiles_dict[profile_link] = profile_entry
116137

117138
md_file.new_header(level=1, title='Profiles')
118139

119140
md_file.new_paragraph("A profile is JSON file defining a ruleset on how to convert your input file."
120141
" Normally, it is created by uploading an example of your input file to the GUI of the "+
121142
md_file.new_inline_link(link="https://github.com/ComPlat/chemotion-converter-client", text="converter client frontend") + ".")
122143

123-
table_header = ["id"] + list(profile_entry.keys())
144+
table_header = ["id (click to download from this GitHub.io mirror)"] + list(profile_entry.keys())
124145
profiles_sorted = dict(sorted(
125146
profiles_dict.items(),
126147
key=lambda item: (item[1].get("extension") or "").lower(),

0 commit comments

Comments
 (0)