Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lecture materials
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
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
generic software skills
lecture materials
Commits
32fce96b
Unverified
Commit
32fce96b
authored
1 year ago
by
Lukas Kluft
Browse files
Options
Downloads
Patches
Plain Diff
Add script to convert lecture dates to iCal
parent
322139f1
No related branches found
No related tags found
1 merge request
!32
Extract lectures dates from Markdown
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
requirements.txt
+9
-8
9 additions, 8 deletions
requirements.txt
scripts/md2ical.py
+50
-0
50 additions, 0 deletions
scripts/md2ical.py
with
59 additions
and
8 deletions
requirements.txt
+
9
−
8
View file @
32fce96b
jupyter
jupyter-cache
beautifulsoup4
aiohttp
icalendar
intake
xarray
intake-xarray
requests
aiohttp
z
ar
r
jupyter
jupyter-cache
m
ar
kdown2
matplotlib
pyyaml
beautifulsoup4
markdown2
requests
xarray
zarr
This diff is collapsed.
Click to expand it.
scripts/md2ical.py
0 → 100755
+
50
−
0
View file @
32fce96b
#!/usr/bin/env python3
import
argparse
import
markdown2
from
bs4
import
BeautifulSoup
from
icalendar
import
Calendar
,
Event
from
datetime
import
datetime
def
extract_lecture_dates
(
markdown_file
,
output_file
):
with
open
(
markdown_file
,
"
r
"
)
as
file
:
html_content
=
markdown2
.
markdown
(
file
.
read
(),
extras
=
[
"
tables
"
])
cal
=
Calendar
()
cal
.
add
(
"
prodid
"
,
"
-//md2ical//Generic Software Skills Lectures//EN
"
)
cal
.
add
(
"
version
"
,
"
2.0
"
)
cal
.
add
(
"
x-wr-calname
"
,
"
GSS Lectures
"
)
soup
=
BeautifulSoup
(
html_content
,
"
html.parser
"
)
for
table_entry
in
soup
.
findAll
(
"
tr
"
)[
1
:]:
date
,
title
,
lecturers
=
[
e
.
contents
[
0
]
for
e
in
table_entry
.
findAll
(
"
td
"
)]
event
=
Event
()
event
.
add
(
"
summary
"
,
f
"
{
title
}
(
{
lecturers
}
)
"
)
event
.
add
(
"
uid
"
,
f
"
{
title
}
+
{
lecturers
}
"
.
replace
(
"
"
,
"
+
"
).
replace
(
"
,
"
,
""
))
event
.
add
(
"
dtstamp
"
,
datetime
.
fromisoformat
(
f
"
{
date
}
T1100Z
"
))
event
.
add
(
"
dtstart
"
,
datetime
.
fromisoformat
(
f
"
{
date
}
T1100Z
"
))
event
.
add
(
"
dtend
"
,
datetime
.
fromisoformat
(
f
"
{
date
}
T1300Z
"
))
event
.
add
(
"
location
"
,
"
Geomatikum, Room 1536a
"
)
cal
.
add_component
(
event
)
with
open
(
output_file
,
"
wb
"
)
as
f
:
f
.
write
(
cal
.
to_ical
())
def
main
():
parser
=
argparse
.
ArgumentParser
(
prog
=
"
md2ical
"
,
description
=
"
Convert a Markdown calendar table to an iCal calendar.
"
,
)
parser
.
add_argument
(
"
-f
"
,
"
--filename
"
,
required
=
True
)
parser
.
add_argument
(
"
-o
"
,
"
--output
"
,
required
=
True
)
args
=
parser
.
parse_args
()
extract_lecture_dates
(
args
.
filename
,
args
.
output
)
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