Change in pysim[master]: pySim-shell: add functionality to walk through the fs recursively

laforge gerrit-no-reply at lists.osmocom.org
Wed Mar 3 07:51:44 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23208 )


Change subject: pySim-shell: add functionality to walk through the fs recursively
......................................................................

pySim-shell: add functionality to walk through the fs recursively

We might add functionality that may require to walk through the entire
filesystem tree to perform an action to all files at once. Lets add a
generic walker that gets a function pointer that can carray out a file
specific action then. Also add another command that just displays the
whole filesystem tree.

Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Related: OS#4963
---
M pySim-shell.py
1 file changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/08/23208/1

diff --git a/pySim-shell.py b/pySim-shell.py
index a254121..4544220 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -131,6 +131,23 @@
 		self._cmd.poutput(directory_str)
 		self._cmd.poutput("%d files" % len(file_list))
 
+	def walk(self, indent = 0, action = None):
+		"""Recursively walk through the file system, starting at the currently selected DF"""
+		files = self._cmd.rs.selected_file.get_selectable_names(flags = ['NAMES', 'APPS'])
+		for f in files:
+			if not action:
+				print ("  " * indent + str(f))
+			if f[0:2] == "DF" or f[0:3] == 'ADF':
+				fcp_dec = self._cmd.rs.select(f, self._cmd)
+				self.walk(indent + 1, action)
+				fcp_dec = self._cmd.rs.select("..", self._cmd)
+			elif action:
+				action(f)
+
+	def do_tree(self, opts):
+		"""Display a filesystem-tree with all selectable files"""
+		self.walk()
+
 
 
 @with_default_category('USIM Commands')

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23208
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If93d24dfb80c83eda39303c936910fa1fa7f48f8
Gerrit-Change-Number: 23208
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210303/cf5b0690/attachment.htm>


More information about the gerrit-log mailing list