eric6/MicroPython/MicroPythonCommandsInterface.py

branch
micropython
changeset 7137
4ed2573947ff
parent 7136
bddcb634a9b8
child 7174
de8175253dfc
diff -r bddcb634a9b8 -r 4ed2573947ff eric6/MicroPython/MicroPythonCommandsInterface.py
--- a/eric6/MicroPython/MicroPythonCommandsInterface.py	Tue Aug 13 16:39:31 2019 +0200
+++ b/eric6/MicroPython/MicroPythonCommandsInterface.py	Tue Aug 13 17:52:58 2019 +0200
@@ -311,7 +311,7 @@
             raise IOError(self.__shortError(err))
         return ast.literal_eval(out.decode("utf-8"))
     
-    def lls(self, dirname="", fullstat=False):
+    def lls(self, dirname="", fullstat=False, showHidden=False):
         """
         Public method to get a long directory listing of the connected device
         including meta data.
@@ -320,6 +320,8 @@
         @type str
         @param fullstat flag indicating to return the full stat() tuple
         @type bool
+        @param showHidden flag indicating to show hidden files as well
+        @type bool
         @return list containing the directory listing with tuple entries of
             the name and and a tuple of mode, size and time (if fullstat is
             false) or the complete stat() tuple. 'None' is returned in case the
@@ -332,8 +334,9 @@
             commands = [
                 "import os as __os_",
                 "\n".join([
-                    "def is_visible(filename):",
-                    "    return filename[0] != '.' and filename[-1] != '~'",
+                    "def is_visible(filename, showHidden):",
+                    "    return showHidden or "
+                    "(filename[0] != '.' and filename[-1] != '~')",
                 ]),
                 "\n".join([
                     "def stat(filename):",
@@ -341,20 +344,21 @@
                     "    return (0, 0, 0, 0, 0, 0, size, 0, 0, 0)"
                 ]),
                 "\n".join([
-                    "def listdir_stat():",
+                    "def listdir_stat(showHidden):",
                     "    files = __os_.listdir()",
                     "    return list((f, stat(f)) for f in files if"
-                    " is_visible(f))",
+                    " is_visible(f,showHidden))",
                 ]),
-                "print(listdir_stat())",
+                "print(listdir_stat({0}))".format(showHidden),
                 "del __os_, stat, listdir_stat, is_visible",
             ]
         else:
             commands = [
                 "import os as __os_",
                 "\n".join([
-                    "def is_visible(filename):",
-                    "    return filename[0] != '.' and filename[-1] != '~'",
+                    "def is_visible(filename, showHidden):",
+                    "    return showHidden or "
+                    "(filename[0] != '.' and filename[-1] != '~')",
                 ]),
                 "\n".join([
                     "def stat(filename):",
@@ -365,18 +369,18 @@
                     "    return tuple(rstat)",
                 ]),
                 "\n".join([
-                    "def listdir_stat(dirname):",
+                    "def listdir_stat(dirname, showHidden):",
                     "    try:",
                     "        files = __os_.listdir(dirname)",
                     "    except OSError:",
                     "        return None",
                     "    if dirname in ('', '/'):",
                     "        return list((f, stat(f)) for f in files if"
-                    " is_visible(f))",
+                    " is_visible(f, showHidden))",
                     "    return list((f, stat(dirname + '/' + f))"
-                    " for f in files if is_visible(f))",
+                    " for f in files if is_visible(f, showHidden))",
                 ]),
-                "print(listdir_stat('{0}'))".format(dirname),
+                "print(listdir_stat('{0}', {1}))".format(dirname, showHidden),
                 "del __os_, stat, listdir_stat, is_visible",
             ]
         out, err = self.execute(commands)

eric ide

mercurial