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

Update supported python versions #221

Merged
merged 3 commits into from
Mar 22, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
py_ver: ["3.7", "3.8", "3.9"]
py_ver: ["3.7", "3.8", "3.9", "3.10", "3.11"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
9 changes: 9 additions & 0 deletions hacksoc_org/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@
This module contains the Flask and Jinja boilerplate, HackSoc-specific customisations for pages,
and user convenience functionality for local testing.
"""
import sys

if sys.version_info < (3, 7):
print(
"Warning: you are using an older version of Python ("
+ str(sys.version)
+ ") that is not supported by HackSoc.org."
)


import flask
import yaml
from os import path


# flask app is constructed here
app = flask.Flask(__name__, static_folder=None, template_folder=None)
# these folders are defined in the Blueprint anyway
Expand Down
6 changes: 1 addition & 5 deletions hacksoc_org/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ def get_redirect_page_routes() -> Generator[str, None, None]:
Yields:
Generator[str, None, None]: URL routes
"""
yield from [
"/newsletter.html",
"/slack.html",
"/discord.html"
]
yield from ["/newsletter.html", "/slack.html", "/discord.html"]


def freeze():
Expand Down
9 changes: 5 additions & 4 deletions hacksoc_org/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_source(
filename = os.path.join(self.path, removesuffix(template, ".html.jinja2") + ".md")

if os.path.exists(filename):
with open(filename, encoding='utf-8') as fd:
with open(filename, encoding="utf-8") as fd:
metadata, markdown = frontmatter.parse(fd.read())
assert isinstance(metadata, dict)
source = """
Expand All @@ -74,8 +74,9 @@ def get_source(
else:
raise TemplateNotFound(filename)


class MarkdownNewsLoader(BaseLoader):
"""Finds news articles written in Markdown and wrangles them into a Jinja template
"""Finds news articles written in Markdown and wrangles them into a Jinja template
extending article.html.jinja2"""

def __init__(self, searchpath: str, prefix_allow: Optional[str] = None) -> None:
Expand Down Expand Up @@ -118,7 +119,7 @@ def get_source(

filename = os.path.join(self.searchpath, removesuffix(template, ".html.jinja2") + ".md")
if os.path.exists(filename):
with open(filename, encoding='utf-8') as fd:
with open(filename, encoding="utf-8") as fd:
metadata, content = frontmatter.parse(fd.read())
# NB: readlines() returns a list of lines WITH \n at the end

Expand All @@ -141,4 +142,4 @@ def get_source(
return (source, filename, None)
# TODO: add 3rd tuple argument for autoreloading
else:
raise TemplateNotFound(template)
raise TemplateNotFound(template)
2 changes: 1 addition & 1 deletion hacksoc_org/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def serve(basedir: str, port=5000):
print(f"Serving {basedir} at http://127.0.0.1:{port}/ ...")

handler = functools.partial(http.server.SimpleHTTPRequestHandler, directory=basedir)
server = http.server.HTTPServer(('localhost', port), RequestHandlerClass=handler)
server = http.server.HTTPServer(("localhost", port), RequestHandlerClass=handler)
server.serve_forever()