Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ESS Beam Physics
ess-python-tools
Commits
dc255e76
Commit
dc255e76
authored
9 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
edits in convert script
parent
22404c4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Vacations/convert.py
+30
-23
30 additions, 23 deletions
Vacations/convert.py
with
30 additions
and
23 deletions
Vacations/convert.py
+
30
−
23
View file @
dc255e76
from
icalendar
import
Calendar
,
Event
import
codecs
import
os
calendar_swe
=
Calendar
()
calendar_swe
.
add
(
'
version
'
,
'
2.0
'
)
calendar_eng
=
calendar_swe
.
copy
()
i_swe
=
1
i_eng
=
1
def
create_event
(
summary
,
description
,
date
,
uid
):
event
=
Event
()
event
[
'
uid
'
]
=
str
(
uid
)
...
...
@@ -15,23 +10,35 @@ def create_event(summary, description, date, uid):
event
[
'
summary
'
]
=
summary
return
event
for
l
in
file
(
'
list.txt
'
):
# encoding issues with swedish:
l
=
codecs
.
decode
(
l
,
'
utf-8
'
)
lsp
=
l
.
split
(
'
'
)
for
f
in
os
.
listdir
(
'
.
'
):
if
f
.
split
(
'
_
'
)[
0
]
==
'
list
'
:
year
=
f
.
split
(
'
.
'
)[
0
].
split
(
'
_
'
)[
1
]
print
f
,
year
calendar_swe
=
Calendar
()
calendar_swe
.
add
(
'
version
'
,
'
2.0
'
)
calendar_eng
=
calendar_swe
.
copy
()
date
=
lsp
[
0
].
strip
()
desc_eng
=
lsp
[
1
].
split
(
'
/
'
)[
0
].
strip
()
desc_swe
=
lsp
[
1
].
split
(
'
/
'
)[
1
].
strip
()
reduction
=
lsp
[
-
1
].
strip
()
event_swe
=
create_event
(
desc_swe
,
desc_swe
+
'
,
'
+
reduction
,
date
,
i_swe
)
i_swe
+=
1
calendar_swe
.
add_component
(
event_swe
)
i_swe
=
1
i_eng
=
1
event_eng
=
create_event
(
desc_eng
,
desc_eng
+
'
,
'
+
reduction
,
date
,
i_eng
)
i_eng
+=
1
calendar_eng
.
add_component
(
event_eng
)
for
l
in
file
(
f
):
# encoding issues with swedish:
l
=
codecs
.
decode
(
l
,
'
utf-8
'
)
lsp
=
l
.
split
(
'
'
)
file
(
'
vacations_swe_2015.ics
'
,
'
w
'
).
writelines
(
calendar_swe
.
to_ical
())
file
(
'
vacations_eng_2015.ics
'
,
'
w
'
).
writelines
(
calendar_eng
.
to_ical
())
date
=
lsp
[
0
].
strip
()
desc_eng
=
lsp
[
1
].
split
(
'
/
'
)[
0
].
strip
()
desc_swe
=
lsp
[
1
].
split
(
'
/
'
)[
1
].
strip
()
reduction
=
lsp
[
-
1
].
strip
()
event_swe
=
create_event
(
desc_swe
,
desc_swe
+
'
,
'
+
reduction
,
date
,
i_swe
)
i_swe
+=
1
calendar_swe
.
add_component
(
event_swe
)
event_eng
=
create_event
(
desc_eng
,
desc_eng
+
'
,
'
+
reduction
,
date
,
i_eng
)
i_eng
+=
1
calendar_eng
.
add_component
(
event_eng
)
file
(
'
vacations_swe_{}.ics
'
.
format
(
year
),
'
w
'
).
writelines
(
calendar_swe
.
to_ical
())
file
(
'
vacations_eng_{}.ics
'
.
format
(
year
),
'
w
'
).
writelines
(
calendar_eng
.
to_ical
())
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