<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/26205">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ts_51_011: move _decode_select_response into profile class<br><br>The method decode_select_response just calls the function<br>_decode_select_response. But the function _decode_select_response<br>is not called from any other location, so we can move it into the<br>profile class.<br><br>Change-Id: Icf0143f64ca7d1c1ebf60ba06585f7afc1ac0d11<br>---<br>M pySim/ts_51_011.py<br>1 file changed, 38 insertions(+), 44 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py</span><br><span>index 393277b..2d3ad0c 100644</span><br><span>--- a/pySim/ts_51_011.py</span><br><span>+++ b/pySim/ts_51_011.py</span><br><span>@@ -934,48 +934,6 @@</span><br><span>           ]</span><br><span>         self.add_files(files)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-def _decode_select_response(resp_hex):</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    resp_bin = h2b(resp_hex)</span><br><span style="color: hsl(0, 100%, 40%);">-    struct_of_file_map = {</span><br><span style="color: hsl(0, 100%, 40%);">-        0: 'transparent',</span><br><span style="color: hsl(0, 100%, 40%);">-        1: 'linear_fixed',</span><br><span style="color: hsl(0, 100%, 40%);">-        3: 'cyclic'</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(0, 100%, 40%);">-    type_of_file_map = {</span><br><span style="color: hsl(0, 100%, 40%);">-        1: 'mf',</span><br><span style="color: hsl(0, 100%, 40%);">-        2: 'df',</span><br><span style="color: hsl(0, 100%, 40%);">-        4: 'working_ef'</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(0, 100%, 40%);">-    ret = {</span><br><span style="color: hsl(0, 100%, 40%);">-        'file_descriptor': {},</span><br><span style="color: hsl(0, 100%, 40%);">-        'proprietary_info': {},</span><br><span style="color: hsl(0, 100%, 40%);">-        }</span><br><span style="color: hsl(0, 100%, 40%);">-    ret['file_id'] = b2h(resp_bin[4:6])</span><br><span style="color: hsl(0, 100%, 40%);">-    ret['proprietary_info']['available_memory'] = int.from_bytes(resp_bin[2:4], 'big')</span><br><span style="color: hsl(0, 100%, 40%);">-    file_type = type_of_file_map[resp_bin[6]] if resp_bin[6] in type_of_file_map else resp_bin[6]</span><br><span style="color: hsl(0, 100%, 40%);">-    ret['file_descriptor']['file_type'] = file_type</span><br><span style="color: hsl(0, 100%, 40%);">-    if file_type in ['mf', 'df']:</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['file_characteristics'] = b2h(resp_bin[13:14])</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['num_direct_child_df'] = resp_bin[14]</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['num_direct_child_ef'] = resp_bin[15]</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['num_chv_unblock_adm_codes'] = int(resp_bin[16])</span><br><span style="color: hsl(0, 100%, 40%);">-        # CHV / UNBLOCK CHV stats</span><br><span style="color: hsl(0, 100%, 40%);">-    elif file_type in ['working_ef']:</span><br><span style="color: hsl(0, 100%, 40%);">-        file_struct = struct_of_file_map[resp_bin[13]] if resp_bin[13] in struct_of_file_map else resp_bin[13]</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['file_descriptor']['structure'] = file_struct</span><br><span style="color: hsl(0, 100%, 40%);">-        ret['access_conditions'] = b2h(resp_bin[8:10])</span><br><span style="color: hsl(0, 100%, 40%);">-        if resp_bin[11] & 0x01 == 0:</span><br><span style="color: hsl(0, 100%, 40%);">-            ret['life_cycle_status_int'] = 'operational_activated'</span><br><span style="color: hsl(0, 100%, 40%);">-        elif resp_bin[11] & 0x04:</span><br><span style="color: hsl(0, 100%, 40%);">-            ret['life_cycle_status_int'] = 'operational_deactivated'</span><br><span style="color: hsl(0, 100%, 40%);">-        else:</span><br><span style="color: hsl(0, 100%, 40%);">-            ret['life_cycle_status_int'] = 'terminated'</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    return ret</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> class CardProfileSIM(CardProfile):</span><br><span> </span><br><span>     ORDER = 2</span><br><span>@@ -1019,8 +977,44 @@</span><br><span>           }</span><br><span> </span><br><span>         super().__init__('SIM', desc='GSM SIM Card', cla="a0", sel_ctrl="0000", files_in_mf=[DF_TELECOM(), DF_GSM()], sw=sw)</span><br><span style="color: hsl(0, 100%, 40%);">-    def decode_select_response(self, data_hex:str) -> Any:</span><br><span style="color: hsl(0, 100%, 40%);">-           return _decode_select_response(data_hex)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    def decode_select_response(self, resp_hex:str) -> Any:</span><br><span style="color: hsl(120, 100%, 40%);">+        resp_bin = h2b(resp_hex)</span><br><span style="color: hsl(120, 100%, 40%);">+        struct_of_file_map = {</span><br><span style="color: hsl(120, 100%, 40%);">+            0: 'transparent',</span><br><span style="color: hsl(120, 100%, 40%);">+            1: 'linear_fixed',</span><br><span style="color: hsl(120, 100%, 40%);">+            3: 'cyclic'</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+        type_of_file_map = {</span><br><span style="color: hsl(120, 100%, 40%);">+            1: 'mf',</span><br><span style="color: hsl(120, 100%, 40%);">+            2: 'df',</span><br><span style="color: hsl(120, 100%, 40%);">+            4: 'working_ef'</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+        ret = {</span><br><span style="color: hsl(120, 100%, 40%);">+            'file_descriptor': {},</span><br><span style="color: hsl(120, 100%, 40%);">+            'proprietary_info': {},</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+        ret['file_id'] = b2h(resp_bin[4:6])</span><br><span style="color: hsl(120, 100%, 40%);">+        ret['proprietary_info']['available_memory'] = int.from_bytes(resp_bin[2:4], 'big')</span><br><span style="color: hsl(120, 100%, 40%);">+        file_type = type_of_file_map[resp_bin[6]] if resp_bin[6] in type_of_file_map else resp_bin[6]</span><br><span style="color: hsl(120, 100%, 40%);">+        ret['file_descriptor']['file_type'] = file_type</span><br><span style="color: hsl(120, 100%, 40%);">+        if file_type in ['mf', 'df']:</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['file_characteristics'] = b2h(resp_bin[13:14])</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['num_direct_child_df'] = resp_bin[14]</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['num_direct_child_ef'] = resp_bin[15]</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['num_chv_unblock_adm_codes'] = int(resp_bin[16])</span><br><span style="color: hsl(120, 100%, 40%);">+            # CHV / UNBLOCK CHV stats</span><br><span style="color: hsl(120, 100%, 40%);">+        elif file_type in ['working_ef']:</span><br><span style="color: hsl(120, 100%, 40%);">+            file_struct = struct_of_file_map[resp_bin[13]] if resp_bin[13] in struct_of_file_map else resp_bin[13]</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['file_descriptor']['structure'] = file_struct</span><br><span style="color: hsl(120, 100%, 40%);">+            ret['access_conditions'] = b2h(resp_bin[8:10])</span><br><span style="color: hsl(120, 100%, 40%);">+            if resp_bin[11] & 0x01 == 0:</span><br><span style="color: hsl(120, 100%, 40%);">+                ret['life_cycle_status_int'] = 'operational_activated'</span><br><span style="color: hsl(120, 100%, 40%);">+            elif resp_bin[11] & 0x04:</span><br><span style="color: hsl(120, 100%, 40%);">+                ret['life_cycle_status_int'] = 'operational_deactivated'</span><br><span style="color: hsl(120, 100%, 40%);">+            else:</span><br><span style="color: hsl(120, 100%, 40%);">+                ret['life_cycle_status_int'] = 'terminated'</span><br><span style="color: hsl(120, 100%, 40%);">+        return ret</span><br><span> </span><br><span>     @staticmethod</span><br><span>     def match_with_card(scc:SimCardCommands) -> bool:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/26205">change 26205</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/pysim/+/26205"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: pysim </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Icf0143f64ca7d1c1ebf60ba06585f7afc1ac0d11 </div>
<div style="display:none"> Gerrit-Change-Number: 26205 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>