Skip to content

Commit 24c034e

Browse files
committed
format
1 parent a11cef7 commit 24c034e

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

utils/airtable.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
class AirtableManager:
77
def __init__(self, api_key: str, base_id: str, production: bool = False):
88
api = Api(api_key)
9-
self.events_table = api.table(base_id, "Events") if production else api.table(base_id, "Test Events")
10-
self.users_table = api.table(base_id, "Users") if production else api.table(base_id, "Test Users")
9+
self.events_table = (
10+
api.table(base_id, "Events")
11+
if production
12+
else api.table(base_id, "Test Events")
13+
)
14+
self.users_table = (
15+
api.table(base_id, "Users")
16+
if production
17+
else api.table(base_id, "Test Users")
18+
)
1119
print("Connected to Airtable")
1220

1321
def create_event(

utils/env.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def __init__(self):
4141
raise Exception("SENTRY_DSN is not set")
4242

4343
self.airtable = AirtableManager(
44-
api_key=self.airtable_api_key, base_id=self.airtable_base_id, production=self.environemnt == "production"
44+
api_key=self.airtable_api_key,
45+
base_id=self.airtable_base_id,
46+
production=self.environemnt == "production",
4547
)
4648

4749
self.mailer = Email(sender=google_username, password=google_password)
@@ -50,7 +52,7 @@ def __init__(self):
5052
"U054VC2KM9P", # Amber
5153
"U0409FSKU82", # Arpan
5254
"U01MPHKFZ7S", # Aarya
53-
"UDK5M9Y13", # Chris
55+
"UDK5M9Y13", # Chris
5456
"U06QST7V0J2", # Eesha
5557
]
5658

utils/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import re
66

77
client = WebClient(token=env.slack_bot_token)
8-
ZWSP = '\u200B'
8+
ZWSP = "\u200B"
9+
910

1011
def user_in_safehouse(user_id: str):
1112
sad_members = client.conversations_members(channel=env.slack_sad_channel)["members"]
@@ -85,7 +86,9 @@ def parse_elements_to_mrkdwn(elements):
8586
text = element["text"]
8687
if "style" in element:
8788
styles = element["style"]
88-
words = re.split(r'(\s+)', text) # Split by whitespace but keep the whitespace
89+
words = re.split(
90+
r"(\s+)", text
91+
) # Split by whitespace but keep the whitespace
8992
formatted_words = []
9093
for word in words:
9194
if word.strip(): # Only apply formatting to non-whitespace words
@@ -122,6 +125,7 @@ def parse_elements_to_mrkdwn(elements):
122125
mrkdwn += f"<!subteam^{element['usergroup_id']}>"
123126
return mrkdwn
124127

128+
125129
def rich_text_to_mrkdwn(data):
126130
mrkdwn = ""
127131
for block in data:
@@ -139,4 +143,4 @@ def rich_text_to_mrkdwn(data):
139143
# Recursively parse nested lists
140144
if "elements" in item:
141145
mrkdwn += rich_text_to_mrkdwn(item["elements"])
142-
return mrkdwn
146+
return mrkdwn

views/app_home.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get_home(user_id: str, client: WebClient):
4949
)
5050
formatted_time = f"<!date^{int(datetime.fromisoformat(event['fields']['End Time']).timestamp())}^Ends at {{time}}|{fallback_time}>"
5151
rich_text = json.loads(event["fields"]["Raw Description"])
52-
mrkdwn = rich_text_to_mrkdwn(rich_text['elements'])
52+
mrkdwn = rich_text_to_mrkdwn(rich_text["elements"])
5353
current_events_blocks.append(
5454
{
5555
"type": "section",
@@ -120,7 +120,7 @@ def get_home(user_id: str, client: WebClient):
120120
)
121121
formatted_time = f"<!date^{int(datetime.fromisoformat(event['fields']['Start Time']).timestamp())}^{{date_long_pretty}} at {{time}}|{fallback_time}>"
122122
rich_text = json.loads(event["fields"]["Raw Description"])
123-
mrkdwn = rich_text_to_mrkdwn(rich_text['elements'])
123+
mrkdwn = rich_text_to_mrkdwn(rich_text["elements"])
124124
upcoming_events_blocks.append(
125125
{
126126
"type": "section",

0 commit comments

Comments
 (0)