golden hour
/opt/imunify360/venv/lib/python3.11/site-packages/lxml
⬆️ Go Up
Upload
File/Folder
Size
Actions
ElementInclude.py
8.36 KB
Del
OK
__init__.py
575 B
Del
OK
__pycache__
-
Del
OK
_elementpath.cpython-311-x86_64-linux-gnu.so
419.42 KB
Del
OK
_elementpath.py
10.49 KB
Del
OK
apihelpers.pxi
62.94 KB
Del
OK
builder.cpython-311-x86_64-linux-gnu.so
222.23 KB
Del
OK
builder.py
7.96 KB
Del
OK
classlookup.pxi
21.94 KB
Del
OK
cleanup.pxi
8.26 KB
Del
OK
cssselect.py
3.29 KB
Del
OK
debug.pxi
3.21 KB
Del
OK
docloader.pxi
5.65 KB
Del
OK
doctestcompare.py
17.91 KB
Del
OK
dtd.pxi
14.86 KB
Del
OK
etree.cpython-311-x86_64-linux-gnu.so
8.46 MB
Del
OK
etree.h
8.37 KB
Del
OK
etree.pyx
129.31 KB
Del
OK
etree_api.h
17.06 KB
Del
OK
extensions.pxi
32.46 KB
Del
OK
html
-
Del
OK
includes
-
Del
OK
isoschematron
-
Del
OK
iterparse.pxi
16.22 KB
Del
OK
lxml.etree.h
8.37 KB
Del
OK
lxml.etree_api.h
17.06 KB
Del
OK
nsclasses.pxi
8.93 KB
Del
OK
objectify.cpython-311-x86_64-linux-gnu.so
4.25 MB
Del
OK
objectify.pyx
75.29 KB
Del
OK
objectpath.pxi
11.21 KB
Del
OK
parser.pxi
76.41 KB
Del
OK
parsertarget.pxi
6.7 KB
Del
OK
proxy.pxi
23.01 KB
Del
OK
public-api.pxi
6.5 KB
Del
OK
pyclasslookup.py
92 B
Del
OK
readonlytree.pxi
18.6 KB
Del
OK
relaxng.pxi
5.94 KB
Del
OK
sax.cpython-311-x86_64-linux-gnu.so
366.73 KB
Del
OK
sax.py
9.18 KB
Del
OK
saxparser.pxi
31.78 KB
Del
OK
schematron.pxi
5.65 KB
Del
OK
serializer.pxi
66.41 KB
Del
OK
usedoctest.py
230 B
Del
OK
xinclude.pxi
2.4 KB
Del
OK
xmlerror.pxi
48.37 KB
Del
OK
xmlid.pxi
5.92 KB
Del
OK
xmlschema.pxi
7.89 KB
Del
OK
xpath.pxi
19.11 KB
Del
OK
xslt.pxi
35.83 KB
Del
OK
xsltext.pxi
10.83 KB
Del
OK
Edit: relaxng.pxi
# support for RelaxNG validation from lxml.includes cimport relaxng cdef object _rnc2rng try: import rnc2rng as _rnc2rng except ImportError: _rnc2rng = None cdef int _require_rnc2rng() except -1: if _rnc2rng is None: raise RelaxNGParseError( 'compact syntax not supported (please install rnc2rng)') return 0 cdef class RelaxNGError(LxmlError): """Base class for RelaxNG errors. """ cdef class RelaxNGParseError(RelaxNGError): """Error while parsing an XML document as RelaxNG. """ cdef class RelaxNGValidateError(RelaxNGError): """Error while validating an XML document with a RelaxNG schema. """ ################################################################################ # RelaxNG cdef class RelaxNG(_Validator): u"""RelaxNG(self, etree=None, file=None) Turn a document into a Relax NG validator. Either pass a schema as Element or ElementTree, or pass a file or filename through the ``file`` keyword argument. """ cdef relaxng.xmlRelaxNG* _c_schema def __cinit__(self): self._c_schema = NULL def __init__(self, etree=None, *, file=None): cdef _Document doc cdef _Element root_node cdef xmlDoc* fake_c_doc = NULL cdef relaxng.xmlRelaxNGParserCtxt* parser_ctxt = NULL _Validator.__init__(self) if etree is not None: doc = _documentOrRaise(etree) root_node = _rootNodeOrRaise(etree) fake_c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node) parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(fake_c_doc) elif file is not None: if _isString(file): if file[-4:].lower() == '.rnc': _require_rnc2rng() rng_data_utf8 = _utf8(_rnc2rng.dumps(_rnc2rng.load(file))) doc = _parseMemoryDocument(rng_data_utf8, parser=None, url=file) parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc) else: doc = None filename = _encodeFilename(file) with self._error_log: orig_loader = _register_document_loader() parser_ctxt = relaxng.xmlRelaxNGNewParserCtxt(_cstr(filename)) _reset_document_loader(orig_loader) elif (_getFilenameForFile(file) or '')[-4:].lower() == '.rnc': _require_rnc2rng() rng_data_utf8 = _utf8(_rnc2rng.dumps(_rnc2rng.load(file))) doc = _parseMemoryDocument( rng_data_utf8, parser=None, url=_getFilenameForFile(file)) parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc) else: doc = _parseDocument(file, parser=None, base_url=None) parser_ctxt = relaxng.xmlRelaxNGNewDocParserCtxt(doc._c_doc) else: raise RelaxNGParseError, u"No tree or file given" if parser_ctxt is NULL: if fake_c_doc is not NULL: _destroyFakeDoc(doc._c_doc, fake_c_doc) raise RelaxNGParseError( self._error_log._buildExceptionMessage( u"Document is not parsable as Relax NG"), self._error_log) relaxng.xmlRelaxNGSetParserStructuredErrors( parser_ctxt, _receiveError, <void*>self._error_log) _connectGenericErrorLog(self._error_log, xmlerror.XML_FROM_RELAXNGP) self._c_schema = relaxng.xmlRelaxNGParse(parser_ctxt) _connectGenericErrorLog(None) relaxng.xmlRelaxNGFreeParserCtxt(parser_ctxt) if self._c_schema is NULL: if fake_c_doc is not NULL: _destroyFakeDoc(doc._c_doc, fake_c_doc) raise RelaxNGParseError( self._error_log._buildExceptionMessage( u"Document is not valid Relax NG"), self._error_log) if fake_c_doc is not NULL: _destroyFakeDoc(doc._c_doc, fake_c_doc) def __dealloc__(self): relaxng.xmlRelaxNGFree(self._c_schema) def __call__(self, etree): u"""__call__(self, etree) Validate doc using Relax NG. Returns true if document is valid, false if not.""" cdef _Document doc cdef _Element root_node cdef xmlDoc* c_doc cdef relaxng.xmlRelaxNGValidCtxt* valid_ctxt cdef int ret assert self._c_schema is not NULL, "RelaxNG instance not initialised" doc = _documentOrRaise(etree) root_node = _rootNodeOrRaise(etree) valid_ctxt = relaxng.xmlRelaxNGNewValidCtxt(self._c_schema) if valid_ctxt is NULL: raise MemoryError() try: self._error_log.clear() relaxng.xmlRelaxNGSetValidStructuredErrors( valid_ctxt, _receiveError, <void*>self._error_log) _connectGenericErrorLog(self._error_log, xmlerror.XML_FROM_RELAXNGV) c_doc = _fakeRootDoc(doc._c_doc, root_node._c_node) with nogil: ret = relaxng.xmlRelaxNGValidateDoc(valid_ctxt, c_doc) _destroyFakeDoc(doc._c_doc, c_doc) finally: _connectGenericErrorLog(None) relaxng.xmlRelaxNGFreeValidCtxt(valid_ctxt) if ret == -1: raise RelaxNGValidateError( u"Internal error in Relax NG validation", self._error_log) if ret == 0: return True else: return False @classmethod def from_rnc_string(cls, src, base_url=None): """Parse a RelaxNG schema in compact syntax from a text string Requires the rnc2rng package to be installed. Passing the source URL or file path of the source as 'base_url' will enable resolving resource references relative to the source. """ _require_rnc2rng() rng_str = utf8(_rnc2rng.dumps(_rnc2rng.loads(src))) return cls(_parseMemoryDocument(rng_str, parser=None, url=base_url))
Save