33# call event sink with our collected events
44# print to console / output to file formatted markdown
55
6+ """
7+ Example Markdown format:
8+ * 2024-03-06 | Virtual (Dublin, IE) | [Rust Dublin](https://www.meetup.com/rust-dublin/)
9+ * [**An intro to `nom`, parsing made easy for Rustaceans**](https://www.meetup.com/rust-dublin/events/299358988/)
10+ * 2024-03-06 | Virtual (Indianapolis, IN, US) | [Indy Rust](https://www.meetup.com/indyrs/)
11+ * [**Indy.rs - with Social Distancing**](https://www.meetup.com/indyrs/events/299047891/)
12+ * 2024-03-07 | Virtual (Charlottesville, NC, US) | [Charlottesville Rust Meetup](https://www.meetup.com/charlottesville-rust-meetup/)
13+ * [**Crafting Interpreters in Rust Collaboratively**](https://www.meetup.com/charlottesville-rust-meetup/events/298368787/)
14+
15+ Sorted by:
16+ - Date
17+ - City (location)
18+ """
19+
620from test_events import get_test_events
721
8- print (get_test_events ())
22+ def main ():
23+ event_list = get_test_events ()
24+ sort_and_filter_events (event_list )
25+ for event in event_list :
26+ print (event .to_markdown_string ())
27+
28+
29+ def sort_and_filter_events (event_list ):
30+ # Sort Events by date and location.
31+ sort_events (event_list )
32+
33+ # Sort Events by Virtual/In-Person.
34+ sort_virtual (event_list )
35+
36+ # TODO Filter out Potential Spam Events.
37+ # TODO Filter out duplicates.
38+
39+
40+ def sort_events (event_list ):
41+ # Sorts event_list date and location.
42+ for i in range (len (event_list )):
43+ # Assigns a current event to be sorted and removes it from list.
44+ current_event = event_list [i ]
45+ event_list .remove (event_list [i ])
46+ #TODO put filter in here for dates not in current window.
47+ for j in range (len (event_list )):
48+ if current_event .date < event_list [j ].date :
49+ # If current event date is earlier than comparison, inserts back into list.
50+ event_list .insert (j , current_event )
51+ break
52+ elif current_event .date == event_list [j ].date :
53+ # If current event date is equal to comparison, compares location.
54+ if current_event .location [0 ] < event_list [j ].location [0 ]:
55+ # If current event location is alphabetically higher, inserts back into list.
56+ event_list .insert (j , current_event )
57+ break
58+ if current_event not in event_list :
59+ # If current event has not already been inserted, appends to the end of the list.
60+ event_list .append (current_event )
61+
62+
63+ def sort_virtual (event_list ):
64+ # Orders event_list into virtual, then in-person events.
65+ virtual_events = []
66+
67+ for event in event_list :
68+ # Filters and removes any virtual events from event_list.
69+ if event .virtual :
70+ virtual_events .append (event )
71+ event_list .remove (event )
72+
73+ for i in range (len (virtual_events )- 1 , - 1 , - 1 ):
74+ # Inserts virtual events back at the top of event_list.
75+ event_list .insert (0 , virtual_events [i ])
76+
77+
78+ def filter_potential_spam ():
79+ # Filters out potential spam events.
80+ pass
81+
82+
83+ if __name__ == "__main__" :
84+ main ()
0 commit comments