mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-04-01 11:41:46 +03:00
pylint: cards.py
pySim/cards.py:30:0: W0401: Wildcard import pySim.utils (wildcard-import) pySim/cards.py:41:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return) pySim/cards.py:55:4: R1711: Useless return at end of function or method (useless-return) pySim/cards.py:78:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments) pySim/cards.py:91:8: R1725: Consider using Python 3 style super() without arguments (super-with-arguments) pySim/cards.py:159:12: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return) pySim/cards.py:28:0: C0411: standard import "import abc" should be placed before "from pySim.ts_102_221 import EF_DIR" (wrong-import-order) pySim/cards.py:25:0: W0611: Unused Dict imported from typing (unused-import) pySim/cards.py:28:0: W0611: Unused import abc (unused-import) Change-Id: I708da28caffb417ed2f8413f9611526b18b29cd4
This commit is contained in:
@@ -22,10 +22,9 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
from typing import Optional, Dict, Tuple
|
from typing import Optional, Tuple
|
||||||
from pySim.ts_102_221 import EF_DIR
|
from pySim.ts_102_221 import EF_DIR
|
||||||
from pySim.ts_51_011 import DF_GSM
|
from pySim.ts_51_011 import DF_GSM
|
||||||
import abc
|
|
||||||
|
|
||||||
from pySim.utils import *
|
from pySim.utils import *
|
||||||
from pySim.commands import Path, SimCardCommands
|
from pySim.commands import Path, SimCardCommands
|
||||||
@@ -40,8 +39,7 @@ class CardBase:
|
|||||||
rc = self._scc.reset_card()
|
rc = self._scc.reset_card()
|
||||||
if rc == 1:
|
if rc == 1:
|
||||||
return self._scc.get_atr()
|
return self._scc.get_atr()
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def set_apdu_parameter(self, cla: Hexstr, sel_ctrl: Hexstr) -> None:
|
def set_apdu_parameter(self, cla: Hexstr, sel_ctrl: Hexstr) -> None:
|
||||||
"""Set apdu parameters (class byte and selection control bytes)"""
|
"""Set apdu parameters (class byte and selection control bytes)"""
|
||||||
@@ -54,7 +52,6 @@ class CardBase:
|
|||||||
|
|
||||||
def erase(self):
|
def erase(self):
|
||||||
print("warning: erasing is not supported for specified card type!")
|
print("warning: erasing is not supported for specified card type!")
|
||||||
return
|
|
||||||
|
|
||||||
def file_exists(self, fid: Path) -> bool:
|
def file_exists(self, fid: Path) -> bool:
|
||||||
res_arr = self._scc.try_select_path(fid)
|
res_arr = self._scc.try_select_path(fid)
|
||||||
@@ -75,7 +72,7 @@ class SimCardBase(CardBase):
|
|||||||
name = 'SIM'
|
name = 'SIM'
|
||||||
|
|
||||||
def __init__(self, scc: SimCardCommands):
|
def __init__(self, scc: SimCardCommands):
|
||||||
super(SimCardBase, self).__init__(scc)
|
super().__init__(scc)
|
||||||
self._scc.cla_byte = "A0"
|
self._scc.cla_byte = "A0"
|
||||||
self._scc.sel_ctrl = "0000"
|
self._scc.sel_ctrl = "0000"
|
||||||
|
|
||||||
@@ -88,7 +85,7 @@ class UiccCardBase(SimCardBase):
|
|||||||
name = 'UICC'
|
name = 'UICC'
|
||||||
|
|
||||||
def __init__(self, scc: SimCardCommands):
|
def __init__(self, scc: SimCardCommands):
|
||||||
super(UiccCardBase, self).__init__(scc)
|
super().__init__(scc)
|
||||||
self._scc.cla_byte = "00"
|
self._scc.cla_byte = "00"
|
||||||
self._scc.sel_ctrl = "0004" # request an FCP
|
self._scc.sel_ctrl = "0004" # request an FCP
|
||||||
# See also: ETSI TS 102 221, Table 9.3
|
# See also: ETSI TS 102 221, Table 9.3
|
||||||
@@ -158,9 +155,8 @@ class UiccCardBase(SimCardBase):
|
|||||||
aid_full = self._complete_aid(aid)
|
aid_full = self._complete_aid(aid)
|
||||||
if aid_full:
|
if aid_full:
|
||||||
return scc.select_adf(aid_full)
|
return scc.select_adf(aid_full)
|
||||||
else:
|
# If we cannot get the full AID, try with short AID
|
||||||
# If we cannot get the full AID, try with short AID
|
return scc.select_adf(aid)
|
||||||
return scc.select_adf(aid)
|
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
def card_detect(scc: SimCardCommands) -> Optional[CardBase]:
|
def card_detect(scc: SimCardCommands) -> Optional[CardBase]:
|
||||||
|
|||||||
Reference in New Issue
Block a user