Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
SAPHsync
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SAPHIRE
SAPHsync
Commits
e902c393
Commit
e902c393
authored
Nov 17, 2018
by
erdnaxe
🎇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make ICS valid
parent
e4e25f40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
config.yml.example
config.yml.example
+2
-1
icalendar_tools.py
icalendar_tools.py
+7
-1
saphsync.py
saphsync.py
+12
-0
No files found.
config.yml.example
View file @
e902c393
...
...
@@ -14,5 +14,6 @@ selected_groups:
base_url: 'https://agenda.ens-cachan.fr/SOGo/dav/'
calendars_url:
- 'user/Calendar/example.ics'
- 'PUT_YOUR_USERNAME/Calendar/personal.ics'
- 'OTHER_USERNAME_TO_SUSCRIBE/Calendar/example.ics'
icalendar_tools.py
View file @
e902c393
...
...
@@ -31,9 +31,15 @@ class OnlineCalendar:
if
component
.
name
==
'VTODO'
:
yield
component
def
get_timezone
(
self
):
"""Return one timezone"""
for
component
in
self
.
components
.
walk
():
if
component
.
name
==
'VTIMEZONE'
:
return
component
def
get_other_components
(
self
):
"""Return all unrecognised components"""
blacklist
=
[
'VEVENT'
,
'VTODO'
,
'V
CALENDAR'
,
'DAYLIGHT'
,
'VTIMEZONE
'
,
'STANDARD'
]
blacklist
=
[
'VEVENT'
,
'VTODO'
,
'V
TIMEZONE'
,
'VCALENDAR'
,
'DAYLIGHT
'
,
'STANDARD'
]
for
component
in
self
.
components
.
walk
():
if
component
.
name
not
in
blacklist
:
...
...
saphsync.py
View file @
e902c393
...
...
@@ -9,20 +9,32 @@ from icalendar_tools import OnlineCalendar
logging
.
basicConfig
(
format
=
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'
,
level
=
logging
.
INFO
)
config
=
Configuration
(
'config.yml'
)
# Create master calendar
calendar
=
Calendar
()
calendar
.
add
(
'prodid'
,
'-//SaphSync//mxm.dk//'
)
calendar
.
add
(
'version'
,
'2.0'
)
# Fetch online calendar and copy components
for
url
in
config
.
calendars_url
:
online_calendar
=
OnlineCalendar
(
url
,
config
.
login
,
config
.
password
)
# Copy timezone definitions
tz
=
online_calendar
.
get_timezone
()
calendar
.
add_component
(
tz
)
# Copy events
for
event
in
online_calendar
.
get_events
():
# If it is an event in the future and in the correct group
if
filter_date
(
event
)
and
filter_group
(
event
,
config
.
selected_groups
):
logging
.
debug
(
'An event was added : {}'
.
format
(
event
.
get
(
'summary'
)))
calendar
.
add_component
(
event
)
# Copy tasks
for
todo
in
online_calendar
.
get_todos
():
logging
.
debug
(
'A task was added : {}'
.
format
(
todo
.
get
(
'summary'
)))
calendar
.
add_component
(
todo
)
# Copy other components
for
component
in
online_calendar
.
get_other_components
():
logging
.
info
(
'A unrecognised component ({}) was added : {}'
.
format
(
component
.
name
,
component
.
to_ical
()))
calendar
.
add_component
(
component
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment