mirror of
https://github.com/androguard/androguard.git
synced 2024-11-27 15:01:03 +00:00
remove redundand parantheses
This commit is contained in:
parent
fa09ef768b
commit
d21744bc4e
@ -147,8 +147,8 @@ class DefaultAndroAnalysis(object):
|
||||
"""
|
||||
file_type = androconf.is_android_raw(fileraw)
|
||||
if file_type == "APK" or file_type == "DEX" or file_type == "DEY" or file_type == "AXML" or file_type == "ARSC":
|
||||
return (True, file_type)
|
||||
return (False, None)
|
||||
return True, file_type
|
||||
return False, None
|
||||
|
||||
def create_axml(self, log, fileraw):
|
||||
"""
|
||||
|
@ -26,7 +26,7 @@ def enable_print_colors(colors):
|
||||
# Handle exit message
|
||||
def Exit(msg):
|
||||
warning("Error : " + msg)
|
||||
raise ("oops")
|
||||
raise "oops"
|
||||
|
||||
|
||||
def Warning(msg):
|
||||
|
@ -1522,7 +1522,7 @@ COMPLEX_UNIT_MASK = 15
|
||||
|
||||
|
||||
def complexToFloat(xcomplex):
|
||||
return (float)(xcomplex & 0xFFFFFF00) * RADIX_MULTS[(xcomplex >> 4) & 3]
|
||||
return float(xcomplex & 0xFFFFFF00) * RADIX_MULTS[(xcomplex >> 4) & 3]
|
||||
|
||||
|
||||
def getPackage(id):
|
||||
|
@ -281,7 +281,7 @@ def writesleb128(value):
|
||||
if hasMore:
|
||||
tmp = 0x80
|
||||
|
||||
buff += pack("=B", (value & 0x7f) | (tmp))
|
||||
buff += pack("=B", (value & 0x7f) | tmp)
|
||||
value = remaining
|
||||
remaining >>= 7
|
||||
|
||||
@ -301,7 +301,7 @@ def determineNext(i, end, m):
|
||||
# if
|
||||
elif 0x32 <= op_value <= 0x3d:
|
||||
off = i.get_ref_off() * 2
|
||||
return [end + i.get_length(), off + (end)]
|
||||
return [end + i.get_length(), off + end]
|
||||
# sparse/packed
|
||||
elif op_value in (0x2b, 0x2c):
|
||||
x = []
|
||||
@ -512,7 +512,7 @@ class HeaderItem(object):
|
||||
self.endian_tag))
|
||||
bytecode._PrintDefault("link_size=%x, link_off=%x\n" %
|
||||
(self.link_size, self.link_off))
|
||||
bytecode._PrintDefault("map_off=%x\n" % (self.map_off))
|
||||
bytecode._PrintDefault("map_off=%x\n" % self.map_off)
|
||||
bytecode._PrintDefault("string_ids_size=%x, string_ids_off=%x\n" %
|
||||
(self.string_ids_size, self.string_ids_off))
|
||||
bytecode._PrintDefault("type_ids_size=%x, type_ids_off=%x\n" %
|
||||
@ -4107,7 +4107,7 @@ class Instruction(object):
|
||||
|
||||
:rtype: string
|
||||
"""
|
||||
raise ("not implemented")
|
||||
raise "not implemented"
|
||||
|
||||
def get_operands(self, idx=-1):
|
||||
"""
|
||||
@ -4115,7 +4115,7 @@ class Instruction(object):
|
||||
|
||||
:rtype: list
|
||||
"""
|
||||
raise ("not implemented")
|
||||
raise "not implemented"
|
||||
|
||||
def get_length(self):
|
||||
"""
|
||||
@ -4123,7 +4123,7 @@ class Instruction(object):
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
raise ("not implemented")
|
||||
raise "not implemented"
|
||||
|
||||
def get_raw(self):
|
||||
"""
|
||||
@ -4131,7 +4131,7 @@ class Instruction(object):
|
||||
|
||||
:rtype: string
|
||||
"""
|
||||
raise ("not implemented")
|
||||
raise "not implemented"
|
||||
|
||||
def get_ref_kind(self):
|
||||
"""
|
||||
@ -4139,7 +4139,7 @@ class Instruction(object):
|
||||
|
||||
:rtype: value
|
||||
"""
|
||||
raise ("not implemented")
|
||||
raise "not implemented"
|
||||
|
||||
def get_formatted_operands(self):
|
||||
return None
|
||||
@ -4589,7 +4589,7 @@ class Instruction35c(Instruction):
|
||||
kind = get_kind(self.cm, self.get_kind(), self.BBBB)
|
||||
|
||||
if self.A == 0:
|
||||
buff += "%s" % (kind)
|
||||
buff += "%s" % kind
|
||||
elif self.A == 1:
|
||||
buff += "v%d, %s" % (self.C, kind)
|
||||
elif self.A == 2:
|
||||
@ -4878,7 +4878,7 @@ class Instruction22c(Instruction):
|
||||
|
||||
def get_raw(self):
|
||||
return pack("=HH",
|
||||
(self.B << 12) | (self.A << 8) | (self.OP), self.CCCC)
|
||||
(self.B << 12) | (self.A << 8) | self.OP, self.CCCC)
|
||||
|
||||
|
||||
class Instruction22cs(Instruction):
|
||||
@ -4917,7 +4917,7 @@ class Instruction22cs(Instruction):
|
||||
|
||||
def get_raw(self):
|
||||
return pack("=HH",
|
||||
(self.B << 12) | (self.A << 8) | (self.OP), self.CCCC)
|
||||
(self.B << 12) | (self.A << 8) | self.OP, self.CCCC)
|
||||
|
||||
|
||||
class Instruction31t(Instruction):
|
||||
@ -5030,7 +5030,7 @@ class Instruction12x(Instruction):
|
||||
return [(OPERAND_REGISTER, self.A), (OPERAND_REGISTER, self.B)]
|
||||
|
||||
def get_raw(self):
|
||||
return pack("=H", (self.B << 12) | (self.A << 8) | (self.OP))
|
||||
return pack("=H", (self.B << 12) | (self.A << 8) | self.OP)
|
||||
|
||||
|
||||
class Instruction11x(Instruction):
|
||||
@ -5052,7 +5052,7 @@ class Instruction11x(Instruction):
|
||||
|
||||
def get_output(self, idx=-1):
|
||||
buff = ""
|
||||
buff += "v%d" % (self.AA)
|
||||
buff += "v%d" % self.AA
|
||||
return buff
|
||||
|
||||
def get_operands(self, idx=-1):
|
||||
@ -5246,7 +5246,7 @@ class Instruction20t(Instruction):
|
||||
|
||||
def get_output(self, idx=-1):
|
||||
buff = ""
|
||||
buff += "%+x" % (self.AAAA)
|
||||
buff += "%+x" % self.AAAA
|
||||
return buff
|
||||
|
||||
def get_operands(self, idx=-1):
|
||||
@ -5311,7 +5311,7 @@ class Instruction10t(Instruction):
|
||||
|
||||
def get_output(self, idx=-1):
|
||||
buff = ""
|
||||
buff += "%+x" % (self.AA)
|
||||
buff += "%+x" % self.AA
|
||||
return buff
|
||||
|
||||
def get_operands(self, idx=-1):
|
||||
@ -5450,7 +5450,7 @@ class Instruction30t(Instruction):
|
||||
|
||||
def get_output(self, idx=-1):
|
||||
buff = ""
|
||||
buff += "%+x" % (self.AAAAAAAA)
|
||||
buff += "%+x" % self.AAAAAAAA
|
||||
return buff
|
||||
|
||||
def get_operands(self, idx=-1):
|
||||
@ -6767,7 +6767,7 @@ class DalvikCode(object):
|
||||
self.code = DCode(self.CM, buff.get_idx(), self.insns_size, buff.read(
|
||||
self.insns_size * ushort))
|
||||
|
||||
if (self.insns_size % 2 == 1):
|
||||
if self.insns_size % 2 == 1:
|
||||
self.padding = unpack("=H", buff.read(2))[0]
|
||||
|
||||
self.tries = []
|
||||
@ -6939,7 +6939,7 @@ class DalvikCode(object):
|
||||
pack("=I", self.insns_size))
|
||||
length += self.code.get_length()
|
||||
|
||||
if (self.insns_size % 2 == 1):
|
||||
if self.insns_size % 2 == 1:
|
||||
length += len(pack("=H", self.padding))
|
||||
|
||||
if self.tries_size > 0:
|
||||
@ -7283,7 +7283,7 @@ class ClassManager(object):
|
||||
try:
|
||||
off = self.__manage_item["TYPE_STRING_ID_ITEM"][idx].get_string_data_off()
|
||||
except IndexError:
|
||||
bytecode.Warning("unknown string item @ %d" % (idx))
|
||||
bytecode.Warning("unknown string item @ %d" % idx)
|
||||
return "AG:IS: invalid string"
|
||||
|
||||
try:
|
||||
@ -7302,7 +7302,7 @@ class ClassManager(object):
|
||||
off = self.__manage_item["TYPE_STRING_ID_ITEM"][idx].get_string_data_off(
|
||||
)
|
||||
except IndexError:
|
||||
bytecode.Warning("unknown string item @ %d" % (idx))
|
||||
bytecode.Warning("unknown string item @ %d" % idx)
|
||||
return "AG:IS: invalid string"
|
||||
|
||||
try:
|
||||
@ -8298,7 +8298,7 @@ class DalvikVMFormat(bytecode._Bytecode):
|
||||
def print_map(node, l, lvl=0):
|
||||
for n in node.children:
|
||||
if lvl == 0:
|
||||
l.append("%s" % (n.title))
|
||||
l.append("%s" % n.title)
|
||||
else:
|
||||
l.append("%s %s" % ('\t' * lvl, n.title))
|
||||
if len(n.children) > 0:
|
||||
@ -8625,7 +8625,7 @@ def get_bytecodes_methodx(method, mx):
|
||||
bb_buffer = ""
|
||||
ins_buffer = ""
|
||||
|
||||
bb_buffer += "%s : " % (i.name)
|
||||
bb_buffer += "%s : " % i.name
|
||||
|
||||
instructions = i.get_instructions()
|
||||
for ins in instructions:
|
||||
@ -8638,7 +8638,7 @@ def get_bytecodes_methodx(method, mx):
|
||||
if (op_value == 0x2b or op_value == 0x2c
|
||||
) and len(i.childs) > 1:
|
||||
values = i.get_special_ins(idx).get_values()
|
||||
bb_buffer += "[ D:%s " % (i.childs[0][2].name)
|
||||
bb_buffer += "[ D:%s " % i.childs[0][2].name
|
||||
bb_buffer += ' '.join(
|
||||
"%d:%s" % (values[j], i.childs[j + 1][2].name)
|
||||
for j in range(0, len(i.childs) - 1)) + " ]"
|
||||
|
@ -329,7 +329,7 @@ def build_node_from_block(block, vmap, gen_ret, exception_type=None):
|
||||
fillarray = block.get_special_ins(idx)
|
||||
lins.append(_ins(ins, vmap, fillarray))
|
||||
# invoke-kind[/range]
|
||||
elif (0x6e <= opcode <= 0x72 or 0x74 <= opcode <= 0x78):
|
||||
elif 0x6e <= opcode <= 0x72 or 0x74 <= opcode <= 0x78:
|
||||
lins.append(_ins(ins, vmap, gen_ret))
|
||||
# filled-new-array[/range]
|
||||
elif 0x24 <= opcode <= 0x25:
|
||||
|
@ -200,9 +200,9 @@ class BinViewMode(ViewMode):
|
||||
|
||||
if dx < 0:
|
||||
# cu (column) selectam coloana
|
||||
idx = (i + 1) * (self.COLUMNS) - (column + 1)
|
||||
idx = (i + 1) * self.COLUMNS - (column + 1)
|
||||
if dx > 0:
|
||||
idx = (i) * (self.COLUMNS) + (column)
|
||||
idx = i * self.COLUMNS + column
|
||||
|
||||
# c = self.dataModel.getDisplayablePage()[idx]
|
||||
c = self.transformationEngine.getChar(idx)
|
||||
|
@ -86,7 +86,7 @@ class DataModel(Observer):
|
||||
return x, y
|
||||
|
||||
def getPageOffset(self, page):
|
||||
return self.getOffset() + (page) * self.rows * self.cols
|
||||
return self.getOffset() + page * self.rows * self.cols
|
||||
|
||||
def getQWORD(self, offset, asString=False):
|
||||
if offset + 8 > len(self.data):
|
||||
|
@ -453,12 +453,12 @@ class DisasmViewMode(ViewMode):
|
||||
|
||||
# draw the two lines
|
||||
qp.drawLine(-5, cursorY * self.fontHeight + self.fontHeight // 2, -30, cursorY * self.fontHeight + half)
|
||||
qp.drawLine(-30, cursorY * self.fontHeight + self.fontHeight // 2, -30, (1) * self.fontHeight + half)
|
||||
qp.drawLine(-30, cursorY * self.fontHeight + self.fontHeight // 2, -30, 1 * self.fontHeight + half)
|
||||
|
||||
# draw arrow
|
||||
points = [QtCore.QPoint(-25, (1) * self.fontHeight + half),
|
||||
QtCore.QPoint(-35, (1) * self.fontHeight + half),
|
||||
QtCore.QPoint(-30, (1) * self.fontHeight), ]
|
||||
points = [QtCore.QPoint(-25, 1 * self.fontHeight + half),
|
||||
QtCore.QPoint(-35, 1 * self.fontHeight + half),
|
||||
QtCore.QPoint(-30, 1 * self.fontHeight), ]
|
||||
needle = QtGui.QPolygon(points)
|
||||
qp.setBrush(QtGui.QBrush(QtGui.QColor(0, 128, 0)))
|
||||
qp.drawPolygon(needle)
|
||||
@ -692,7 +692,7 @@ class DisasmViewMode(ViewMode):
|
||||
diff = offset - self.dataModel.getOffset() - off_row # self.OPCODES[row].size
|
||||
|
||||
if row is not None:
|
||||
self.cursor.moveAbsolute((diff) * 3, row)
|
||||
self.cursor.moveAbsolute(diff * 3, row)
|
||||
|
||||
self.draw(refresh=False)
|
||||
else:
|
||||
|
@ -237,9 +237,9 @@ class HexViewMode(ViewMode):
|
||||
|
||||
if dx < 0:
|
||||
# cu (column) selectam coloana
|
||||
idx = (i + 1) * (self.COLUMNS) - (column + 1)
|
||||
idx = (i + 1) * self.COLUMNS - (column + 1)
|
||||
if dx > 0:
|
||||
idx = (i) * (self.COLUMNS) + (column)
|
||||
idx = i * self.COLUMNS + column
|
||||
|
||||
if len(self.getDisplayablePage()) > idx:
|
||||
qp.setPen(self.transformationEngine.choosePen(idx))
|
||||
@ -259,7 +259,7 @@ class HexViewMode(ViewMode):
|
||||
cemu.writeAt(textBegining + self.COLUMNS - (column + 1), i, self.cp437(c))
|
||||
|
||||
if dx > 0:
|
||||
cemu.writeAt((column) * 3, i, hex_s, noBackgroudOnSpaces=True)
|
||||
cemu.writeAt(column * 3, i, hex_s, noBackgroudOnSpaces=True)
|
||||
cemu.writeAt(textBegining + column, i, self.cp437(c))
|
||||
|
||||
qp.setBackgroundMode(0)
|
||||
|
@ -234,7 +234,7 @@ class DefaultSelection(Selection):
|
||||
qp.fillRect((d0 % cols) * 8, (d0 // cols) * height, (cols - d0 % cols) * 8, 1 * height, brush)
|
||||
d0 += (cols - d0 % cols)
|
||||
|
||||
if (d1 - d0 <= 0):
|
||||
if d1 - d0 <= 0:
|
||||
mark = False
|
||||
qp.setOpacity(1)
|
||||
|
||||
@ -281,7 +281,7 @@ class DefaultSelection(Selection):
|
||||
brush)
|
||||
d0 += (cols - d0 % cols)
|
||||
|
||||
if (d1 - d0 <= 0):
|
||||
if d1 - d0 <= 0:
|
||||
mark = False
|
||||
qp.setOpacity(1)
|
||||
|
||||
@ -339,7 +339,7 @@ class HexSelection(Selection):
|
||||
|
||||
d0 += (cols - d0 % cols)
|
||||
|
||||
if (d1 - d0 <= 0):
|
||||
if d1 - d0 <= 0:
|
||||
mark = False
|
||||
qp.setOpacity(1)
|
||||
|
||||
|
@ -90,7 +90,7 @@ class ConsoleEmulator(object):
|
||||
self.qp.setBackgroundMode(background)
|
||||
|
||||
def getXY(self):
|
||||
return (self._x, self._y)
|
||||
return self._x, self._y
|
||||
|
||||
def writeAt(self, x, y, s, noBackgroudOnSpaces=False):
|
||||
self.gotoXY(x, y)
|
||||
|
@ -51,7 +51,7 @@ def display2classmethod(display):
|
||||
"""
|
||||
|
||||
L = display.split(" -> ")
|
||||
return (L[0], L[1])
|
||||
return L[0], L[1]
|
||||
|
||||
|
||||
def classdot2func(path):
|
||||
|
@ -1362,7 +1362,7 @@ class PyZipFile(ZipFile):
|
||||
archivename = os.path.split(fname)[1]
|
||||
if basename:
|
||||
archivename = "%s/%s" % (basename, archivename)
|
||||
return (fname, archivename)
|
||||
return fname, archivename
|
||||
|
||||
|
||||
def main(args=None):
|
||||
|
@ -56,7 +56,7 @@ class Session(object):
|
||||
self.analyzed_files[filename].append(digest)
|
||||
self.analyzed_digest[digest] = filename
|
||||
androconf.debug("added APK:%s" % digest)
|
||||
return (digest, apk)
|
||||
return digest, apk
|
||||
|
||||
def addDEX(self, filename, data, dx=None):
|
||||
"""
|
||||
@ -89,7 +89,7 @@ class Session(object):
|
||||
androconf.debug("Exporting in ipython")
|
||||
d.create_python_export()
|
||||
|
||||
return (digest, d, dx)
|
||||
return digest, d, dx
|
||||
|
||||
def addDEY(self, filename, data, dx=None):
|
||||
digest = hashlib.sha256(data).hexdigest()
|
||||
@ -110,7 +110,7 @@ class Session(object):
|
||||
if self.export_ipython:
|
||||
d.create_python_export()
|
||||
|
||||
return (digest, d, dx)
|
||||
return digest, d, dx
|
||||
|
||||
def runAnalysis(self, d, dx=None):
|
||||
if dx is None:
|
||||
|
@ -105,7 +105,7 @@ def save_file(filename):
|
||||
fd.write("PERMISSIONS = {\n")
|
||||
for i in PERMS_API:
|
||||
if len(PERMS_API[i]) > 0:
|
||||
fd.write("\"%s\" : {\n" % (i))
|
||||
fd.write("\"%s\" : {\n" % i)
|
||||
|
||||
for package in PERMS_API[i]:
|
||||
if len(PERMS_API[i][package]) > 0:
|
||||
|
@ -107,7 +107,7 @@ def parseMethod(methodString):
|
||||
returnValue = retValue_mName[0:mNameStartPos].strip()
|
||||
methodName = retValue_mName[mNameStartPos + 1:].strip()
|
||||
|
||||
return (methodName, params, returnValue)
|
||||
return methodName, params, returnValue
|
||||
|
||||
|
||||
# end of auxiliary
|
||||
|
Loading…
Reference in New Issue
Block a user