Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python3..../xml/etree
File: ElementTree.py
def handler(tag, attrib_in, event=event_name, append=append,
[1500] Fix | Delete
start=self._start):
[1501] Fix | Delete
append((event, start(tag, attrib_in)))
[1502] Fix | Delete
parser.StartElementHandler = handler
[1503] Fix | Delete
elif event_name == "end":
[1504] Fix | Delete
def handler(tag, event=event_name, append=append,
[1505] Fix | Delete
end=self._end):
[1506] Fix | Delete
append((event, end(tag)))
[1507] Fix | Delete
parser.EndElementHandler = handler
[1508] Fix | Delete
elif event_name == "start-ns":
[1509] Fix | Delete
def handler(prefix, uri, event=event_name, append=append):
[1510] Fix | Delete
append((event, (prefix or "", uri or "")))
[1511] Fix | Delete
parser.StartNamespaceDeclHandler = handler
[1512] Fix | Delete
elif event_name == "end-ns":
[1513] Fix | Delete
def handler(prefix, event=event_name, append=append):
[1514] Fix | Delete
append((event, None))
[1515] Fix | Delete
parser.EndNamespaceDeclHandler = handler
[1516] Fix | Delete
else:
[1517] Fix | Delete
raise ValueError("unknown event %r" % event_name)
[1518] Fix | Delete
[1519] Fix | Delete
def _raiseerror(self, value):
[1520] Fix | Delete
err = ParseError(value)
[1521] Fix | Delete
err.code = value.code
[1522] Fix | Delete
err.position = value.lineno, value.offset
[1523] Fix | Delete
raise err
[1524] Fix | Delete
[1525] Fix | Delete
def _fixname(self, key):
[1526] Fix | Delete
# expand qname, and convert name string to ascii, if possible
[1527] Fix | Delete
try:
[1528] Fix | Delete
name = self._names[key]
[1529] Fix | Delete
except KeyError:
[1530] Fix | Delete
name = key
[1531] Fix | Delete
if "}" in name:
[1532] Fix | Delete
name = "{" + name
[1533] Fix | Delete
self._names[key] = name
[1534] Fix | Delete
return name
[1535] Fix | Delete
[1536] Fix | Delete
def _start(self, tag, attr_list):
[1537] Fix | Delete
# Handler for expat's StartElementHandler. Since ordered_attributes
[1538] Fix | Delete
# is set, the attributes are reported as a list of alternating
[1539] Fix | Delete
# attribute name,value.
[1540] Fix | Delete
fixname = self._fixname
[1541] Fix | Delete
tag = fixname(tag)
[1542] Fix | Delete
attrib = {}
[1543] Fix | Delete
if attr_list:
[1544] Fix | Delete
for i in range(0, len(attr_list), 2):
[1545] Fix | Delete
attrib[fixname(attr_list[i])] = attr_list[i+1]
[1546] Fix | Delete
return self.target.start(tag, attrib)
[1547] Fix | Delete
[1548] Fix | Delete
def _end(self, tag):
[1549] Fix | Delete
return self.target.end(self._fixname(tag))
[1550] Fix | Delete
[1551] Fix | Delete
def _default(self, text):
[1552] Fix | Delete
prefix = text[:1]
[1553] Fix | Delete
if prefix == "&":
[1554] Fix | Delete
# deal with undefined entities
[1555] Fix | Delete
try:
[1556] Fix | Delete
data_handler = self.target.data
[1557] Fix | Delete
except AttributeError:
[1558] Fix | Delete
return
[1559] Fix | Delete
try:
[1560] Fix | Delete
data_handler(self.entity[text[1:-1]])
[1561] Fix | Delete
except KeyError:
[1562] Fix | Delete
from xml.parsers import expat
[1563] Fix | Delete
err = expat.error(
[1564] Fix | Delete
"undefined entity %s: line %d, column %d" %
[1565] Fix | Delete
(text, self.parser.ErrorLineNumber,
[1566] Fix | Delete
self.parser.ErrorColumnNumber)
[1567] Fix | Delete
)
[1568] Fix | Delete
err.code = 11 # XML_ERROR_UNDEFINED_ENTITY
[1569] Fix | Delete
err.lineno = self.parser.ErrorLineNumber
[1570] Fix | Delete
err.offset = self.parser.ErrorColumnNumber
[1571] Fix | Delete
raise err
[1572] Fix | Delete
elif prefix == "<" and text[:9] == "<!DOCTYPE":
[1573] Fix | Delete
self._doctype = [] # inside a doctype declaration
[1574] Fix | Delete
elif self._doctype is not None:
[1575] Fix | Delete
# parse doctype contents
[1576] Fix | Delete
if prefix == ">":
[1577] Fix | Delete
self._doctype = None
[1578] Fix | Delete
return
[1579] Fix | Delete
text = text.strip()
[1580] Fix | Delete
if not text:
[1581] Fix | Delete
return
[1582] Fix | Delete
self._doctype.append(text)
[1583] Fix | Delete
n = len(self._doctype)
[1584] Fix | Delete
if n > 2:
[1585] Fix | Delete
type = self._doctype[1]
[1586] Fix | Delete
if type == "PUBLIC" and n == 4:
[1587] Fix | Delete
name, type, pubid, system = self._doctype
[1588] Fix | Delete
if pubid:
[1589] Fix | Delete
pubid = pubid[1:-1]
[1590] Fix | Delete
elif type == "SYSTEM" and n == 3:
[1591] Fix | Delete
name, type, system = self._doctype
[1592] Fix | Delete
pubid = None
[1593] Fix | Delete
else:
[1594] Fix | Delete
return
[1595] Fix | Delete
if hasattr(self.target, "doctype"):
[1596] Fix | Delete
self.target.doctype(name, pubid, system[1:-1])
[1597] Fix | Delete
elif self.doctype != self._XMLParser__doctype:
[1598] Fix | Delete
# warn about deprecated call
[1599] Fix | Delete
self._XMLParser__doctype(name, pubid, system[1:-1])
[1600] Fix | Delete
self.doctype(name, pubid, system[1:-1])
[1601] Fix | Delete
self._doctype = None
[1602] Fix | Delete
[1603] Fix | Delete
def doctype(self, name, pubid, system):
[1604] Fix | Delete
"""(Deprecated) Handle doctype declaration
[1605] Fix | Delete
[1606] Fix | Delete
*name* is the Doctype name, *pubid* is the public identifier,
[1607] Fix | Delete
and *system* is the system identifier.
[1608] Fix | Delete
[1609] Fix | Delete
"""
[1610] Fix | Delete
warnings.warn(
[1611] Fix | Delete
"This method of XMLParser is deprecated. Define doctype() "
[1612] Fix | Delete
"method on the TreeBuilder target.",
[1613] Fix | Delete
DeprecationWarning,
[1614] Fix | Delete
)
[1615] Fix | Delete
[1616] Fix | Delete
# sentinel, if doctype is redefined in a subclass
[1617] Fix | Delete
__doctype = doctype
[1618] Fix | Delete
[1619] Fix | Delete
def feed(self, data):
[1620] Fix | Delete
"""Feed encoded data to parser."""
[1621] Fix | Delete
try:
[1622] Fix | Delete
self.parser.Parse(data, 0)
[1623] Fix | Delete
except self._error as v:
[1624] Fix | Delete
self._raiseerror(v)
[1625] Fix | Delete
[1626] Fix | Delete
def close(self):
[1627] Fix | Delete
"""Finish feeding data to parser and return element structure."""
[1628] Fix | Delete
try:
[1629] Fix | Delete
self.parser.Parse("", 1) # end of data
[1630] Fix | Delete
except self._error as v:
[1631] Fix | Delete
self._raiseerror(v)
[1632] Fix | Delete
try:
[1633] Fix | Delete
close_handler = self.target.close
[1634] Fix | Delete
except AttributeError:
[1635] Fix | Delete
pass
[1636] Fix | Delete
else:
[1637] Fix | Delete
return close_handler()
[1638] Fix | Delete
finally:
[1639] Fix | Delete
# get rid of circular references
[1640] Fix | Delete
del self.parser, self._parser
[1641] Fix | Delete
del self.target, self._target
[1642] Fix | Delete
[1643] Fix | Delete
[1644] Fix | Delete
# Import the C accelerators
[1645] Fix | Delete
try:
[1646] Fix | Delete
# Element is going to be shadowed by the C implementation. We need to keep
[1647] Fix | Delete
# the Python version of it accessible for some "creative" by external code
[1648] Fix | Delete
# (see tests)
[1649] Fix | Delete
_Element_Py = Element
[1650] Fix | Delete
[1651] Fix | Delete
# Element, SubElement, ParseError, TreeBuilder, XMLParser
[1652] Fix | Delete
from _elementtree import *
[1653] Fix | Delete
except ImportError:
[1654] Fix | Delete
pass
[1655] Fix | Delete
[1656] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function