Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made all code pep8 conformant #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions example_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Timetable
timetable_links = {
### NOTE THE ORDER OF NAMES IN DICT MUST STAY THE SAME! ###
# NOTE THE ORDER OF NAMES IN DICT MUST STAY THE SAME! ###
# Must USE _ UNDERSCORES, NO SPACES
"Name1": "",
"Name_Two": "",
Expand All @@ -23,14 +23,14 @@
combined_cal = ""

personal_cals = {
"Link": "Name1",
"Link": "Name_Two",
"Link": "Name",
"Link_Two": "Name_Two",
}

quote_url = "https://zenquotes.io/api/today"


menu_sheet = ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
menu_sheet = ""
menu_sheet = ""

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the change here, I think I'm missing something

# Set a testing date if you want the calendar to render a different date.
# NOTE this doesn't affect date display/percentage etc.
testing_date = False
testing_date = None
# testing_date = (2024,2,29)
10 changes: 6 additions & 4 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def get_ordinal_suffix(day: int) -> str:
Returns:
str: The ordinal suffix for the given day.
"""
return {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th') if day not in (11, 12, 13) else 'th'
if 11 <= day <= 13:
return 'th'
else:
return {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')


def getDateReadable() -> str:
"""
Expand All @@ -28,7 +32,6 @@ def getDateReadable() -> str:
"""
day_of_week = datetime.now(tz).strftime("%A")


day = int(datetime.now(tz).strftime("%d"))
ordinal_suffix = get_ordinal_suffix(day)

Expand Down Expand Up @@ -65,6 +68,7 @@ def getQuote() -> tuple[str, str]:

return quote, author


def decide_day_check() -> date:
"""
Helper function that decides what date to check for events.
Expand All @@ -76,6 +80,4 @@ def decide_day_check() -> date:
# If past 8pm, check tomorrow's events
if datetime.now(tz).hour >= 20:
check_date += timedelta(1)


return check_date
12 changes: 7 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json


##* WEB APP ##
# WEB APP #
app = Flask(__name__)
# app.config.from_object('config')

Expand All @@ -16,30 +16,32 @@ def home():

return render_template("index.html", quote=quote, author=author)


@app.route("/api/date")
def date():
return json.dumps({"date": helper.getDateReadable()})


@app.route("/api/cal")
def cal():
return parse_calendar.parse_all_calendars()

#! TESTING LINE
# TESTING LINE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be indented to the first level?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much of a muchness, lets have it indented then

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TESTING LINE
# ! TESTING LINE

with open("examplecal.json") as file:
data = json.load(file)
return data



@app.route("/api/menu")
def menu():
return parse_menu.main()

#! TESTING LINE
# TESTING LINE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the #! with the Better Comments VSC plugin to make important items stand out
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I'll do that in future

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TESTING LINE
# ! TESTING LINE

with open("examplemenu.json") as file:
data = json.load(file)
return data


@app.route("/api/quote")
def quote():
quote, author = helper.getQuote()
Expand All @@ -49,4 +51,4 @@ def quote():
# Run as flask app (locally only) for testing.
# Production level runs gunicorn (WSGI server)
if __name__ == "__main__":
app.run(debug=True)
app.run(debug=True)
Loading
Loading