diff --git a/eventgenutils.py b/eventgenutils.py index cef9eddf2ff3d9af40fc5910e1f0a121870231b0..35403559e546983a7db98f1d9fb6e3a96b9a4a96 100644 --- a/eventgenutils.py +++ b/eventgenutils.py @@ -38,6 +38,10 @@ def is_wednesday(_date_candidate): return wd == WED +def is_nth_monday_of_month(_date_candidate, _n): + return is_nth_xday_of_month(_date_candidate, _date_candidate.year, _date_candidate.month, _n, MON) + + def is_nth_tuesday_of_month(_date_candidate, _n): return is_nth_xday_of_month(_date_candidate, _date_candidate.year, _date_candidate.month, _n, TUE) @@ -54,6 +58,50 @@ def is_nth_friday_of_month(_date_candidate, _n): return is_nth_xday_of_month(_date_candidate, _date_candidate.year, _date_candidate.month, _n, FRI) +def is_first_monday_of_month(_date_candidate): + is_nth_monday_of_month(_date_candidate, 1) + + +def is_first_monday_of_month_except_january_an_may_if_monday_is_first(_date_candidate): + _year = _date_candidate.year + if is_january(_date_candidate): + _firstof_string = str(_year) + "-01-01" + _firstof = datetime.datetime.strptime(_firstof_string, date_format) + if _firstof.weekday() == MON: + return is_nth_monday_of_month(_date_candidate, 2) + if is_may(_date_candidate): + _firstof_string = str(_year) + "-05-01" + _firstof = datetime.datetime.strptime(_firstof_string, date_format) + if _firstof.weekday() == MON: + return is_nth_monday_of_month(_date_candidate, 2) + return is_nth_monday_of_month(_date_candidate, 1) + + +def first_saturday_after_may_10th(_date_candidate): + _year = _date_candidate.year + _start_string = str(_year) + "-05-10" + _start = datetime.datetime.strptime(_start_string, date_format) + while _start.month == 5: + if _start.weekday() == SAT: + if _start == _date_candidate: + return True + else: + return False + _start += datetime.timedelta(days=1) + + +def last_saturday_in_march(_date_candidate): + _year = _date_candidate.year + _start_string = str(_year) + "-03-20" + _start = datetime.datetime.strptime(_start_string, date_format) + _last_saturday = None + while _start.month == 3: + if _start.weekday() == SAT: + _last_saturday = _start + _start += datetime.timedelta(days=1) + return _date_candidate == _last_saturday + + def is_equal_month(_date_candidate): if _date_candidate.month % 2 == 1: return True @@ -63,15 +111,35 @@ def is_equal_month(_date_candidate): def is_january(_date_candidate): return _date_candidate.month == 1 + def is_march(_date_candidate): return _date_candidate.month == 3 + +def is_april(_date_candidate): + return _date_candidate.month == 4 + + +def is_may(_date_candidate): + return _date_candidate.month == 5 + + def is_june(_date_candidate): return _date_candidate.month == 6 + +def is_july(_date_candidate): + return _date_candidate.month == 7 + + def is_september(_date_candidate): return _date_candidate.month == 9 + +def is_october(_date_candidate): + return _date_candidate.month == 10 + + def is_november(_date_candidate): return _date_candidate.month == 11 @@ -107,6 +175,10 @@ def modify_template(_template, _start, _end): return _template +def get_filename(_start, _name): + return _start.strftime("%Y-%m-%d") + "-" + _name + ".markdown" + + def create_event(_name, _date, start_hour=00, start_minute=00, end_hour=23, end_minute=59, add_days=0): with open(_name + ".txt") as f: _template = f.read() @@ -116,6 +188,19 @@ def create_event(_name, _date, start_hour=00, start_minute=00, end_hour=23, end_ _template = modify_template(_template, _start, _end) - filename = _start.strftime("%Y-%m-%d") + "-" + _name + ".md" - with open("created/" + filename, 'w') as out: + with open("created/" + get_filename(_start, _name), 'w') as out: + out.write(_template) + + +def create_event_c3(_name, _date, start_hour=00, start_minute=00, end_hour=23, end_minute=59, add_days=0): + with open(_name + ".txt") as f: + _template = f.read() + _start = cet.localize(_date.replace(hour=start_hour, minute=start_minute, second=00)) + _end = cet.localize(_date.replace(hour=end_hour, minute=end_minute, second=00)) + _end += datetime.timedelta(days=add_days) + + _template = modify_template(_template, _start, _end) + _template = _template.replace("<CCCNumber>", str(_start.year - 1986)) + + with open("created/" + get_filename(_start, _name), 'w') as out: out.write(_template) diff --git a/getting-space-clean.txt b/getting-space-clean.txt new file mode 100644 index 0000000000000000000000000000000000000000..b6730772123f27db7efdfcd41f7fefb11bcba895 --- /dev/null +++ b/getting-space-clean.txt @@ -0,0 +1,12 @@ +--- +layout: [eventcal] +title: "Getting Space Clean" +eventdate: <EVENTSTART> +eventend: <EVENTEND> +#https://www.uuidgenerator.net/ +uid: <UUID> +contact: info@chaotikum.org +locations: + - nobreakspace (gesamt) +short: "Monatliche Hau-Ruck-Aufräum- und Putzaktion im gesamten Nobreakspace. Lasst uns den Space gemeinsam sauber und behaglich halten!" +--- diff --git a/main.py b/main.py index 1d4879825beeedb77f94f4c82437a384a725fa79..7c9044bc9d2115a911f02dae85e21224f24655fe 100644 --- a/main.py +++ b/main.py @@ -4,23 +4,33 @@ import eventgenutils as utils ################################################# # set true if you want to generate files for that event type ################################################# -OPENSPACE = True +OPENSPACE = False # every wednesday 19:00 to 23:59:59 but not between (and including) 24.12 and 1.1 -REINIGUNG = True +REINIGUNG = False # wednesday from 09:00 to 18:00 -PLENUM = True +PLENUM = False # second thursday of the month, except in november, where it is the third -OSM = True +OSM = False # vierter donnerstag in ungeraden monaten -BITSUNDBAEUME = True +BITSUNDBAEUME = False # jeden zweiten Dienstag im Monat um 18:31... ich vermute mal nicht im Januar? -FFHLORGA = True +FFHLORGA = False # jeden dritten Donnerstag im Monat 19:00 bis 22:00 Uhr -NOOK = True +NOOK = False # zweiter freitag im November (und der darauf folgende Samstag) FUENF_MIN_TERMINE = True -# üblicherweise am vierten Mittwoch im letzten monat des quartals außer dezember (also März, Juni, September) -# März wird ggf geschoben, wenn Ostern/Easterhegg dazwischen kommt... +# Üblicherweise Zweiter Mittwoch im ersten Monat des Quartals +SOMMERFEST = False +# Üblicherweise der erste Samstag nach dem 10 Mai. 15:00 bis 23:59 +TAG_DES_OFFENEN_HACKSPACES = False +# https://wiki.hackerspaces.org/International_Open_Hackerspace_Day +# The International Open Hackerspace Day is happening every last Saturday of March. +MOINC3 = False +# Congress. +MAUS_TUEROEFFNER_TAG = False +# Der Maus Türöffner Tag ist immer am Tag der Deutschen Einheit +GETTING_SPACE_CLEAN = False +# Erster Montag des Monats, außer das ist der 01.01 oder 01.05, dann der zweite Montag dieser Monate ################################################# # Year to create events for @@ -73,17 +83,38 @@ def is_ffhl(_date_candidate): def is_nook(_date_candidate): - if utils.is_november(_date_candidate) and utils.is_nth_friday_of_month(_date_candidate, 2): - return True + return utils.is_november(_date_candidate) and utils.is_nth_friday_of_month(_date_candidate, 2) def is_fuenf_min(_date_candidate): - if utils.is_march(_date_candidate) or utils.is_june(_date_candidate) or utils.is_september(_date_candidate): - if utils.is_nth_wednesday_of_month(_date_candidate, 4): + if utils.is_april(_date_candidate) or utils.is_july(_date_candidate) or utils.is_october(_date_candidate): + if utils.is_nth_wednesday_of_month(_date_candidate, 2): return True return False +def is_sommerfest(_date_candidate): + return utils.first_saturday_after_may_10th(_date_candidate) + + +def is_tag_des_offenen_hackspaces(_date_candidate): + return utils.last_saturday_in_march(_date_candidate) + + +def is_moin_c3(_date_candidate): + _md = _date_candidate.day + return utils.is_december(_date_candidate) and _md == 27 + + +def is_maus_tueroeffner_tag(_date_candidate): + _md = _date_candidate.day + return utils.is_october(_date_candidate) and _md == 3 + + +def is_getting_space_clean(_date_candidate): + return utils.is_first_monday_of_month_except_january_an_may_if_monday_is_first(_date_candidate) + + def create_open_space(_date): utils.create_event("openspace", _date, start_hour=19) @@ -116,6 +147,26 @@ def create_fuenf_min(_date): utils.create_event("5min", _date, start_hour=20, end_hour=21) +def create_sommerfest(_date): + utils.create_event("sommerfest", _date, start_hour=15) + + +def create_tag_des_offenen_hackspaces(_date): + utils.create_event("tagderoffenenhackspaces", _date, start_hour=15, end_hour=20, end_minute=00) + + +def create_moin_c3(_date): + utils.create_event_c3("moinc3", _date, add_days=3) + + +def create_getting_space_clean(_date): + utils.create_event("getting-space-clean", _date, start_hour=18, start_minute=30, end_hour=20, end_minute=00) + + +def create_maus_tueroeffner_tag(_date): + utils.create_event("maus", _date, start_hour=14, end_hour=19, end_minute=00) + + date_to_check = datetime.datetime.strptime(str(YEAR) + "-01-01", utils.date_format) while date_to_check <= datetime.datetime.strptime(str(YEAR) + "-12-31", utils.date_format): if OPENSPACE: @@ -150,5 +201,25 @@ while date_to_check <= datetime.datetime.strptime(str(YEAR) + "-12-31", utils.da result = is_fuenf_min(date_to_check) if result: create_fuenf_min(date_to_check) + if SOMMERFEST: + result = is_sommerfest(date_to_check) + if result: + create_sommerfest(date_to_check) + if TAG_DES_OFFENEN_HACKSPACES: + result = is_tag_des_offenen_hackspaces(date_to_check) + if result: + create_tag_des_offenen_hackspaces(date_to_check) + if MOINC3: + result = is_moin_c3(date_to_check) + if result: + create_moin_c3(date_to_check) + if MAUS_TUEROEFFNER_TAG: + result = is_maus_tueroeffner_tag(date_to_check) + if result: + create_maus_tueroeffner_tag(date_to_check) + if GETTING_SPACE_CLEAN: + result = is_getting_space_clean(date_to_check) + if result: + create_getting_space_clean(date_to_check) date_to_check += datetime.timedelta(days=1) diff --git a/maus.txt b/maus.txt new file mode 100644 index 0000000000000000000000000000000000000000..0cd40a77bf434bbca7e8641c68560f63615185cd --- /dev/null +++ b/maus.txt @@ -0,0 +1,14 @@ +--- +layout: [eventcal] +title: "Maus Türöffner Tag" +eventdate: <EVENTSTART> +eventend: <EVENTEND> +#https://www.uuidgenerator.net/ +uid: <UUID> +contact: info@chaotikum.org +locations: + - Augenprüfraum + - Wartezimmer + - Lager +short: "Maus Türöffner Tag im nbsp" +--- diff --git a/moinc3.txt b/moinc3.txt new file mode 100644 index 0000000000000000000000000000000000000000..4a37e21efb75abbcd80dcf226cde37ad4d61461d --- /dev/null +++ b/moinc3.txt @@ -0,0 +1,12 @@ +--- +layout: [eventcal] +title: "MOiN auf dem <CCCNumber>C3" +eventdate: <EVENTSTART> +eventend: <EVENTEND> +#https://www.uuidgenerator.net/ +uid: <UUID> +contact: info@chaotikum.org +locations: + - CCH +short: "Wir sind Teil von MOiN auf dem <CCCNumber>C3" +--- diff --git a/sommerfest.txt b/sommerfest.txt new file mode 100644 index 0000000000000000000000000000000000000000..a494e61482fa7b69d3db4ffc1c50f6902498fe00 --- /dev/null +++ b/sommerfest.txt @@ -0,0 +1,14 @@ +--- +layout: [eventcal] +title: "Chaotikum Sommerfest" +eventdate: <EVENTSTART> +eventend: <EVENTEND> +#https://www.uuidgenerator.net/ +uid: <UUID> +contact: vorstand@chaotikum.org +fotopolicy: open +organizer: Chaotikum +locations: + - Parkplatz hinter dem Nbsp +short: "Chaotikum (Früh)-Sommerfest" +--- diff --git a/tagderoffenenhackspaces.txt b/tagderoffenenhackspaces.txt new file mode 100644 index 0000000000000000000000000000000000000000..ea31a817b1a8b6bb8b1d4e16175eab705edcaf60 --- /dev/null +++ b/tagderoffenenhackspaces.txt @@ -0,0 +1,14 @@ +--- +layout: [eventcal] +title: "Tag des Offenen Hackspaces" +eventdate: <EVENTSTART> +eventend: <EVENTEND> +#https://www.uuidgenerator.net/ +uid: <UUID> +contact: info@chaotikum.org +locations: + - Augenprüfraum + - Wartezimmer + - Lager +short: "Kommt vorbei! Wir haben Computer, Elektronik, Dinge zum Löten (auch für Anfänger) und kalte Getränke" +---