-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser.py
More file actions
30 lines (22 loc) · 792 Bytes
/
Copy pathbrowser.py
File metadata and controls
30 lines (22 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os.path
import urwid
class FileBrowser():
currentlocation = "/"
def __init__(self, startdir):
startdir = self.reformat(startdir)
self.currentlocation = startdir
def reformat(self, dirname):
if dirname [-1] != '/':
dirname += '/'
return dirname
def up(self):
self.currentlocation = self.reformat(os.path.realpath(self.currentlocation + "../"))
def cd(self, dirname):
dirname = self.reformat(dirname)
if os.path.exists(self.currentlocation + dirname):
self.currentlocation += dirname
def ls(self, ):
for (dirpath, dirnames, filenames) in os.walk(self.currentlocation):
return (dirnames, filenames)
def pwd(self, ):
return self.currentlocation