Skip to content
Snippets Groups Projects

Hedgedoc import

Merged Andreas Domanowski requested to merge hedgedoc-import into main
1 file
+ 12
4
Compare changes
  • Side-by-side
  • Inline
@@ -33,13 +33,21 @@ def import_into_hedgedoc(instance_url, session_id, export_folder, archive_file):
@@ -33,13 +33,21 @@ def import_into_hedgedoc(instance_url, session_id, export_folder, archive_file):
f"Checking existence of archive file ({archive_file})")
f"Checking existence of archive file ({archive_file})")
check_file_exists(archive_file)
check_file_exists(archive_file)
# get exported history map
# get exported history map
with open(os.path.join(export_folder, "history.json")) as map_file:
history_json_filename = "history.json"
history_dictionary = json.load(map_file)
history_dictionary = {}
 
try:
 
with open(os.path.join(export_folder, "%s" % history_json_filename)) as map_file:
 
history_dictionary = json.load(map_file)
 
except FileNotFoundError:
 
print_block_heading(
 
f"INFO: could not find file {history_json_filename}. Continuing anyways with random generated paths for "
 
f"documents")
# mapping from title of a document (= filename without md extension in archive) to its id (= note url in CodiMD)
# mapping from title of a document (= filename without md extension in archive) to its id (= note url in CodiMD)
lookup_map = {}
lookup_map = {}
for entry in history_dictionary["history"]:
if "history" in history_dictionary:
lookup_map[entry["text"]] = entry["id"]
for entry in history_dictionary["history"]:
 
lookup_map[entry["text"]] = entry["id"]
# URLs to visit to make the new document available in the history
# URLs to visit to make the new document available in the history
urls_to_visit = []
urls_to_visit = []
Loading