-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ lxml | |
gql>=3.0.0a5 | ||
aiohttp>=3.7.4.post0 | ||
gitpython | ||
bs4 | ||
beautifulsoup4 | ||
html5lib | ||
ics | ||
dataclasses | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
import argparse | ||
import os | ||
from git import Repo | ||
from voc.c3data import C3data | ||
from voc.schedule import Schedule | ||
from voc.tools import ( | ||
commit_changes_if_something_relevant_changed, | ||
git, | ||
) | ||
|
||
def export_event_files(schedule: Schedule, options: argparse.Namespace, local = False): | ||
# to get proper a state, we first have to remove all event files from the previous run | ||
if not local or options.git: | ||
git("rm events/* >/dev/null") | ||
os.makedirs('events', exist_ok=True) | ||
|
||
# write separate file for each event, to get better git diffs | ||
# TODO: use Event.export() | ||
def export_event(event: Event): | ||
origin_system = None | ||
if isinstance(event, Event): | ||
origin_system = event.origin.origin_system | ||
|
||
with open("events/{}.json".format(event["guid"]), "w") as fp: | ||
json.dump( | ||
{ | ||
**event, | ||
"room_id": schedule._room_ids.get(event["room"], None), | ||
"origin": origin_system or None, | ||
}, | ||
fp, | ||
indent=2, | ||
cls=ScheduleEncoder, | ||
) | ||
|
||
schedule.foreach_event(export_event) | ||
|
||
|
||
def postprocessing(schedule: Schedule, options: argparse.Namespace, local = False): | ||
if not local or options.git: | ||
commit_changes_if_something_relevant_changed(schedule) | ||
# Attention: This method exits the script, if nothing relevant changed | ||
# TODO: make this fact more obvious or refactor code | ||
|
||
if not local and "c3data" in targets: | ||
print("\n== Updating c3data via API…") | ||
|
||
c3data = C3data(schedule) | ||
c3data.process_changed_events(Repo('.'), options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters