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

Srcf #44

Merged
merged 1 commit into from
Feb 18, 2024
Merged

Srcf #44

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
15 changes: 15 additions & 0 deletions deploy/srcf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -eux
files="$(dirname $0)"
bindto="unix:web.sock"

export SERVER_NAME=jmft2.user.srcf.net
export SCRIPT_NAME=/pypew

. /home/jmft2/venvs/py38/bin/activate

cd "$(dirname "$files")"
exec gunicorn wsgi:app \
-w 4 \
--bind "$bindto" \
--log-level debug
18 changes: 9 additions & 9 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import typing
from abc import ABC, abstractmethod
from functools import cache
from functools import lru_cache
from pathlib import Path
from typing import List, Optional

Expand Down Expand Up @@ -349,7 +349,7 @@ def collects(self) -> List[str]:

# TODO primary or secondary?
@property
def introit_proper(self) -> str | None:
def introit_proper(self) -> Optional[str]:
return self.primary_feast.introit

@property
Expand All @@ -372,27 +372,27 @@ def gat_propers(self) -> List[str]:
return propers

@property
def offertory_proper(self) -> str | None:
def offertory_proper(self) -> Optional[str]:
return self.primary_feast.offertory

@property
def communion_proper(self) -> str | None:
def communion_proper(self) -> Optional[str]:
return self.primary_feast.communion

@property
def epistle_ref(self) -> str | None:
def epistle_ref(self) -> Optional[str]:
return self.primary_feast.epistle_ref

@property
def epistle(self) -> str | None:
def epistle(self) -> Optional[str]:
return self.primary_feast.epistle

@property
def gospel_ref(self) -> str | None:
def gospel_ref(self) -> Optional[str]:
return self.primary_feast.gospel_ref

@property
def gospel(self) -> str | None:
def gospel(self) -> Optional[str]:
return self.primary_feast.gospel

@property
Expand Down Expand Up @@ -478,7 +478,7 @@ def create_docx(self, path):
doc.save(path)


@cache
@lru_cache()
def _feast_from_yaml(slug: str) -> Feast:
with open((DATA_DIR / slug).with_suffix('.yaml')) as f:
info = yaml.safe_load(f)
Expand Down
2 changes: 1 addition & 1 deletion pypew.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def clear_trailing_slashes():
return app


def main(argv: Sequence[str] | None = None) -> None:
def main(argv: Optional[Sequence[str]] = None) -> None:
"""
Start PyPew.
"""
Expand Down
13 changes: 6 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ attrs~=21.2.0
cattrs~=22.1.0
docxtpl~=0.15.2
dotmap~=1.3.26
Flask~=1.1.2
Flask-WTF
Flask~=2.2.2
Flask-WTF~=1.2.1
gunicorn~=20.1.0
Jinja2~=2.11.3
markupsafe==2.0.1
Jinja2~=3.1.2
markupsafe==2.1.1
parameterized~=0.8.1
python-dateutil~=2.8.2
python-docx~=0.8.11
python-dotenv~=0.19.2
python-dotenv~=0.21.0
python-slugify~=7.0.0
PyYAML~=6.0
WTForms~=3.0.1
setuptools~=50.3.2
openpyxl==3.0.9
pandas==2.1.0
Werkzeug~=1.0.1
Werkzeug~=2.2.2
7 changes: 7 additions & 0 deletions tests/test_pypew.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def test_english_ordinals(self, supplied_date, expected_string):
self.assertEqual(english_date(supplied_date), expected_string)


try:
import pandas as pd
except ImportError:
pd = None


@unittest.skipIf(pd is None, "Pandas not available")
class TestModels(unittest.TestCase):
def test_neh_lookup(self):
music = Music.get_neh_hymn_by_ref('NEH: 1a')
Expand Down
5 changes: 3 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pathlib import Path
from typing import Optional

import pandas as pd
from appdirs import AppDirs


Expand All @@ -31,7 +30,9 @@ def str2date(s: Optional[str]) -> date:

@lru_cache()
def get_neh_df():
if pd is None:
try:
import pandas as pd
except ImportError:
raise NoPandasError(
'Pandas not available, can\'t load hymn information'
)
Expand Down
2 changes: 1 addition & 1 deletion views/feast_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@ def feast_docx_view(slug):
temp_docx = os.path.join(cache_dir, f"feast_{str(uuid.uuid4())}.docx")
feast.create_docx(path=temp_docx)
return send_file(
temp_docx, as_attachment=True, attachment_filename=filename
temp_docx, as_attachment=True, download_name=filename
)
2 changes: 1 addition & 1 deletion views/pew_sheet_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ def pew_sheet_docx_view():
temp_docx = os.path.join(cache_dir, f"pew_sheet_{str(uuid.uuid4())}.docx")
service.create_docx(temp_docx)
return send_file(
temp_docx, as_attachment=True, attachment_filename=filename
temp_docx, as_attachment=True, download_name=filename
)
Loading