3 \.@sdZddlmZddlmZmZddlmZmZm Z m Z m Z efddZ efddZ d gZd Zernd d lZd d lZd d lZejj rd ejkrejd jd Z[dZejd ddkrejjerejjejd ZgfddZejd ddkrddZnddZ[d S)aSimple API for XML (SAX) implementation for Python. This module provides an implementation of the SAX 2 interface; information about the Java version of the interface can be found at http://www.megginson.com/SAX/. The Python version of the interface is documented at <...>. This package contains the following modules: handler -- Base classes and constants which define the SAX 2 API for the 'client-side' of SAX for Python. saxutils -- Implementation of the convenience classes commonly used to work with SAX. xmlreader -- Base classes and constants which define the SAX 2 API for the parsers used with SAX for Python. expatreader -- Driver that allows use of the Expat parser with SAX. ) InputSource)ContentHandler ErrorHandler) SAXExceptionSAXNotRecognizedExceptionSAXParseExceptionSAXNotSupportedExceptionSAXReaderNotAvailablecCs(t}|j||j||j|dS)N) make_parsersetContentHandlersetErrorHandlerparse)sourcehandler errorHandlerparserr(/usr/lib64/python3.6/xml/sax/__init__.pyr s  r cCspddl}|dkrt}t}|j||j|t}t|trR|j|j |n|j |j ||j |dS)N) iorr r r r isinstancestrZsetCharacterStreamStringIOZ setByteStreamBytesIOr )stringrrrrZinpsrcrrr parseString#s   rzxml.sax.expatreaderrNZ PY_SAX_PARSER,zpython.xml.sax.parserjavacCsrxb|tD]V}yt|Stk rL}zddl}||jkr<WYdd}~Xq tk r^Yq Xq WtdddS)a&Creates and returns a SAX parser. Creates the first parser it is able to instantiate of the ones given in the list created by doing parser_list + default_parser_list. The lists must contain the names of Python modules containing both a SAX parser and a create_parser function.rNzNo parsers found)default_parser_list_create_parser ImportErrorsysmodulesr )Z parser_list parser_nameer"rrrr Fs  r cCs$ddlm}|j|dt}|jS)Nr)imp)Zorg.python.corer&Z importNameglobals create_parser)r$r& drv_modulerrrr as r cCst|iidg}|jS)Nr() __import__r()r$r)rrrr gs)__doc__Z xmlreaderrrrr _exceptionsrrrrr r rr_falseZxml.sax.expatreaderZxmlosr"flagsignore_environmentenvironsplitZ_keyplatformregistryZ containsKeyZ getPropertyr r rrrrs*