opentechcalendartools 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opentechcalendartools/worker.py +45 -12
- {opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/METADATA +1 -1
- opentechcalendartools-0.1.1.dist-info/RECORD +9 -0
- {opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/WHEEL +1 -1
- opentechcalendartools-0.1.0.dist-info/RECORD +0 -9
- {opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/licenses/LICENSE +0 -0
- {opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/top_level.txt +0 -0
opentechcalendartools/worker.py
CHANGED
|
@@ -2,6 +2,7 @@ import datetime
|
|
|
2
2
|
import os
|
|
3
3
|
import sqlite3
|
|
4
4
|
import tempfile
|
|
5
|
+
import zoneinfo
|
|
5
6
|
|
|
6
7
|
import icalendar
|
|
7
8
|
import requests
|
|
@@ -43,31 +44,63 @@ class Worker:
|
|
|
43
44
|
os.close(new_filename_dets[0])
|
|
44
45
|
return new_filename_dets[1]
|
|
45
46
|
|
|
46
|
-
def _import_group_type_ical(
|
|
47
|
-
self, group, ical_filename, group_country=None, group_place=None
|
|
48
|
-
):
|
|
47
|
+
def _import_group_type_ical(self, group, ical_filename):
|
|
49
48
|
os.makedirs(os.path.join(self._data_dir, "event", group["id"]), exist_ok=True)
|
|
50
49
|
with open(ical_filename) as fp:
|
|
51
50
|
calendar = icalendar.Calendar.from_ical(fp.read())
|
|
52
51
|
for event in calendar.events:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
timezone_name = group["field_timezone"] or "UTC"
|
|
53
|
+
start_datetime = event.get("DTSTART").dt
|
|
54
|
+
end_datetime = event.get("DTEND").dt
|
|
55
|
+
if isinstance(start_datetime, datetime.datetime):
|
|
56
|
+
pass
|
|
57
|
+
elif isinstance(start_datetime, datetime.date):
|
|
58
|
+
start_datetime = datetime.datetime(
|
|
59
|
+
start_datetime.year,
|
|
60
|
+
start_datetime.month,
|
|
61
|
+
start_datetime.day,
|
|
62
|
+
0,
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
65
|
+
tzinfo=zoneinfo.ZoneInfo(timezone_name),
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
raise Exception(
|
|
69
|
+
"Start not in the format we expect {}".format(start_datetime)
|
|
70
|
+
)
|
|
71
|
+
if isinstance(end_datetime, datetime.datetime):
|
|
72
|
+
pass
|
|
73
|
+
elif isinstance(end_datetime, datetime.date):
|
|
74
|
+
end_datetime = datetime.datetime(
|
|
75
|
+
end_datetime.year,
|
|
76
|
+
end_datetime.month,
|
|
77
|
+
end_datetime.day,
|
|
78
|
+
23,
|
|
79
|
+
59,
|
|
80
|
+
59,
|
|
81
|
+
tzinfo=zoneinfo.ZoneInfo(timezone_name),
|
|
82
|
+
)
|
|
83
|
+
else:
|
|
84
|
+
raise Exception(
|
|
85
|
+
"End not in the format we expect {}".format(end_datetime)
|
|
86
|
+
)
|
|
87
|
+
if end_datetime.timestamp() > datetime.datetime.now().timestamp():
|
|
56
88
|
# Create event data with various fields
|
|
57
89
|
event_data = {
|
|
58
90
|
"title": str(event.get("SUMMARY")),
|
|
59
91
|
"group": group["id"],
|
|
60
|
-
"timezone":
|
|
61
|
-
"start_at": str(
|
|
62
|
-
"end_at": str(
|
|
92
|
+
"timezone": timezone_name,
|
|
93
|
+
"start_at": str(start_datetime),
|
|
94
|
+
"end_at": str(end_datetime),
|
|
63
95
|
"url": str(event.get("URL")),
|
|
64
96
|
"cancelled": (event.get("STATUS") == "CANCELLED"),
|
|
65
97
|
"imported": True,
|
|
66
98
|
"community_participation": {
|
|
67
|
-
"at_event":
|
|
68
|
-
"at_event_audience_text":
|
|
69
|
-
"at_event_audience_audio":
|
|
99
|
+
"at_event": "unknown",
|
|
100
|
+
"at_event_audience_text": "unknown",
|
|
101
|
+
"at_event_audience_audio": "unknown",
|
|
70
102
|
},
|
|
103
|
+
"in_person": "unknown",
|
|
71
104
|
}
|
|
72
105
|
if group["field_country"]:
|
|
73
106
|
event_data["country"] = group["field_country"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
opentechcalendartools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
opentechcalendartools/__main__.py,sha256=k62u01s2PYzYpErY7unEc49JsxnOohcSOG_Gu9pFuYA,98
|
|
3
|
+
opentechcalendartools/cli.py,sha256=fR5XhuniYb15hOGzYmCHc2ORRxbhiB9KOEUZNtkiIx8,1201
|
|
4
|
+
opentechcalendartools/worker.py,sha256=W_rJCgwZXJeGx2HsjCROEfqDWRQDRjmmVQlVtRphoLM,7483
|
|
5
|
+
opentechcalendartools-0.1.1.dist-info/licenses/LICENSE,sha256=t3-svmFJHEV_slEWg4lRY-LK523IOA56WXz62uOzGFI,1499
|
|
6
|
+
opentechcalendartools-0.1.1.dist-info/METADATA,sha256=ugHs_NLZ8srvRPVZSX4yXwvS7ULOobm0DQRALw4WWYQ,881
|
|
7
|
+
opentechcalendartools-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
8
|
+
opentechcalendartools-0.1.1.dist-info/top_level.txt,sha256=cXAUphHY7mCrtEnq3V6i_QyeWcbBEM75SJYjrUtDZ8E,22
|
|
9
|
+
opentechcalendartools-0.1.1.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
opentechcalendartools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
opentechcalendartools/__main__.py,sha256=k62u01s2PYzYpErY7unEc49JsxnOohcSOG_Gu9pFuYA,98
|
|
3
|
-
opentechcalendartools/cli.py,sha256=fR5XhuniYb15hOGzYmCHc2ORRxbhiB9KOEUZNtkiIx8,1201
|
|
4
|
-
opentechcalendartools/worker.py,sha256=hxn_gYiswPE9jwj0WEfE2wKuIeHdpr_bbB-KA9wQ5JM,6019
|
|
5
|
-
opentechcalendartools-0.1.0.dist-info/licenses/LICENSE,sha256=t3-svmFJHEV_slEWg4lRY-LK523IOA56WXz62uOzGFI,1499
|
|
6
|
-
opentechcalendartools-0.1.0.dist-info/METADATA,sha256=cXQwxc4QiEuS3Wq68jeUBpDT6pjFBasVuEHgh6QCcC4,881
|
|
7
|
-
opentechcalendartools-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
opentechcalendartools-0.1.0.dist-info/top_level.txt,sha256=cXAUphHY7mCrtEnq3V6i_QyeWcbBEM75SJYjrUtDZ8E,22
|
|
9
|
-
opentechcalendartools-0.1.0.dist-info/RECORD,,
|
{opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{opentechcalendartools-0.1.0.dist-info → opentechcalendartools-0.1.1.dist-info}/top_level.txt
RENAMED
|
File without changes
|