X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/ca8319931f449468918067367133ff25f9b19f30..0604bdd5f693da9f1c78f9d9fa2276f0c7b6c17b:/src/librarian/document.py?ds=inline diff --git a/src/librarian/document.py b/src/librarian/document.py new file mode 100644 index 0000000..1bd249d --- /dev/null +++ b/src/librarian/document.py @@ -0,0 +1,24 @@ +from lxml import etree +from .builders import get_builder_class +from .parser import parser +from . import dcparser + + +class WLDocument: + def __init__(self, tree=None, filename=None): + if filename is not None: + tree = etree.parse(filename, parser=parser) + self.tree = tree + tree.getroot().document = self + self.base_meta = dcparser.BookInfo({}, {}, validate_required=False) + + @property + def meta(self): + # Allow metadata of the master element as document meta. + #master = self.tree.getroot()[-1] + return self.tree.getroot().meta + return master.meta + + def build(self, builder_id, **kwargs): + return get_builder_class(builder_id)().build(self, **kwargs) +