Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python2..../xml/etree
File: ElementTree.py
try:
[1500] Fix | Delete
self._parser.buffer_text = 1
[1501] Fix | Delete
except AttributeError:
[1502] Fix | Delete
pass
[1503] Fix | Delete
# use new-style attribute handling, if supported
[1504] Fix | Delete
try:
[1505] Fix | Delete
self._parser.ordered_attributes = 1
[1506] Fix | Delete
self._parser.specified_attributes = 1
[1507] Fix | Delete
parser.StartElementHandler = self._start_list
[1508] Fix | Delete
except AttributeError:
[1509] Fix | Delete
pass
[1510] Fix | Delete
self._doctype = None
[1511] Fix | Delete
self.entity = {}
[1512] Fix | Delete
try:
[1513] Fix | Delete
self.version = "Expat %d.%d.%d" % expat.version_info
[1514] Fix | Delete
except AttributeError:
[1515] Fix | Delete
pass # unknown
[1516] Fix | Delete
[1517] Fix | Delete
def _raiseerror(self, value):
[1518] Fix | Delete
err = ParseError(value)
[1519] Fix | Delete
err.code = value.code
[1520] Fix | Delete
err.position = value.lineno, value.offset
[1521] Fix | Delete
raise err
[1522] Fix | Delete
[1523] Fix | Delete
def _fixtext(self, text):
[1524] Fix | Delete
# convert text string to ascii, if possible
[1525] Fix | Delete
try:
[1526] Fix | Delete
return text.encode("ascii")
[1527] Fix | Delete
except UnicodeError:
[1528] Fix | Delete
return text
[1529] Fix | Delete
[1530] Fix | Delete
def _fixname(self, key):
[1531] Fix | Delete
# expand qname, and convert name string to ascii, if possible
[1532] Fix | Delete
try:
[1533] Fix | Delete
name = self._names[key]
[1534] Fix | Delete
except KeyError:
[1535] Fix | Delete
name = key
[1536] Fix | Delete
if "}" in name:
[1537] Fix | Delete
name = "{" + name
[1538] Fix | Delete
self._names[key] = name = self._fixtext(name)
[1539] Fix | Delete
return name
[1540] Fix | Delete
[1541] Fix | Delete
def _start(self, tag, attrib_in):
[1542] Fix | Delete
fixname = self._fixname
[1543] Fix | Delete
fixtext = self._fixtext
[1544] Fix | Delete
tag = fixname(tag)
[1545] Fix | Delete
attrib = {}
[1546] Fix | Delete
for key, value in attrib_in.items():
[1547] Fix | Delete
attrib[fixname(key)] = fixtext(value)
[1548] Fix | Delete
return self.target.start(tag, attrib)
[1549] Fix | Delete
[1550] Fix | Delete
def _start_list(self, tag, attrib_in):
[1551] Fix | Delete
fixname = self._fixname
[1552] Fix | Delete
fixtext = self._fixtext
[1553] Fix | Delete
tag = fixname(tag)
[1554] Fix | Delete
attrib = {}
[1555] Fix | Delete
if attrib_in:
[1556] Fix | Delete
for i in range(0, len(attrib_in), 2):
[1557] Fix | Delete
attrib[fixname(attrib_in[i])] = fixtext(attrib_in[i+1])
[1558] Fix | Delete
return self.target.start(tag, attrib)
[1559] Fix | Delete
[1560] Fix | Delete
def _data(self, text):
[1561] Fix | Delete
return self.target.data(self._fixtext(text))
[1562] Fix | Delete
[1563] Fix | Delete
def _end(self, tag):
[1564] Fix | Delete
return self.target.end(self._fixname(tag))
[1565] Fix | Delete
[1566] Fix | Delete
def _comment(self, data):
[1567] Fix | Delete
try:
[1568] Fix | Delete
comment = self.target.comment
[1569] Fix | Delete
except AttributeError:
[1570] Fix | Delete
pass
[1571] Fix | Delete
else:
[1572] Fix | Delete
return comment(self._fixtext(data))
[1573] Fix | Delete
[1574] Fix | Delete
def _pi(self, target, data):
[1575] Fix | Delete
try:
[1576] Fix | Delete
pi = self.target.pi
[1577] Fix | Delete
except AttributeError:
[1578] Fix | Delete
pass
[1579] Fix | Delete
else:
[1580] Fix | Delete
return pi(self._fixtext(target), self._fixtext(data))
[1581] Fix | Delete
[1582] Fix | Delete
def _default(self, text):
[1583] Fix | Delete
prefix = text[:1]
[1584] Fix | Delete
if prefix == "&":
[1585] Fix | Delete
# deal with undefined entities
[1586] Fix | Delete
try:
[1587] Fix | Delete
self.target.data(self.entity[text[1:-1]])
[1588] Fix | Delete
except KeyError:
[1589] Fix | Delete
from xml.parsers import expat
[1590] Fix | Delete
err = expat.error(
[1591] Fix | Delete
"undefined entity %s: line %d, column %d" %
[1592] Fix | Delete
(text, self._parser.ErrorLineNumber,
[1593] Fix | Delete
self._parser.ErrorColumnNumber)
[1594] Fix | Delete
)
[1595] Fix | Delete
err.code = 11 # XML_ERROR_UNDEFINED_ENTITY
[1596] Fix | Delete
err.lineno = self._parser.ErrorLineNumber
[1597] Fix | Delete
err.offset = self._parser.ErrorColumnNumber
[1598] Fix | Delete
raise err
[1599] Fix | Delete
elif prefix == "<" and text[:9] == "<!DOCTYPE":
[1600] Fix | Delete
self._doctype = [] # inside a doctype declaration
[1601] Fix | Delete
elif self._doctype is not None:
[1602] Fix | Delete
# parse doctype contents
[1603] Fix | Delete
if prefix == ">":
[1604] Fix | Delete
self._doctype = None
[1605] Fix | Delete
return
[1606] Fix | Delete
text = text.strip()
[1607] Fix | Delete
if not text:
[1608] Fix | Delete
return
[1609] Fix | Delete
self._doctype.append(text)
[1610] Fix | Delete
n = len(self._doctype)
[1611] Fix | Delete
if n > 2:
[1612] Fix | Delete
type = self._doctype[1]
[1613] Fix | Delete
if type == "PUBLIC" and n == 4:
[1614] Fix | Delete
name, type, pubid, system = self._doctype
[1615] Fix | Delete
elif type == "SYSTEM" and n == 3:
[1616] Fix | Delete
name, type, system = self._doctype
[1617] Fix | Delete
pubid = None
[1618] Fix | Delete
else:
[1619] Fix | Delete
return
[1620] Fix | Delete
if pubid:
[1621] Fix | Delete
pubid = pubid[1:-1]
[1622] Fix | Delete
if hasattr(self.target, "doctype"):
[1623] Fix | Delete
self.target.doctype(name, pubid, system[1:-1])
[1624] Fix | Delete
elif self.doctype != self._XMLParser__doctype:
[1625] Fix | Delete
# warn about deprecated call
[1626] Fix | Delete
self._XMLParser__doctype(name, pubid, system[1:-1])
[1627] Fix | Delete
self.doctype(name, pubid, system[1:-1])
[1628] Fix | Delete
self._doctype = None
[1629] Fix | Delete
[1630] Fix | Delete
##
[1631] Fix | Delete
# (Deprecated) Handles a doctype declaration.
[1632] Fix | Delete
#
[1633] Fix | Delete
# @param name Doctype name.
[1634] Fix | Delete
# @param pubid Public identifier.
[1635] Fix | Delete
# @param system System identifier.
[1636] Fix | Delete
[1637] Fix | Delete
def doctype(self, name, pubid, system):
[1638] Fix | Delete
"""This method of XMLParser is deprecated."""
[1639] Fix | Delete
warnings.warn(
[1640] Fix | Delete
"This method of XMLParser is deprecated. Define doctype() "
[1641] Fix | Delete
"method on the TreeBuilder target.",
[1642] Fix | Delete
DeprecationWarning,
[1643] Fix | Delete
)
[1644] Fix | Delete
[1645] Fix | Delete
# sentinel, if doctype is redefined in a subclass
[1646] Fix | Delete
__doctype = doctype
[1647] Fix | Delete
[1648] Fix | Delete
##
[1649] Fix | Delete
# Feeds data to the parser.
[1650] Fix | Delete
#
[1651] Fix | Delete
# @param data Encoded data.
[1652] Fix | Delete
[1653] Fix | Delete
def feed(self, data):
[1654] Fix | Delete
try:
[1655] Fix | Delete
self._parser.Parse(data, 0)
[1656] Fix | Delete
except self._error, v:
[1657] Fix | Delete
self._raiseerror(v)
[1658] Fix | Delete
[1659] Fix | Delete
##
[1660] Fix | Delete
# Finishes feeding data to the parser.
[1661] Fix | Delete
#
[1662] Fix | Delete
# @return An element structure.
[1663] Fix | Delete
# @defreturn Element
[1664] Fix | Delete
[1665] Fix | Delete
def close(self):
[1666] Fix | Delete
try:
[1667] Fix | Delete
self._parser.Parse("", 1) # end of data
[1668] Fix | Delete
except self._error, v:
[1669] Fix | Delete
self._raiseerror(v)
[1670] Fix | Delete
tree = self.target.close()
[1671] Fix | Delete
del self.target, self._parser # get rid of circular references
[1672] Fix | Delete
return tree
[1673] Fix | Delete
[1674] Fix | Delete
# compatibility
[1675] Fix | Delete
XMLTreeBuilder = XMLParser
[1676] Fix | Delete
[1677] Fix | Delete
# workaround circular import.
[1678] Fix | Delete
try:
[1679] Fix | Delete
from ElementC14N import _serialize_c14n
[1680] Fix | Delete
_serialize["c14n"] = _serialize_c14n
[1681] Fix | Delete
except ImportError:
[1682] Fix | Delete
pass
[1683] Fix | Delete
[1684] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function