From: Jan Szejko Date: Wed, 1 Feb 2017 13:16:25 +0000 (+0100) Subject: move validation outside librarian X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/30a74b436b8a81adbdbeea5a9b2f99dfc2e4949f?ds=sidebyside;hp=dc310ddf91e20a927cd1fc1db72e1c8cd803756d move validation outside librarian --- diff --git a/librarian/document.py b/librarian/document.py index a4a8593..462b1ba 100755 --- a/librarian/document.py +++ b/librarian/document.py @@ -32,20 +32,11 @@ class Document(object): tree = etree.parse(StringIO(etree.tostring(root_elem)), parser) tree.xinclude() self.edoc = tree - root_elem = self.edoc.getroot() else: raise ValueError("Invalid root element. Found '%s', should be '%s'" % ( root_elem.tag, SSTNS('section'))) else: raise ValueError("Invalid class of root element. Use librarian.parser.SSTParser.") - if len(root_elem) < 1 or root_elem[0].tag != SSTNS('metadata'): - raise ValueError("The first tag in section should be metadata") - if len(root_elem) < 2 or root_elem[1].tag != SSTNS('header'): - raise ValueError("The first tag after metadata should be header") - header = root_elem[1] - if not getattr(header, 'text', None) or not header.text.strip(): - raise ValueError( - "The first header should contain the title in plain text (no links, emphasis etc.) and cannot be empty") @classmethod def from_string(cls, xml, *args, **kwargs):