javacard, cosmetic: fix sourcecode fromatting and improve docstring
The line with TAGS is longer than 120 columns and there is some comment that should be moved to the python docstring. Related: OS#6679 Change-Id: I1d02098320cfbe17a0eb1bfdcf3bc85034cc8e20
This commit is contained in:
@@ -6,14 +6,16 @@ import sys
|
|||||||
import io
|
import io
|
||||||
|
|
||||||
def ijc_to_cap(in_file: io.IOBase, out_zip: zipfile.ZipFile, p : str = "foo"):
|
def ijc_to_cap(in_file: io.IOBase, out_zip: zipfile.ZipFile, p : str = "foo"):
|
||||||
"""Convert an ICJ (Interoperable Java Card) file [back] to a CAP file."""
|
"""Convert an ICJ (Interoperable Java Card) file [back] to a CAP file.
|
||||||
TAGS = ["Header", "Directory", "Applet", "Import", "ConstantPool", "Class", "Method", "StaticField", "RefLocation", "Export", "Descriptor", "Debug"]
|
example usage:
|
||||||
|
with io.open(sys.argv[1],"rb") as f, zipfile.ZipFile(sys.argv[2], "wb") as z:
|
||||||
|
ijc_to_cap(f, z)
|
||||||
|
"""
|
||||||
|
TAGS = ["Header", "Directory", "Applet", "Import", "ConstantPool", "Class", "Method", "StaticField", "RefLocation",
|
||||||
|
"Export", "Descriptor", "Debug"]
|
||||||
b = in_file.read()
|
b = in_file.read()
|
||||||
while len(b):
|
while len(b):
|
||||||
tag, size = struct.unpack('!BH', b[0:3])
|
tag, size = struct.unpack('!BH', b[0:3])
|
||||||
out_zip.writestr(p+"/javacard/"+TAGS[tag-1]+".cap", b[0:3+size])
|
out_zip.writestr(p+"/javacard/"+TAGS[tag-1]+".cap", b[0:3+size])
|
||||||
b = b[3+size:]
|
b = b[3+size:]
|
||||||
|
|
||||||
# example usage:
|
|
||||||
# with io.open(sys.argv[1],"rb") as f, zipfile.ZipFile(sys.argv[2], "wb") as z:
|
|
||||||
# ijc_to_cap(f, z)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user