refactor: Extract templating to model module

This commit is contained in:
Marty Oehme 2023-08-31 21:40:38 +02:00
parent e56f014136
commit 5450776eb2
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
4 changed files with 20 additions and 15 deletions

View file

@ -8,7 +8,8 @@ import papis.strings
from papis.document import Document from papis.document import Document
from papis_extract import extractor, exporter from papis_extract import extractor, exporter
from papis_extract.annotation_data import AnnotatedDocument, Markdown from papis_extract.annotation_data import AnnotatedDocument
from papis_extract.model.templating import Markdown
logger = papis.logging.get_logger(__name__) logger = papis.logging.get_logger(__name__)

View file

@ -85,16 +85,3 @@ class AnnotatedDocument:
document: Document document: Document
annotations: list[Annotation] annotations: list[Annotation]
@dataclass
class Templating(Protocol):
string: str
@dataclass
class Markdown:
string: str = (
"{{#tag}}#{{tag}}\n{{/tag}}"
"{{#quote}}> {{quote}}{{/quote}} {{#page}}[p. {{page}}]{{/page}}\n"
"{{#note}} NOTE: {{note}}{{/note}}"
)

View file

@ -7,7 +7,8 @@ import papis.git
import papis.config import papis.config
import Levenshtein import Levenshtein
from papis_extract.annotation_data import AnnotatedDocument, Annotation, Templating from papis_extract.annotation_data import AnnotatedDocument
from papis_extract.model.templating import Templating
logger = papis.logging.get_logger(__name__) logger = papis.logging.get_logger(__name__)

View file

@ -0,0 +1,16 @@
from dataclasses import dataclass
from typing import Protocol
@dataclass
class Templating(Protocol):
string: str
@dataclass
class Markdown:
string: str = (
"{{#tag}}#{{tag}}\n{{/tag}}"
"{{#quote}}> {{quote}}{{/quote}} {{#page}}[p. {{page}}]{{/page}}\n"
"{{#note}} NOTE: {{note}}{{/note}}"
)