Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CodiMD export script
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stgroup
misc
CodiMD export script
Merge requests
!1
Hedgedoc import
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Hedgedoc import
hedgedoc-import
into
main
Overview
2
Commits
38
Pipelines
0
Changes
1
Merged
Andreas Domanowski
requested to merge
hedgedoc-import
into
main
2 years ago
Overview
2
Commits
38
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
853f1a71
Prev
Next
Show latest version
1 file
+
2
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
853f1a71
Write history.json only once
· 853f1a71
Andreas Domanowski
authored
2 years ago
export_md/codimd_export.py
+
2
−
2
Options
@@ -43,6 +43,8 @@ def export_from_codimd(instance_url, session_id, export_to):
target_dir
=
prepare_target_dir
(
export_to
)
num_ok
=
num_fail
=
0
print_block_heading
(
f
"
Accessing history and trying to fetch each document
"
)
with
open
(
Path
(
target_dir
,
f
"
history.json
"
),
mode
=
"
w
"
)
as
stream
:
json
.
dump
(
data
,
stream
)
print
(
"
Hold on, this may take a while...
"
)
for
row
in
data
[
"
history
"
]:
document_id
=
row
[
"
id
"
]
@@ -51,8 +53,6 @@ def export_from_codimd(instance_url, session_id, export_to):
contents
=
slurp
(
f
"
{
document_url
}
/download
"
,
session_id
)
with
open
(
Path
(
target_dir
,
f
"
{
document_id
}
.md
"
),
mode
=
"
wb
"
)
as
stream
:
stream
.
write
(
contents
)
with
open
(
Path
(
target_dir
,
f
"
history.json
"
),
mode
=
"
w
"
)
as
stream
:
json
.
dump
(
data
,
stream
)
num_ok
+=
1
except
HTTPError
as
error
:
# history might reference deleted or otherwise inaccessible notes
Loading