Skip to content

Commit

Permalink
Merge pull request #76 from UNopenGIS:dev
Browse files Browse the repository at this point in the history
Refactor events_updater.py and remove recurring weekly meeting event
  • Loading branch information
albertkun authored Dec 14, 2023
2 parents fbffd33 + 9e73365 commit 51f12ce
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 106 deletions.
137 changes: 65 additions & 72 deletions .scripts/events_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
events = []
from dateutil.rrule import rrulestr as dateutil_rrulestr
from dateutil.tz import tzlocal

for calendar in calendars:
for component in calendar.walk():
if isinstance(component, Event):
summary = component.get('summary')
if summary == 'スマート地図ミートアップ':
continue
dtstart = component.get('dtstart').dt
print(f"Original dtstart: {dtstart}") # Debug line
if isinstance(dtstart, date) and not isinstance(dtstart, datetime):
Expand All @@ -58,9 +60,9 @@
if rrule:
rrule = dateutil_rrulestr(rrule.to_ical().decode(), dtstart=dtstart)
for recurrence in rrule:
events.append((recurrence, component.get('summary')))
events.append((recurrence, summary))
else:
events.append((dtstart, component.get('summary')))
events.append((dtstart, summary))

# Sort events by start time
events.sort()
Expand Down Expand Up @@ -117,22 +119,41 @@
events_folder_path = os.path.join(parent_dir, 'docs', 'events')
i18n_folder_path = os.path.join(parent_dir, 'i18n', 'ja', 'docusaurus-plugin-content-docs', 'current', 'events')

# Write upcoming events to the current markdown files
with open(events_index_path, 'w', encoding='utf-8') as f, \
open(i18n_index_path, 'w', encoding='utf-8') as f_i18n, \
open(past_events_path, 'w', encoding='utf-8') as past_f, \
open(past_i18n_events_path, 'w', encoding='utf-8') as past_f_i18n:
f.write("# Events\n\n")
f.write("The following events are upcoming:\n\n")
f.write("| Event | Date | Time| Location |\n")
f.write("| --- | --- | --- |----|\n")

f_i18n.write("# イベントのお知らせ\n\n")
f_i18n.write("このページでは、プロジェクトに関連するイベントを紹介します。\n\n")
f_i18n.write("| イベント | 日付 |時刻| 場所 |\n")
f_i18n.write("| --- | --- | --- |---|\n")

for start_time, summary in events:
with open(events_index_path, 'w', encoding='utf-8') as f, open(i18n_index_path, 'w', encoding='utf-8') as f_i18n, open(past_events_path, 'w', encoding='utf-8') as past_f, open(past_i18n_events_path, 'w', encoding='utf-8') as past_f_i18n:
f.write("# Events\n\n")
f.write("| Event | Date | Time| Location |\n")
f.write("| --- | --- | --- |----|\n")

f_i18n.write("# イベント\n\n")
f_i18n.write("| イベント | 日付 |時刻| 場所 |\n")
f_i18n.write("| --- | --- | --- |---|\n")

for start_time, summary in events:
if summary == 'スマート地図ミートアップ':
continue
# Get the event count for this day
day = start_time.strftime("%Y-%m-%d")
count = event_counts[day]

# Append the event count to the filename if there are multiple events on this day
filename = day
if count > 1:
filename += "-" + str(count)
event_counts[day] -= 1
filename += ".md"

# Check if the event is in the past
if start_time < now:
# Write the event to the past events file
past_f.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n")
past_f_i18n.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n") # Replace with translated summary
elif now < start_time < one_month_later and summary not in existing_events:
# Write the event to the current markdown files
f.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n")
f_i18n.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n") # Replace with translated summary

if now < start_time < one_month_later and summary not in existing_events:

# Get the event count for this day
day = start_time.strftime("%Y-%m-%d")
count = event_counts[day]
Expand All @@ -144,56 +165,28 @@
event_counts[day] -= 1
filename += ".md"

# Check if the event is in the past
if start_time < now:
# Write the event to the past events file
past_f.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n")
past_f_i18n.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n") # Replace with translated summary
elif now <= start_time <= one_month_later and summary not in existing_events:
# Write the event to the current markdown files
f.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n")
f_i18n.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n") # Replace with translated summary

