Skip to content

Commit

Permalink
More cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Bachmann committed Jun 19, 2017
1 parent c94543a commit 546cc7e
Show file tree
Hide file tree
Showing 32 changed files with 209 additions and 215 deletions.
6 changes: 3 additions & 3 deletions androarsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@


def main(options, arguments):
if options.input != None:
if options.input is not None:
buff = ""

arscobj = None
Expand Down Expand Up @@ -90,14 +90,14 @@ def main(options, arguments):
arscobj, "get_" + ttype + "_resources")(package,
locale)).toprettyxml()

if options.output != None:
if options.output is not None:
fd = codecs.open(options.output, "w", "utf-8")
fd.write(buff)
fd.close()
else:
print(buff)

elif options.version != None:
elif options.version is not None:
print("Androarsc version %s" % androconf.ANDROGUARD_VERSION)


Expand Down
6 changes: 3 additions & 3 deletions androaxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


def main(options, arguments):
if options.input != None:
if options.input is not None:
buff = ""

ret_type = androconf.is_android(options.input)
Expand All @@ -62,14 +62,14 @@ def main(options, arguments):
print("Unknown file type")
return

if options.output != None:
if options.output is not None:
fd = codecs.open(options.output, "w", "utf-8")
fd.write(buff)
fd.close()
else:
print(buff)

elif options.version != None:
elif options.version is not None:
print("Androaxml version %s" % androconf.ANDROGUARD_VERSION)


