opentechcalendartools 0.0.0__py3-none-any.whl → 0.1.0__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 +64 -11
- {opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/METADATA +1 -1
- opentechcalendartools-0.1.0.dist-info/RECORD +9 -0
- opentechcalendartools-0.0.0.dist-info/RECORD +0 -9
- {opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/WHEEL +0 -0
- {opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/licenses/LICENSE +0 -0
- {opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/top_level.txt +0 -0
opentechcalendartools/worker.py
CHANGED
|
@@ -29,10 +29,8 @@ class Worker:
|
|
|
29
29
|
group = res.fetchone()
|
|
30
30
|
if group["field_import_type"] == "ical":
|
|
31
31
|
self._import_group_type_ical(
|
|
32
|
-
|
|
32
|
+
group,
|
|
33
33
|
self._download_file_to_temp(group["field_import_url"]),
|
|
34
|
-
group_country=group["field_country"],
|
|
35
|
-
group_place=group["field_place"],
|
|
36
34
|
)
|
|
37
35
|
|
|
38
36
|
def _download_file_to_temp(self, url) -> str:
|
|
@@ -46,34 +44,89 @@ class Worker:
|
|
|
46
44
|
return new_filename_dets[1]
|
|
47
45
|
|
|
48
46
|
def _import_group_type_ical(
|
|
49
|
-
self,
|
|
47
|
+
self, group, ical_filename, group_country=None, group_place=None
|
|
50
48
|
):
|
|
51
|
-
os.makedirs(os.path.join(self._data_dir, "event",
|
|
49
|
+
os.makedirs(os.path.join(self._data_dir, "event", group["id"]), exist_ok=True)
|
|
52
50
|
with open(ical_filename) as fp:
|
|
53
51
|
calendar = icalendar.Calendar.from_ical(fp.read())
|
|
54
52
|
for event in calendar.events:
|
|
55
53
|
start = event.get("DTSTART")
|
|
56
54
|
end = event.get("DTEND")
|
|
57
55
|
if end.dt.timestamp() > datetime.datetime.now().timestamp():
|
|
56
|
+
# Create event data with various fields
|
|
58
57
|
event_data = {
|
|
59
58
|
"title": str(event.get("SUMMARY")),
|
|
60
|
-
"group":
|
|
59
|
+
"group": group["id"],
|
|
60
|
+
"timezone": group["field_timezone"] or "UTC",
|
|
61
61
|
"start_at": str(start.dt),
|
|
62
62
|
"end_at": str(end.dt),
|
|
63
63
|
"url": str(event.get("URL")),
|
|
64
64
|
"cancelled": (event.get("STATUS") == "CANCELLED"),
|
|
65
65
|
"imported": True,
|
|
66
|
+
"community_participation": {
|
|
67
|
+
"at_event": None,
|
|
68
|
+
"at_event_audience_text": None,
|
|
69
|
+
"at_event_audience_audio": None,
|
|
70
|
+
},
|
|
66
71
|
}
|
|
67
|
-
if
|
|
68
|
-
event_data["country"] =
|
|
69
|
-
if
|
|
70
|
-
event_data["place"] =
|
|
72
|
+
if group["field_country"]:
|
|
73
|
+
event_data["country"] = group["field_country"]
|
|
74
|
+
if group["field_place"]:
|
|
75
|
+
event_data["place"] = group["field_place"]
|
|
76
|
+
if group["field_code_of_conduct_url"]:
|
|
77
|
+
event_data["code_of_conduct_url"] = group[
|
|
78
|
+
"field_code_of_conduct_url"
|
|
79
|
+
]
|
|
80
|
+
# In-person events
|
|
81
|
+
if group["field_in_person"] == "all":
|
|
82
|
+
event_data["in_person"] = "yes"
|
|
83
|
+
elif group["field_in_person"] == "none":
|
|
84
|
+
event_data["in_person"] = "no"
|
|
85
|
+
# Community Participation: Interact with event?
|
|
86
|
+
if group["field_community_participation_at_event"] == "all":
|
|
87
|
+
event_data["community_participation"]["at_event"] = "yes"
|
|
88
|
+
elif group["field_community_participation_at_event"] == "none":
|
|
89
|
+
event_data["community_participation"]["at_event"] = "no"
|
|
90
|
+
# Community Participation: Interact with other audience members at the event via text?
|
|
91
|
+
if (
|
|
92
|
+
group["field_community_participation_at_event_audience_text"]
|
|
93
|
+
== "all"
|
|
94
|
+
):
|
|
95
|
+
event_data["community_participation"][
|
|
96
|
+
"at_event_audience_text"
|
|
97
|
+
] = "yes"
|
|
98
|
+
elif (
|
|
99
|
+
group["field_community_participation_at_event_audience_text"]
|
|
100
|
+
== "none"
|
|
101
|
+
):
|
|
102
|
+
event_data["community_participation"][
|
|
103
|
+
"at_event_audience_text"
|
|
104
|
+
] = "no"
|
|
105
|
+
# Community Participation: Interact with other audience members at the event via audio?
|
|
106
|
+
if (
|
|
107
|
+
group["field_community_participation_at_event_audience_audio"]
|
|
108
|
+
== "all"
|
|
109
|
+
):
|
|
110
|
+
event_data["community_participation"][
|
|
111
|
+
"at_event_audience_audio"
|
|
112
|
+
] = "yes"
|
|
113
|
+
elif (
|
|
114
|
+
group["field_community_participation_at_event_audience_audio"]
|
|
115
|
+
== "none"
|
|
116
|
+
):
|
|
117
|
+
event_data["community_participation"][
|
|
118
|
+
"at_event_audience_audio"
|
|
119
|
+
] = "no"
|
|
120
|
+
# Id
|
|
71
121
|
id = event.get("UID").split("@").pop(0)
|
|
122
|
+
# filename
|
|
72
123
|
filename = os.path.join(
|
|
73
|
-
self._data_dir, "event",
|
|
124
|
+
self._data_dir, "event", group["id"], id + ".md"
|
|
74
125
|
)
|
|
126
|
+
# Finally write data
|
|
75
127
|
with open(filename, "w") as fp:
|
|
76
128
|
fp.write("---\n")
|
|
77
129
|
fp.write(yaml.dump(event_data))
|
|
78
130
|
fp.write("---\n\n\n")
|
|
79
131
|
fp.write(event.get("DESCRIPTION"))
|
|
132
|
+
fp.write("\n")
|
|
@@ -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=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,,
|
|
@@ -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=0MD6QVW5BaXFX4aL6M7gf6VG2LuqBrzwa3QZuP076Lc,3215
|
|
5
|
-
opentechcalendartools-0.0.0.dist-info/licenses/LICENSE,sha256=t3-svmFJHEV_slEWg4lRY-LK523IOA56WXz62uOzGFI,1499
|
|
6
|
-
opentechcalendartools-0.0.0.dist-info/METADATA,sha256=iJ-pfMuATfpKCK1Vd0kydMPWN_Rk8OaE5U0-pBsG5Zs,881
|
|
7
|
-
opentechcalendartools-0.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
8
|
-
opentechcalendartools-0.0.0.dist-info/top_level.txt,sha256=cXAUphHY7mCrtEnq3V6i_QyeWcbBEM75SJYjrUtDZ8E,22
|
|
9
|
-
opentechcalendartools-0.0.0.dist-info/RECORD,,
|
|
File without changes
|
{opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{opentechcalendartools-0.0.0.dist-info → opentechcalendartools-0.1.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|