pylint: ara_m.py
pySim/ara_m.py:29:0: W0622: Redefining built-in 'BlockingIOError' (redefined-builtin)
pySim/ara_m.py:29:0: W0401: Wildcard import construct (wildcard-import)
pySim/ara_m.py:68:12: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
pySim/ara_m.py:89:12: R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
pySim/ara_m.py:282:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
pySim/ara_m.py:280:15: W0612: Unused variable 'sw' (unused-variable)
pySim/ara_m.py:312:34: W0613: Unused argument 'opts' (unused-argument)
pySim/ara_m.py:318:37: W0613: Unused argument 'opts' (unused-argument)
pySim/ara_m.py:356:15: C0121: Comparison 'opts.aid != None' should be 'opts.aid is not None' (singleton-comparison)
pySim/ara_m.py:385:37: W0613: Unused argument 'opts' (unused-argument)
pySim/ara_m.py:309:8: W0238: Unused private member `AddlShellCommands.__init(self)` (unused-private-member)
pySim/ara_m.py:309:8: W0238: Unused private member `ADF_ARAM.AddlShellCommands.__init(self)` (unused-private-member)
Change-Id: I5a739187a8966cdb0ae5c6cbc7bc5d4115433aeb
diff --git a/pySim/ara_m.py b/pySim/ara_m.py
index d137dcf..5776e3d 100644
--- a/pySim/ara_m.py
+++ b/pySim/ara_m.py
@@ -26,11 +26,12 @@
#
-from construct import *
+from construct import GreedyBytes, GreedyString, Struct, Enum, Int8ub, Int16ub
from construct import Optional as COptional
from pySim.construct import *
from pySim.filesystem import *
from pySim.tlv import *
+from pySim.utils import Hexstr
import pySim.global_platform
# various BER-TLV encoded Data Objects (DOs)
@@ -68,11 +69,10 @@
if do[0] == 0x00:
self.decoded = {'generic_access_rule': 'never'}
return self.decoded
- elif do[0] == 0x01:
+ if do[0] == 0x01:
self.decoded = {'generic_access_rule': 'always'}
return self.decoded
- else:
- return ValueError('Invalid 1-byte generic APDU access rule')
+ return ValueError('Invalid 1-byte generic APDU access rule')
else:
if len(do) % 8:
return ValueError('Invalid non-modulo-8 length of APDU filter: %d' % len(do))
@@ -88,10 +88,9 @@
if 'generic_access_rule' in self.decoded:
if self.decoded['generic_access_rule'] == 'never':
return b'\x00'
- elif self.decoded['generic_access_rule'] == 'always':
+ if self.decoded['generic_access_rule'] == 'always':
return b'\x01'
- else:
- return ValueError('Invalid 1-byte generic APDU access rule')
+ return ValueError('Invalid 1-byte generic APDU access rule')
else:
if not 'apdu_filter' in self.decoded:
return ValueError('Invalid APDU AR DO')
@@ -277,14 +276,13 @@
cmd_do_enc = b''
cmd_do_len = 0
c_apdu = hdr + ('%02x' % cmd_do_len) + b2h(cmd_do_enc)
- (data, sw) = tp.send_apdu_checksw(c_apdu, exp_sw)
+ (data, _sw) = tp.send_apdu_checksw(c_apdu, exp_sw)
if data:
if resp_cls:
resp_do = resp_cls()
resp_do.from_tlv(h2b(data))
return resp_do
- else:
- return data
+ return data
else:
return None
@@ -306,16 +304,13 @@
@with_default_category('Application-Specific Commands')
class AddlShellCommands(CommandSet):
- def __init(self):
- super().__init__()
-
- def do_aram_get_all(self, opts):
+ def do_aram_get_all(self, _opts):
"""GET DATA [All] on the ARA-M Applet"""
res_do = ADF_ARAM.get_all(self._cmd.lchan.scc._tp)
if res_do:
self._cmd.poutput_json(res_do.to_dict())
- def do_aram_get_config(self, opts):
+ def do_aram_get_config(self, _opts):
"""Perform GET DATA [Config] on the ARA-M Applet: Tell it our version and retrieve its version."""
res_do = ADF_ARAM.get_config(self._cmd.lchan.scc._tp)
if res_do:
@@ -353,7 +348,7 @@
"""Perform STORE DATA [Command-Store-REF-AR-DO] to store a (new) access rule."""
# REF
ref_do_content = []
- if opts.aid != None:
+ if opts.aid is not None:
ref_do_content += [{'aid_ref_do': opts.aid}]
elif opts.aid_empty:
ref_do_content += [{'aid_ref_empty_do': None}]
@@ -382,7 +377,7 @@
if res_do:
self._cmd.poutput_json(res_do.to_dict())
- def do_aram_delete_all(self, opts):
+ def do_aram_delete_all(self, _opts):
"""Perform STORE DATA [Command-Delete[all]] to delete all access rules."""
deldo = CommandDelete()
res_do = ADF_ARAM.store_data(self._cmd.lchan.scc._tp, deldo)