Skip to content

Commit

Permalink
Python 3.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszAniszewski committed Feb 20, 2015
1 parent 8016453 commit 1c94dcd
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions axmlparserpy/apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ def get_libraries(self):
libraries = property(get_libraries)

def show(self):
print "FILES: ", self.get_files_types()
print("FILES: ", self.get_files_types())

print "ACTIVITIES: ", self.get_activities()
print "SERVICES: ", self.get_services()
print "RECEIVERS: ", self.get_receivers()
print "PROVIDERS: ", self.get_providers()
print("ACTIVITIES: ", self.get_activities())
print("SERVICES: ", self.get_services())
print("RECEIVERS: ", self.get_receivers())
print("PROVIDERS: ", self.get_providers())

18 changes: 9 additions & 9 deletions axmlparserpy/axmlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Androguard. If not, see <http://www.gnu.org/licenses/>.

import bytecode
import axmlparserpy.bytecode

import stringblock
import typeconstants as tc
from stringblock import StringBlock
from bytecode import SV
import axmlparserpy.stringblock
import axmlparserpy.typeconstants as tc
from axmlparserpy.stringblock import StringBlock
from axmlparserpy.bytecode import SV

import StringIO
from io import StringIO
from struct import pack, unpack
from xml.dom import minidom

Expand All @@ -33,7 +33,7 @@ class AXMLParser:
def __init__(self, raw_buff):
self.reset()

self.buff = bytecode.BuffHandle(raw_buff)
self.buff = axmlparserpy.bytecode.BuffHandle(raw_buff)

self.buff.read(4)
self.buff.read(4)
Expand Down Expand Up @@ -89,7 +89,7 @@ def doNext(self):
if chunkSize < 8 or chunkSize%4 != 0:
raise("ooo")

for i in range(0, chunkSize/4-2):
for i in range(0, int(chunkSize/4-2)):
self.m_resourceIDs.append(SV('<L', self.buff.read(4)))

continue
Expand Down Expand Up @@ -217,7 +217,7 @@ def getAttributeCount(self):
if self.m_event != tc.START_TAG:
return -1

return len(self.m_attributes) / tc.ATTRIBUTE_LENGTH
return int(len(self.m_attributes) / tc.ATTRIBUTE_LENGTH)

def getAttributePrefix(self, index):
offset = self.getAttributeOffset(index)
Expand Down
10 changes: 5 additions & 5 deletions axmlparserpy/axmlprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Androguard. If not, see <http://www.gnu.org/licenses/>.

import bytecode
import axmlparserpy.bytecode

import typeconstants as tc
from axmlparser import AXMLParser
from bytecode import SV
import axmlparserpy.typeconstants as tc
from axmlparserpy.axmlparser import AXMLParser
from axmlparserpy.bytecode import SV

import StringIO
from io import StringIO
from struct import pack, unpack
from xml.dom import minidom

Expand Down
2 changes: 1 addition & 1 deletion axmlparserpy/bytecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _Print(name, arg):
elif isinstance(arg, SVs):
buff += arg.get_value().__str__()

print buff
print(buff)

class SV:
"""SV is used to handle more easily a value"""
Expand Down
14 changes: 7 additions & 7 deletions axmlparserpy/stringblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Androguard. If not, see <http://www.gnu.org/licenses/>.

import bytecode
import axmlparserpy.bytecode

from bytecode import SV
from axmlparserpy.bytecode import SV

import StringIO
from io import StringIO
from struct import pack, unpack
from xml.dom import minidom

Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self, buff):
if (size % 4) != 0:
pass

for i in range(0, size / 4):
for i in range(0, int(size / 4)):
self.m_strings.append(SV('=L', buff.read(4)))

if self.stylesOffset.get_value() != 0:
Expand All @@ -86,7 +86,7 @@ def getRaw(self, idx):
while length > 0:
offset += 2
# Unicode character
data += unichr(self.getShort(self.m_strings, offset))
data += chr(self.getShort(self.m_strings, offset))

# FIXME
if data[-1] == "&":
Expand All @@ -97,8 +97,8 @@ def getRaw(self, idx):
return data

def getShort(self, array, offset):
value = array[offset / 4].get_value()
if ((offset % 4) / 2) == 0:
value = array[int(offset / 4)].get_value()
if (int((offset % 4)) / 2) == 0:
return value & 0xFFFF
else:
return value >> 16
Expand Down

0 comments on commit 1c94dcd

Please sign in to comment.