# Define the directory paths
events_folder_path = os.path.join(parent_dir, 'docs', 'events')
i18n_folder_path = os.path.join(parent_dir, 'i18n', 'ja', 'docusaurus-plugin-content-docs', 'current', 'events')

for start_time, summary in events:
# Get the event count for this day
day = start_time.strftime("%Y-%m-%d")
count = event_counts[day]

# Append the event count to the filename if there are multiple events on this day
filename = day
if count > 1:
filename += "-" + str(count)
event_counts[day] -= 1
filename += ".md"

# Include the directory path in the filename
filename_en = os.path.join(events_folder_path, filename)
filename_ja = os.path.join(i18n_folder_path, filename)

# Check if the event is in the future
if now <= start_time <= one_month_later and summary not in existing_events:
# Write the event to the current markdown files
if not os.path.exists(filename_en):
with open(filename_en, 'w', encoding='utf-8') as f:
f.write(f"## {summary}\n")
f.write(f"Start time: {start_time}\n\n")
f.write("## When is this event?\n\n")
f.write("- Time for Los Angeles\n")
f.write("- Time for New York\n")
f.write("- Time for Rome\n")
f.write("- Time for New Delhi\n")
f.write("- Time for Tokyo\n")
if not os.path.exists(filename_ja):
with open(filename_ja, 'w', encoding='utf-8') as f_i18n:
f_i18n.write(f"## {summary}\n") # Replace with translated summary
f_i18n.write(f"開始時間: {start_time}\n\n")
f_i18n.write("## このイベントはいつですか?\n\n")
f_i18n.write("- ロサンゼルスの時間\n")
f_i18n.write("- ニューヨークの時間\n")
f_i18n.write("- ローマの時間\n")
f_i18n.write("- ニューデリーの時間\n")
f_i18n.write("- 東京の時間\n")
# Check if the English markdown file exists
if not os.path.exists(filename):
with open(filename, 'w', encoding='utf-8') as event_file:
event_file.write(f"## {summary}\n")
event_file.write(f"Start time: {start_time}\n\n")
event_file.write("## When is this event?\n\n")
for city, tz in timezones.items():
local_start_time = start_time.astimezone(timezone(tz))
local_end_time = (start_time + timedelta(hours=1)).astimezone(timezone(tz))
event_file.write(f"- {local_start_time.strftime('%Y-%m-%dT%H:%M')}/{local_end_time.strftime('%H:%M')} for {city}\n")

# Check if the translated markdown file exists
if not os.path.exists(filename):
with open(filename, 'w', encoding='utf-8') as event_file:
event_file.write(f"## {summary}\n") # Replace with translated summary
event_file.write(f"Start time: {start_time}\n\n")
event_file.write("## When is this event?\n\n")
for city, tz in timezones.items():
local_start_time = start_time.astimezone(timezone(tz))
local_end_time = (start_time + timedelta(hours=1)).astimezone(timezone(tz))
event_file.write(f"- {local_start_time.strftime('%Y-%m-%dT%H:%M')}/{local_end_time.strftime('%H:%M')} for {city}\n")

# Write the event to the index.md file
f.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n")
f_i18n.write(f"| [{summary}]({filename}) | [{start_time.strftime('%Y-%m-%d')}]({filename}) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg={summary.replace(' ', '+')}&iso={start_time.strftime('%Y%m%dT%H%M')}&p1=1440&ah=1) | [Register](#) |\n") # Replace with translated summary
7 changes: 1 addition & 6 deletions docs/events/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Events

The following events are upcoming:

