Attention is currently required from: laforge.
dexter has posted comments on this change by dexter. (
https://gerrit.osmocom.org/c/pysim/+/39198?usp=email )
Change subject: javacard: add parser for JAVA-card CAP file format
......................................................................
Patch Set 2:
(4 comments)
File pySim/javacard.py:
https://gerrit.osmocom.org/c/pysim/+/39198/comment/04b83e25_fb799e51?usp=em… :
PS1, Line 45:
can we somehow check easily if a file is extended and
in that case print a meaningful error message?
I think we could just check if there
are any .capx components in the file. When this is the case, we can throw an exception.
https://gerrit.osmocom.org/c/pysim/+/39198/comment/3b0be06c_9ebd2329?usp=em… :
PS1, Line 47: __component_header = None
: __component_directory = None
: __component_applet = None #optional
: __component_import = None
: __component_constantPool = None
: __component_class = None
: __component_method = None
: __component_staticField = None
: __component_referenceLocation = None
: __component_export = None #optional
: __component_descriptor = None
: __component_debug = None #optional, since CAP format 2.2
doesn't it make sense to use a dict here, indexed
by the component type? Just a thought.
I think that is a great idea. Then we also
won't need setattr()
https://gerrit.osmocom.org/c/pysim/+/39198/comment/86a4712a_7a4a6362?usp=em… :
PS1, Line 86: if filename.lower().endswith('header.cap'):
: self.__component_header = cap.read(filename)
: elif filename.lower().endswith('directory.cap'):
: self.__component_directory = cap.read(filename)
: elif filename.lower().endswith('applet.cap'):
: self.__component_applet = cap.read(filename)
: elif filename.lower().endswith('import.cap'):
: self.__component_import = cap.read(filename)
: elif filename.lower().endswith('constantpool.cap'):
: self.__component_constantPool = cap.read(filename)
: elif filename.lower().endswith('class.cap'):
: self.__component_class = cap.read(filename)
: elif filename.lower().endswith('method.cap'):
: self.__component_method = cap.read(filename)
: elif filename.lower().endswith('staticfield.cap'):
: self.__component_staticField = cap.read(filename)
: elif filename.lower().endswith('reflocation.cap'):
: self.__component_referenceLocation = cap.read(filename)
: elif filename.lower().endswith('export.cap'):
: self.__component_export = cap.read(filename)
: elif filename.lower().endswith('descriptor.cap'):
: self.__component_descriptor = cap.read(filename)
: elif filename.lower().endswith('debug.cap'):
: self.__component_debug = cap.read(filename)
IMHO, this looks like a lot of copy+paste / typing
work in something that can be implemented more el […]
Done
https://gerrit.osmocom.org/c/pysim/+/39198/comment/4a1825c4_8acf2da1?usp=em… :
PS1, Line 113: if self.__component_header is None:
: raise ValueError("invalid cap file, COMPONENT_Header
missing!")
: if self.__component_directory is None:
: raise ValueError("invalid cap file, COMPONENT_Directory
missing!")
: if self.__component_import is None:
: raise ValueError("invalid cap file, COMPONENT_Import
missing!")
: if self.__component_constantPool is None:
: raise ValueError("invalid cap file, COMPONENT_ConstantPool
missing!")
: if self.__component_class is None:
: raise ValueError("invalid cap file, COMPONENT_Class
missing!")
: if self.__component_method is None:
: raise ValueError("invalid cap file, COMPONENT_Method
missing!")
: if self.__component_staticField is None:
: raise ValueError("invalid cap file, COMPONENT_StaticField
missing!")
: if self.__component_referenceLocation is None:
: raise ValueError("invalid cap file,
COMPONENT_ReferenceLocation missing!")
: if self.__component_descriptor is None:
: raise ValueError("invalid cap file, COMPONENT_Descriptor
missing!")
likewise here, that's a lot of code to write.
Why not simply have a […]
Done
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/39198?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I581483ccb9d8a254fcecc995fec3c811c5cf38eb
Gerrit-Change-Number: 39198
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 03 Jan 2025 09:45:18 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>