Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
thesis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
Jasper Gräflich
thesis
Commits
10ef92fc
Commit
10ef92fc
authored
2 years ago
by
Jasper Clemens Gräflich
Browse files
Options
Downloads
Patches
Plain Diff
Add script for creating new journal pages in wiki
parent
4e778290
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#86537
failed
2 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
journal_entry.py
+71
-0
71 additions, 0 deletions
journal_entry.py
with
71 additions
and
0 deletions
journal_entry.py
0 → 100644
+
71
−
0
View file @
10ef92fc
"""
Utility tool to add a new Journal entry to the wiki.
"""
import
glob
import
os
import
re
from
datetime
import
date
,
datetime
def
main
():
# The wikifolder for `<repo>` should be located in `../<repo>.wiki`.
reponame
=
os
.
path
.
basename
(
os
.
getcwd
())
wikifolder
=
"
../
"
+
reponame
+
"
.wiki
"
os
.
chdir
(
wikifolder
)
os
.
system
(
"
git pull
"
)
update
()
os
.
system
(
"
git add .
"
)
os
.
system
(
f
"
git commit -m
'
Create journal entry for
{
date
.
today
()
}
'"
)
def
update
():
"""
Update previous entry, MoC, and _sidebar, and create new entry.
"""
# Read previous entry
previous
=
glob
.
glob
(
"
./journal/2*
"
)[
-
1
]
with
open
(
previous
,
"
r
"
)
as
file
:
lines
=
file
.
readlines
()
lines
[
2
]
=
re
.
sub
(
r
'
next
'
,
r
'
[next](
'
+
f
'
journal/
{
date
.
today
()
}
'
+
'
)
'
,
lines
[
2
]
)
# Modify previous entry
with
open
(
previous
,
"
w
"
)
as
file
:
file
.
writelines
(
lines
)
# Create new entry
create_entry
(
previous
,
lines
[
lines
.
index
(
"
## Future Tasks
\n
"
)
+
1
:])
# Modify MoC
with
open
(
"
./journal/map-of-contents.md
"
,
"
a
"
)
as
moc
:
moc
.
write
(
f
"
[
{
date
.
today
()
}
](journal/
{
date
.
today
()
}
)
\n
"
)
# Modify sidebar
os
.
system
(
"
head -n -1 ./_sidebar.md > temp.md; mv temp.md ./_sidebar.md
"
)
with
open
(
"
./_sidebar.md
"
,
"
a
"
)
as
file
:
file
.
write
(
"
[View all pages](https://gitlab1.ptb.de/graefl01/thesis/-/wikis/pages)
"
f
"
– [Journal](journal/
{
date
.
today
()
}
)
\n
"
)
def
create_entry
(
previous
,
prev_tasks
,
day
=
None
):
if
day
==
None
:
day
=
date
.
today
()
weekday
=
day
.
strftime
(
"
%A
"
)
week
=
day
.
strftime
(
"
%W
"
)
print
(
previous
)
lines
=
[
f
"
#
{
day
}
Journal
\n\n
"
,
f
"
[previous](
{
previous
[
2
:
-
3
]
}
) –
{
weekday
}
, week
{
week
}
– next
\n\n
"
,
"
## Tasks
\n
"
,
]
lines
.
extend
(
prev_tasks
)
lines
.
extend
((
"
\n
"
,
"
## Future Tasks
\n\n
"
,
"
- [ ]
\n\n
"
))
with
open
(
f
"
./journal/
{
day
}
.md
"
,
'
w
'
)
as
file
:
file
.
writelines
(
lines
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment