本文整理匯總了Python中builtins.str方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.str方法的具體用法?Python builtins.str怎麽用?Python builtins.str使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類builtins
的用法示例。
在下文中一共展示了builtins.str方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: slotDoubleClicked
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def slotDoubleClicked(self, mi):
mi = self.proxyModel.mapToSource(mi)
row = mi.row()
column = mi.column()
if column == len(self.headers) - 1:
data = mi.data()
xref_method = None
xref_class = None
for xref in self.xrefs:
if str(xref[-2]) == data:
xref_method = xref[-2]
xref_class = xref[-1]
break
if xref_class and xref_method:
self.mainwin.openSourceWindow(current_class=xref_class,
method=xref_method)
self.parent.close()
return
else:
self.mainwin.showStatus("Impossible to find the xref ....")
return
示例2: eventFilter
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def eventFilter(self, watched, event):
if event.type() == QtCore.QEvent.KeyPress:
if event.key() == QtCore.Qt.Key_Delete:
# get RVA column from treeView
item = self.widget.currentItem()
offset = item.getOffset() # int(str(item.text(1)),0)
size = item.getSize() # int(str(item.text(2)),0)
u = offset
v = offset + size
self.view.selector.removeSelection(u, v, TextSelection.SelectionType.PERMANENT)
# TODO: remove tree!
item.parent().removeChild(item)
# self.widget.takeTopLevelItem(self.widget.indexOfTopLevelItem(item))
# rva = self.widget.indexFromItem(item, 1).data().toString()
return False
示例3: draw
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def draw(self, refresh=False, row=0, howMany=0):
if self.dataModel.getOffset() in self.Paints:
self.refresh = False
self.qpix = QtGui.QPixmap(self.Paints[self.dataModel.getOffset()])
self.drawAdditionals()
return
if self.refresh or refresh:
qp = QtGui.QPainter()
qp.begin(self.qpix)
start = time()
if not howMany:
howMany = self.ROWS
self.drawTextMode(qp, row=row, howMany=howMany)
end = time() - start
log.debug('draw Time ' + str(end))
self.refresh = False
qp.end()
# self.Paints[self.dataModel.getOffset()] = QtGui.QPixmap(self.qpix)
self.drawAdditionals()
示例4: handleEditMode
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def handleEditMode(self, modifiers, key, event):
if key in range(0, 256):
offs = self.getCursorOffsetInPage()
self.dataModel.setData_b(self.dataModel.getOffset() + offs, str(event.text()))
z = self.dataModel.getOffset() + offs
# TODO: sa nu se repete, tre original_transformengine
self.transformationEngine = RangePen(self.original_textdecorator, z, z + 0,
QtGui.QPen(QtGui.QColor(218, 94, 242), 0, QtCore.Qt.SolidLine),
ignoreHighlights=True)
self.moveCursor(Directions.Right)
x, y = self.cursor.getPosition()
self.draw(refresh=True, row=y, howMany=1)
示例5: get_field_ast
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def get_field_ast(field):
triple = field.get_class_name()[1:-1], field.get_name(
), field.get_descriptor()
expr = None
if field.init_value:
val = field.init_value.value
expr = dummy(str(val))
if val is not None:
if field.get_descriptor() == 'Ljava/lang/String;':
expr = literal_string(val)
elif field.proto == 'B':
expr = literal_hex_int(struct.unpack('<b', struct.pack("B", val))[0])
return {
'triple': triple,
'type': parse_descriptor(field.get_descriptor()),
'flags': util.get_access_field(field.get_access_flags()),
'expr': expr,
}
示例6: get_class
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def get_class(self, class_name):
"""
Return the :class:`DvClass` with the given name
The name is partially matched against the known class names and the first result is returned.
For example, the input `foobar` will match on Lfoobar/bla/foo;
:param str class_name:
:return: the class matching on the name
:rtype: DvClass
"""
for name, klass in self.classes.items():
# TODO why use the name partially?
if class_name in name:
if isinstance(klass, DvClass):
return klass
dvclass = self.classes[name] = DvClass(klass, self.vma)
return dvclass
示例7: __getstate__
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def __getstate__(self):
"""
Function for pickling APK Objects.
We remove the zip from the Object, as it is not pickable
And it does not make any sense to pickle it anyways.
:returns: the picklable APK Object without zip.
"""
# Upon pickling, we need to remove the ZipFile
x = self.__dict__
x['axml'] = str(x['axml'])
x['xml'] = str(x['xml'])
del x['zip']
return x
示例8: get_elements
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def get_elements(self, tag_name, attribute, with_namespace=True):
"""
.. deprecated:: 3.3.5
use :meth:`get_all_attribute_value` instead
Return elements in xml files which match with the tag name and the specific attribute
:param str tag_name: a string which specify the tag name
:param str attribute: a string which specify the attribute
"""
warnings.warn("This method is deprecated since 3.3.5.", DeprecationWarning)
for i in self.xml:
if self.xml[i] is None:
continue
for item in self.xml[i].findall('.//' + tag_name):
if with_namespace:
value = item.get(self._ns(attribute))
else:
value = item.get(attribute)
# There might be an attribute without the namespace
if value:
yield self._format_value(value)
示例9: get_all_attribute_value
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def get_all_attribute_value(
self, tag_name, attribute, format_value=True, **attribute_filter
):
"""
Yields all the attribute values in xml files which match with the tag name and the specific attribute
:param str tag_name: specify the tag name
:param str attribute: specify the attribute
:param bool format_value: specify if the value needs to be formatted with packagename
"""
tags = self.find_tags(tag_name, **attribute_filter)
for tag in tags:
value = tag.get(attribute) or tag.get(self._ns(attribute))
if value is not None:
if format_value:
yield self._format_value(value)
else:
yield value
示例10: find_tags_from_xml
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def find_tags_from_xml(
self, xml_name, tag_name, **attribute_filter
):
"""
Return a list of all the matched tags in a specific xml
w
:param str xml_name: specify from which xml to pick the tag from
:param str tag_name: specify the tag name
"""
xml = self.xml[xml_name]
if xml is None:
return []
if xml.tag == tag_name:
if self.is_tag_matched(
xml.tag, **attribute_filter
):
return [xml]
return []
tags = xml.findall(".//" + tag_name)
return [
tag for tag in tags if self.is_tag_matched(
tag, **attribute_filter
)
]
示例11: object_to_bytes
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def object_to_bytes(obj):
"""
Convert a object to a bytearray or call get_raw() of the object
if no useful type was found.
"""
if isinstance(obj, str):
return bytearray(obj, "UTF-8")
elif isinstance(obj, bool):
return bytearray()
elif isinstance(obj, int):
return pack("<L", obj)
elif obj is None:
return bytearray()
elif isinstance(obj, bytearray):
return obj
else:
return obj.get_raw()
示例12: FormatClassToPython
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def FormatClassToPython(i):
"""
Transform a typed class name into a form which can be used as a python
attribute
example::
>>> FormatClassToPython('Lfoo/bar/foo/Barfoo$InnerClass;')
'Lfoo_bar_foo_Barfoo_InnerClass'
:param i: classname to transform
:rtype: str
"""
i = i[:-1]
i = i.replace("/", "_")
i = i.replace("$", "_")
return i
示例13: FormatNameToPython
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def FormatNameToPython(i):
"""
Transform a (method) name into a form which can be used as a python
attribute
example::
>>> FormatNameToPython('<clinit>')
'clinit'
:param i: name to transform
:rtype: str
"""
i = i.replace("<", "")
i = i.replace(">", "")
i = i.replace("$", "_")
return i
示例14: FormatDescriptorToPython
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def FormatDescriptorToPython(i):
"""
Format a descriptor into a form which can be used as a python attribute
example::
>>> FormatDescriptorToPython('(Ljava/lang/Long; Ljava/lang/Long; Z Z)V')
'Ljava_lang_LongLjava_lang_LongZZV
:param i: name to transform
:rtype: str
"""
i = i.replace("/", "_")
i = i.replace(";", "")
i = i.replace("[", "")
i = i.replace("(", "")
i = i.replace(")", "")
i = i.replace(" ", "")
i = i.replace("$", "")
return i
示例15: get_fake_method
# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import str [as 別名]
def get_fake_method(self, name, descriptor):
"""
Search for the given method name and descriptor
and return a fake (ExternalMethod) if required.
:param name: name of the method
:param descriptor: descriptor of the method, for example `'(I I I)V'`
:return: :class:`ExternalMethod`
"""
if self.external:
# An external class can only generate the methods on demand
return self.orig_class.get_method(name, descriptor)
# We are searching an unknown method in this class
# It could be something that the class herits
key = name + str(descriptor)
if key not in self._inherits_methods:
self._inherits_methods[key] = ExternalMethod(self.orig_class.get_name(), name, descriptor)
return self._inherits_methods[key]