<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/pysim/+/23208">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pySim-shell: add functionality to walk through the fs recursively<br><br>We might add functionality that may require to walk through the entire<br>filesystem tree to perform an action to all files at once. Lets add a<br>generic walker that gets a function pointer that can carray out a file<br>specific action then. Also add another command that just displays the<br>whole filesystem tree.<br><br>Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8<br>Related: OS#4963<br>---<br>M pySim-shell.py<br>1 file changed, 17 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/08/23208/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/pySim-shell.py b/pySim-shell.py</span><br><span>index a254121..4544220 100755</span><br><span>--- a/pySim-shell.py</span><br><span>+++ b/pySim-shell.py</span><br><span>@@ -131,6 +131,23 @@</span><br><span>                self._cmd.poutput(directory_str)</span><br><span>             self._cmd.poutput("%d files" % len(file_list))</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+  def walk(self, indent = 0, action = None):</span><br><span style="color: hsl(120, 100%, 40%);">+            """Recursively walk through the file system, starting at the currently selected DF"""</span><br><span style="color: hsl(120, 100%, 40%);">+           files = self._cmd.rs.selected_file.get_selectable_names(flags = ['NAMES', 'APPS'])</span><br><span style="color: hsl(120, 100%, 40%);">+            for f in files:</span><br><span style="color: hsl(120, 100%, 40%);">+                       if not action:</span><br><span style="color: hsl(120, 100%, 40%);">+                                print ("  " * indent + str(f))</span><br><span style="color: hsl(120, 100%, 40%);">+                      if f[0:2] == "DF" or f[0:3] == 'ADF':</span><br><span style="color: hsl(120, 100%, 40%);">+                               fcp_dec = self._cmd.rs.select(f, self._cmd)</span><br><span style="color: hsl(120, 100%, 40%);">+                           self.walk(indent + 1, action)</span><br><span style="color: hsl(120, 100%, 40%);">+                         fcp_dec = self._cmd.rs.select("..", self._cmd)</span><br><span style="color: hsl(120, 100%, 40%);">+                      elif action:</span><br><span style="color: hsl(120, 100%, 40%);">+                          action(f)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   def do_tree(self, opts):</span><br><span style="color: hsl(120, 100%, 40%);">+              """Display a filesystem-tree with all selectable files"""</span><br><span style="color: hsl(120, 100%, 40%);">+               self.walk()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> </span><br><span> </span><br><span> @with_default_category('USIM Commands')</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/pysim/+/23208">change 23208</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/+/23208"/><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: If93d24dfb80c83eda39303c936910fa1fa7f48f8 </div>
<div style="display:none"> Gerrit-Change-Number: 23208 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>