text
stringlengths
0
828
ret[ keyword ] = ret.get(keyword, 0) + 1 # `ret[ keyword ] += 1` with initial value
return ret"
3785,"def _remove_strings(code) :
"""""" Remove strings in code
""""""
removed_string = """"
is_string_now = None
for i in range(0, len(code)-1) :
append_this_turn = False
if code[i] == ""'"" and (i == 0 or code[i-1] != '\\') :
if is_string_now == ""'"" :
is_string_now = None
elif is_string_now == None :
is_string_now = ""'""
append_this_turn = True
elif code[i] == '""' and (i == 0 or code[i-1] != '\\') :
if is_string_now == '""' :
is_string_now = None
elif is_string_now == None :
is_string_now = '""'
append_this_turn = True
if is_string_now == None or append_this_turn == True :
removed_string += code[i]
return removed_string"
3786,"def getratio(self, code) :
"""""" Get ratio of code and pattern matched
""""""
if len(code) == 0 : return 0
code_replaced = self.prog.sub('', code)
return (len(code) - len(code_replaced)) / len(code)"
3787,"def loadXmlProperty(self, xprop):
""""""
Loads an XML property that is a child of the root data being loaded.
:param xprop | <xml.etree.ElementTree.Element>
""""""
if xprop.tag == 'property':
value = self.dataInterface().fromXml(xprop[0])
self._xmlData[xprop.get('name', '')] = value"
3788,"def toXml(self, xparent=None):
""""""
Converts this object to XML.
:param xparent | <xml.etree.ElementTree.Element> || None
:return <xml.etree.ElementTree.Element>
""""""
if xparent is None:
xml = ElementTree.Element('object')
else:
xml = ElementTree.SubElement(xparent, 'object')
xml.set('class', self.__class__.__name__)
for name, value in self._xmlData.items():
xprop = ElementTree.SubElement(xml, 'property')
xprop.set('name', name)
XmlDataIO.toXml(value, xprop)
return xml"
3789,"def fromXml(cls, xml):
""""""
Restores an object from XML.
:param xml | <xml.etree.ElementTree.Element>
:return subclass of <XmlObject>
""""""
clsname = xml.get('class')
if clsname:
subcls = XmlObject.byName(clsname)
if subcls is None:
inst = MissingXmlObject(clsname)
else:
inst = subcls()
else:
inst = cls()
inst.loadXml(xml)
return inst"
3790,"def fromXml(cls, elem):
""""""
Converts the inputted element to a Python object by looking through
the IO addons for the element's tag.
:param elem | <xml.etree.ElementTree.Element>
:return <variant>
""""""
if elem is None:
return None