SILENT KILLERPanel

Current Path: > > opt > cloudlinux > venv > lib64 > python3.11 > site-packages > > lxml


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/cloudlinux/venv/lib64/python3.11/site-packages//lxml

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
html Directory - -
includes Directory - -
isoschematron Directory - -
ElementInclude.py File 8560 bytes April 17 2025 13:10:58.
__init__.py File 575 bytes April 17 2025 13:10:58.
_elementpath.cpython-311-x86_64-linux-gnu.so File 230680 bytes April 17 2025 13:11:30.
_elementpath.py File 10742 bytes April 17 2025 13:10:58.
apihelpers.pxi File 64452 bytes April 17 2025 13:10:58.
builder.cpython-311-x86_64-linux-gnu.so File 123624 bytes April 17 2025 13:11:30.
builder.py File 8147 bytes April 17 2025 13:10:58.
classlookup.pxi File 22462 bytes April 17 2025 13:10:58.
cleanup.pxi File 8458 bytes April 17 2025 13:10:58.
cssselect.py File 3366 bytes April 17 2025 13:10:58.
debug.pxi File 3283 bytes April 17 2025 13:10:58.
docloader.pxi File 5783 bytes April 17 2025 13:10:58.
doctestcompare.py File 18339 bytes April 17 2025 13:10:58.
dtd.pxi File 15219 bytes April 17 2025 13:10:58.
etree.cpython-311-x86_64-linux-gnu.so File 5797240 bytes April 17 2025 13:11:30.
etree.h File 8575 bytes April 17 2025 13:10:58.
etree.pyx File 132415 bytes April 17 2025 13:10:58.
etree_api.h File 17467 bytes April 17 2025 13:10:58.
extensions.pxi File 33241 bytes April 17 2025 13:10:58.
iterparse.pxi File 16607 bytes April 17 2025 13:10:58.
lxml.etree.h File 8575 bytes April 17 2025 13:10:58.
lxml.etree_api.h File 17472 bytes April 17 2025 13:10:58.
nsclasses.pxi File 9145 bytes April 17 2025 13:10:58.
objectify.cpython-311-x86_64-linux-gnu.so File 3351520 bytes April 17 2025 13:11:30.
objectify.pyx File 77100 bytes April 17 2025 13:10:58.
objectpath.pxi File 11479 bytes April 17 2025 13:10:58.
parser.pxi File 78247 bytes April 17 2025 13:10:58.
parsertarget.pxi File 6859 bytes April 17 2025 13:10:58.
proxy.pxi File 23562 bytes April 17 2025 13:10:58.
public-api.pxi File 6660 bytes April 17 2025 13:10:58.
pyclasslookup.py File 92 bytes April 17 2025 13:10:58.
readonlytree.pxi File 19048 bytes April 17 2025 13:10:58.
relaxng.pxi File 6085 bytes April 17 2025 13:10:58.
sax.cpython-311-x86_64-linux-gnu.so File 201680 bytes April 17 2025 13:11:30.
sax.py File 9396 bytes April 17 2025 13:10:58.
saxparser.pxi File 32542 bytes April 17 2025 13:10:58.
schematron.pxi File 5782 bytes April 17 2025 13:10:58.
serializer.pxi File 67999 bytes April 17 2025 13:10:58.
usedoctest.py File 230 bytes April 17 2025 13:10:58.
xinclude.pxi File 2460 bytes April 17 2025 13:10:58.
xmlerror.pxi File 49531 bytes April 17 2025 13:10:58.
xmlid.pxi File 6064 bytes April 17 2025 13:10:58.
xmlschema.pxi File 8079 bytes April 17 2025 13:10:58.
xpath.pxi File 19571 bytes April 17 2025 13:10:58.
xslt.pxi File 36694 bytes April 17 2025 13:10:58.
xsltext.pxi File 11085 bytes April 17 2025 13:10:58.

Reading File: //opt/cloudlinux/venv/lib64/python3.11/site-packages//lxml/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))

SILENT KILLER Tool