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

change karp backend version #37

Merged
merged 8 commits into from
Feb 19, 2025
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ snapshot-update:
### === project targets below this line ===

serve-dev:
${INVENV} watchfiles "gunicorn --chdir fsvreader --bind 'localhost:8000' fsvreader.views:app" ${PROJECT_SRC}
${INVENV} fastapi dev fsvreader/main.py
12 changes: 12 additions & 0 deletions fsvreader/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pydantic import BaseModel
from pydantic_settings import BaseSettings


class AppSettings(BaseModel):
base_url: str | None = None
root_path: str = ""
template_directory: str = "templates"


class Settings(BaseSettings):
app: AppSettings = AppSettings()
6 changes: 6 additions & 0 deletions fsvreader/deps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import karp_api_client
from fastapi import Request


def get_karp_client(request: Request) -> karp_api_client.Client:
return request.app.state._karp_client
27 changes: 27 additions & 0 deletions fsvreader/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class MissingError(Exception):
"""Raised when something is missing."""

def __init__(self, *, title: str, header: str, message: str) -> None:
self.title = title
self.header = header
self.message = message


class UnknownDirError(MissingError):
"""Raised when an dir is missing."""

def __init__(self, *, dir: str) -> None:
super().__init__(
title="Okänd mapp", header="Mapp saknas", message=f"Mappen '{dir}' saknas"
)


class UnknownFileError(MissingError):
"""Raised when a file is missing."""

def __init__(self, *, dir: str, file: str) -> None:
super().__init__(
title="Okänd fil",
header="Fil saknas",
message=f"Filen '{file}' saknas i mappen '{dir}'",
)
5 changes: 5 additions & 0 deletions fsvreader/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from fsvreader import config, server

settings = config.Settings()

app = server.create_server(settings=settings)
106 changes: 106 additions & 0 deletions fsvreader/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from typing import TypedDict


class Text(TypedDict):
title: str
commentary: str


class Metadata(TypedDict):
title: str
texts: dict[str, Text]


METADATA: dict[str, Metadata] = {
"aldre_lagar": {
"title": "Äldre lagar",
"texts": {
"SkL.html": {
"title": "Skånelagen, enligt Holm B 76",
"commentary": "txt 1203-12 / ms 1300-25",
},
"AVgL.html": {
"title": "Äldre Västgötalagen, enligt Holm B 59",
"commentary": "txt ca 1220 / ms ca 1280",
},
"GL.html": {
"title": "Gutalagen, enligt Holm B 64",
"commentary": "ms ca 1350",
},
"OgL.html": {
"title": "Östgötalagen, enligt Holm B 50",
"commentary": "txt 1280–90 / ms ca 1350",
},
"YVgL.html": {
"title": "Yngre Västgötalagen, enligt Holm B 58",
"commentary": "txt ca 1280 / ms ca 1350",
},
"DL.html": {
"title": "Äldre Västmannalagen / Dalalagen, enligt Holm B 54",
"commentary": "txt ca 1280",
},
"UL.html": {
"title": "Upplandslagen, enligt Ups B 12",
"commentary": "ms ca 1350",
},
"HL.html": {
"title": "Hälsingelagen, enligt Ups B 49",
"commentary": "ms 1350–1400",
},
"VmL.html": {
"title": "Yngre Västmannalagen enligt Holm B 57",
"commentary": "txt 1300–25 / ms 1300-50",
},
"BjR.html": {
"title": "Bjärköarätten, enligt Holm B 58",
"commentary": "ms ca 1350",
},
"SmL_Kb.html": {
"title": "Smålandslagens Kyrkobalk",
"commentary": "ms 1350–1400",
},
"SdmL.html": {
"title": "Södermannalagen, enligt Holm B 53",
"commentary": "txt 1327 / ms ca 1330",
},
"SdmL-A.html": {
"title": "Södermannalagen, enligt Holm B 53 [Utdrag?]",
"commentary": "txt 1327 / ms ca 1330",
},
"MEL.html": {
"title": "Magnus Erikssons Landslag, enligt AM 51",
"commentary": "txt ca 1350 / ms ca 1350",
},
"MESt.html": {
"title": "Magnus Erikssons Stadslag, enligt Holm B 154",
"commentary": "txt 1357 / ms 1400–50",
},
},
},
"aldre_profan": {
"title": "Äldre övrigt profan prosa",
"texts": {
"Ks.html": {
"title": "Kungastyrelsen, efter Bureus utgåva (förkommen handskrift)",
"commentary": "Bureus 1632",
}
},
},
"aldre_religios": {
"title": "Äldre religiös prosa",
"texts": {
"Legendarium-B.html": {
"title": "Fornsvenska legendariet, enligt Ups C 528",
"commentary": "txt 1276–1308 / ms 1400-50",
},
"Moses-B.html": {
"title": "Pentateuchparafrasen, enligt Holm A1",
"commentary": "txt 1300–50 / ms 1526",
},
"Birgitta_aut-B.html": {
"title": "Birgittas uppenbarelser, fsv original",
"commentary": "1340–1370",
},
},
},
}
Loading
Loading