diff --git a/README.md b/README.md index 8327a79..fdb127f 100644 --- a/README.md +++ b/README.md @@ -2410,12 +2410,12 @@ Curses ------ #### Runs a basic file explorer in the terminal: ```python -from curses import wrapper, ascii, A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER -from os import listdir, path, chdir +import curses, curses.ascii, os +from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER def main(screen): - ch, first, selected, paths = 0, 0, 0, listdir() - while ch != ascii.ESC: + ch, first, selected, paths = 0, 0, 0, os.listdir() + while ch != curses.ascii.ESC: height, _ = screen.getmaxyx() screen.erase() for y, filename in enumerate(paths[first : first+height]): @@ -2426,12 +2426,12 @@ def main(screen): first += (first <= selected - height) - (first > selected) if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, 10, 13]: new_dir = '..' if ch == KEY_LEFT else paths[selected] - if path.isdir(new_dir): - chdir(new_dir) - first, selected, paths = 0, 0, listdir() + if os.path.isdir(new_dir): + os.chdir(new_dir) + first, selected, paths = 0, 0, os.listdir() if __name__ == '__main__': - wrapper(main) + curses.wrapper(main) ``` diff --git a/index.html b/index.html index 16b9665..3ac8943 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1976,12 +1976,12 @@ print(table) -

#Curses

Runs a basic file explorer in the terminal:

from curses import wrapper, ascii, A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
-from os import listdir, path, chdir
+

#Curses

Runs a basic file explorer in the terminal:

import curses, curses.ascii, os
+from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
 
 def main(screen):
-    ch, first, selected, paths = 0, 0, 0, listdir()
-    while ch != ascii.ESC:
+    ch, first, selected, paths = 0, 0, 0, os.listdir()
+    while ch != curses.ascii.ESC:
         height, _ = screen.getmaxyx()
         screen.erase()
         for y, filename in enumerate(paths[first : first+height]):
@@ -1992,12 +1992,12 @@ print(table)
         first += (first <= selected - height) - (first > selected)
         if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, 10, 13]:
             new_dir = '..' if ch == KEY_LEFT else paths[selected]
-            if path.isdir(new_dir):
-                chdir(new_dir)
-                first, selected, paths = 0, 0, listdir()
+            if os.path.isdir(new_dir):
+                os.chdir(new_dir)
+                first, selected, paths = 0, 0, os.listdir()
 
 if __name__ == '__main__':
-    wrapper(main)
+    curses.wrapper(main)
 
@@ -2906,7 +2906,7 @@ $ pyinstaller script.py --add-data '<path>:.'