| Event | Date | Time| Location |
| --- | --- | --- |----|
| [スマート地図ミートアップ](2023-12-19.md) | [2023-12-19](2023-12-19.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20231219T1230&p1=1440&ah=1) | [Register](#) |
| [UN Smart Maps Pacific and Strategy meeting](2023-12-22.md) | [2023-12-22](2023-12-22.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=UN+Smart+Maps+Pacific+and+Strategy+meeting&iso=20231222T0300&p1=1440&ah=1) | [Register](https://ucla.zoom.us/meeting/register/tJcoc-mvrTovG920aIcgb-64RaKdVWKTb1Ik) |
| [スマート地図ミートアップ](2023-12-26.md) | [2023-12-26](2023-12-26.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20231226T1230&p1=1440&ah=1) | [Register](#) |
| [スマート地図ミートアップ](2024-01-02.md) | [2024-01-02](2024-01-02.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20240102T1230&p1=1440&ah=1) | [Register](#) |
| [UN Smart Maps Pacific and Strategy meeting](2023-12-22.md) | [2023-12-22](2023-12-22.md) | [3:00 UTC](https://www.timeanddate.com/worldclock/fixedtime.html?msg=UN+Smart+Maps+Pacific+and+Strategy+meeting&iso=20231222T0300&p1=1440&ah=1) | [Register](https://ucla.zoom.us/j/93540731519?pwd=OG91Q2FPQktpUWF1YldVNVRMT294UT09) |
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# イベントのお知らせ

このページでは、プロジェクトに関連するイベントを紹介します。

| イベント | 日付 |時刻| 場所 |
| イベント | 日付 |時間| 場所 |
| --- | --- | --- |---|
| [スマート地図ミートアップ](2023-12-19.md) | [2023-12-19](2023-12-19.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20231219T1230&p1=1440&ah=1) | [Register](#) |
| [UN Smart Maps Pacific and Strategy meeting](2023-12-22.md) | [2023-12-22](2023-12-22.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=UN+Smart+Maps+Pacific+and+Strategy+meeting&iso=20231222T0300&p1=1440&ah=1) | [Register](https://ucla.zoom.us/meeting/register/tJcoc-mvrTovG920aIcgb-64RaKdVWKTb1Ik) |
| [スマート地図ミートアップ](2023-12-26.md) | [2023-12-26](2023-12-26.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20231226T1230&p1=1440&ah=1) | [Register](#) |
| [スマート地図ミートアップ](2024-01-02.md) | [2024-01-02](2024-01-02.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=スマート地図ミートアップ&iso=20240102T1230&p1=1440&ah=1) | [Register](#) |
| [UN Smart Maps Pacific and Strategy meeting](2023-12-22.md) | [2023-12-22](2023-12-22.md) | [Time](https://www.timeanddate.com/worldclock/fixedtime.html?msg=UN+Smart+Maps+Pacific+and+Strategy+meeting&iso=20231222T0300&p1=1440&ah=1) | [Register](https://ucla.zoom.us/j/93540731519?pwd=OG91Q2FPQktpUWF1YldVNVRMT294UT09) |
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,8 @@

コミュニティミーティングは、プロジェクトについて学び、関わるための素晴らしい方法です。

## 今後のミーティング
|ミーティング| 日付 | 時刻 | 現地時刻 |リンク |
|-------|------|------|------|------|
|国連スマート地図ミートアップ日本|2023-05-16|03:30 UTC|12:30 JST|TBD|
|[国連スマート地図国際ミートアップ](./international/2023-07-21.md)|2023-07-21|04:00 UTC|13:00 JST|[Zoomリンク](https://ucla.zoom.us/meeting/register/tJcoc-mvrTovG920aIcgb-64RaKdVWKTb1Ik)|
|[国連スマート地図ドキュメンテーション](./documentation/2023-07-17.md)|2023-07-17|04:00 UTC|13:00 JST|[Zoomリンク](https://ucla.zoom.us/meeting/register/tJUrcO-pqjsiEtQZccTcBHfbeISlnexdxe4Z)|



### ミーティングスケジュール
| ミーティング | 繰り返し | 時刻 | 現地時刻 |
|---------|------------|------|------|
|国連スマート地図ミートアップ日本|毎月第3火曜日|3:30 UTC|12:30 JST |
|国連スマート地図国際ミートアップ|毎月第3金曜日|4:00 UTC|13:00 JST |
|国連スマート地図ドキュメンテーション|毎月第3月曜日|3:00 UTC|12:00 JST |

### 過去のミーティング
|ミーティング| 日付 | 時刻 | 現地時刻 |リンク |
|-------|------|------|------|------|
|国連スマート地図国際ミートアップ|2023-06-16|04:00 UTC|13:00 JST |TBD|
|国連スマート地図ドキュメンテーション|2023-05-22|04:00 UTC|13:00 JST |[Zoomリンク](https://ucla.zoom.us/j/93249046195)|
### 今後のミーティング
| ミーティング | 繰り返し | 時間 |
|---------|------------|------|
|国連スマート地図ミートアップ日本|毎月第3火曜日|3:30 UTC|

0 comments on commit 51f12ce

Please sign in to comment.