Expand Down
2 changes: 1 addition & 1 deletion androdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def export_apps_to_format(filename,


def main(options, arguments):
if options.input != None and options.output != None:
if options.input is not None and options.output is not None:
s = session.Session()
with open(options.input, "rb") as fd:
s.add(options.input, fd.read())
Expand Down
2 changes: 1 addition & 1 deletion androdis.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

def disassemble(dex, offset, size):
d = dvm.auto(dex)
if d != None:
if d is not None:
nb = 0
idx = offset
for i in d.disassemble(offset, size):
Expand Down
19 changes: 10 additions & 9 deletions androguard/core/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ def set_childs(self, values):
# print self, self.start, self.end, values
if values == []:
next_block = self.context.get_basic_block(self.end + 1)
if next_block != None:
if next_block is not None:
self.childs.append((self.end - self.get_last_length(), self.end,
next_block))
else:
for i in values:
if i != -1:
next_block = self.context.get_basic_block(i)
if next_block != None:
if next_block is not None:
self.childs.append((self.end - self.get_last_length(),
i, next_block))

for c in self.childs:
if c[2] != None:
if c[2] is not None:
c[2].set_fathers((c[1], c[0], self))

def push(self, i):
Expand All @@ -149,6 +149,7 @@ def get_special_ins(self, idx):
"""
try:
return self.special_ins[idx]
# FIXME: Too broad exception clause
except:
return None

Expand Down Expand Up @@ -248,13 +249,13 @@ def __init__(self, patterns=TAGS_ANDROID, reverse=TAG_REVERSE_ANDROID):
def emit(self, method):
for i in self.patterns:
if self.patterns[i][0] == 0:
if self.patterns[i][1].search(method.get_class()) != None:
if self.patterns[i][1].search(method.get_class()) is not None:
self.tags.add(i)

def emit_by_classname(self, classname):
for i in self.patterns:
if self.patterns[i][0] == 0:
if self.patterns[i][1].search(classname) != None:
if self.patterns[i][1].search(classname) is not None:
self.tags.add(i)

def get_list(self):
Expand Down Expand Up @@ -322,7 +323,7 @@ def show_buff(self):
buff = "%x:%x\n" % (self.start, self.end)

for i in self.exceptions:
if i[2] == None:
if i[2] is None:
buff += "\t(%s -> %x %s)\n" % (i[0], i[1], i[2])
else:
buff += "\t(%s -> %x %s)\n" % (i[0], i[1], i[2].get_name())
Expand Down Expand Up @@ -387,7 +388,7 @@ def __init__(self, vm, method):
self.exceptions = Exceptions(self.__vm)

code = self.method.get_code()
if code == None:
if code is None:
return

current_basic = DVMBasicBlock(0, self.__vm, self.method, self.basic_blocks)
Expand All @@ -404,7 +405,7 @@ def __init__(self, vm, method):
instructions = [i for i in bc.get_instructions()]
for i in instructions:
for j in BasicOPCODES:
if j.match(i.get_name()) != None:
if j.match(i.get_name()) is not None:
v = dvm.determineNext(i, idx, self.method)
h[idx] = v
l.extend(v)
Expand Down Expand Up @@ -787,7 +788,7 @@ def _create_xref(self, instances_class_name, last_vm, queue_classes):
debug("Creating XREF for %s" % current_method)

code = current_method.get_code()
if code == None:
if code is None:
continue

off = 0
Expand Down
4 changes: 2 additions & 2 deletions androguard/core/analysis/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def create_dex(self, log, dexraw):
"""
return dvm.DalvikVMFormat(dexraw)

def create_dey(self, log, deyraw):
def create_dey(self, log, dexraw):
"""
This method is called in order to create a DalvikOdexVMFormat object
Expand All @@ -203,7 +203,7 @@ def create_dey(self, log, deyraw):
:rtype: a :class:`DalvikOdexVMFormat` object
"""
return dvm.DalvikOdexVMFormat(deyraw)
return dvm.DalvikOdexVMFormat(dexraw)

def create_adex(self, log, dexobj):
"""
Expand Down
2 changes: 0 additions & 2 deletions androguard/core/androconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ def is_android(filename):
f_bytes = fd.read()
return is_android_raw(f_bytes)

return None


def is_android_raw(raw):
"""
Expand Down
4 changes: 2 additions & 2 deletions androguard/core/bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _PrintBanner():

def _PrintSubBanner(title=None):
print_fct = CONF["PRINT_FCT"]
if title == None:
if title is None:
print_fct("#" * 20 + "\n")
else:
print_fct("#" * 10 + " " + title + "\n")
Expand Down Expand Up @@ -670,7 +670,7 @@ def object_to_bytes(obj):
return bytearray()
elif isinstance(obj, int):
return pack("<L", obj)
elif obj == None:
elif obj is None:
return bytearray()
elif isinstance(obj, bytearray):
return obj
Expand Down
20 changes: 10 additions & 10 deletions androguard/core/bytecodes/apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def delete(self, patterns):
while e is not None:
e.get_FileName(filename)

if re.match(patterns, filename.getString()) != None:
if re.match(patterns, filename.getString()) is not None:
el.append(e)
e = e.NextEntry()

Expand Down Expand Up @@ -205,7 +205,7 @@ def __init__(self,
androconf.warning("AXML parsing failed", e)
self.xml[i] = None

if self.xml[i] != None:
if self.xml[i] is not None:
self.package = self.xml[i].documentElement.getAttribute(
"package")
self.androidversion[
Expand Down Expand Up @@ -747,11 +747,11 @@ def get_requested_permissions(self):
return self.permissions

def get_requested_aosp_permissions(self):
'''
"""
Returns requested permissions declared within AOSP project.
:rtype: list of strings
'''
"""
aosp_permissions = []
all_permissions = self.get_requested_permissions()
for perm in all_permissions:
Expand All @@ -775,11 +775,11 @@ def get_requested_aosp_permissions_details(self):
return l

def get_requested_third_party_permissions(self):
'''
"""
Returns list of requested permissions not declared within AOSP project.
:rtype: list of strings
'''
"""
third_party_permissions = []
all_permissions = self.get_requested_permissions()
for perm in all_permissions:
Expand All @@ -788,19 +788,19 @@ def get_requested_third_party_permissions(self):
return third_party_permissions

def get_declared_permissions(self):
'''
"""
Returns list of the declared permissions.
:rtype: list of strings
'''
"""
return list(self.declared_permissions.keys())

def get_declared_permissions_details(self):
'''
"""
Returns declared permissions with the details.
:rtype: dict
'''
"""
return self.declared_permissions

def get_max_sdk_version(self):
Expand Down
Loading

0 comments on commit 546cc7e

Please sign in to comment.