Commit 36b626d8 by willmcgugan

Just some tweaks

parent e6834c21
...@@ -134,12 +134,12 @@ def makerelative(path): ...@@ -134,12 +134,12 @@ def makerelative(path):
return path return path
def _iteratepath(path, numsplits=None): def _iteratepath(path, numsplits=None):
path = resolvepath(path) path = resolvepath(path)
if not path: if not path:
return [] return []
if numsplits == None: if numsplits == None:
return filter(lambda p:bool(p), path.split('/')) return filter(lambda p:bool(p), path.split('/'))
else: else:
...@@ -175,7 +175,7 @@ class FS(object): ...@@ -175,7 +175,7 @@ class FS(object):
def _resolve(self, pathname): def _resolve(self, pathname):
resolved_path = resolvepath(pathname) resolved_path = resolvepath(pathname)
return resolved_path return resolved_path
...@@ -267,12 +267,12 @@ class OSFS(FS): ...@@ -267,12 +267,12 @@ class OSFS(FS):
def __init__(self, root_path): def __init__(self, root_path):
expanded_path = normpath(os.path.expanduser(root_path)) expanded_path = normpath(os.path.expanduser(root_path))
if not os.path.exists(expanded_path): if not os.path.exists(expanded_path):
raise FSError("NO_DIR", expanded_path, msg="Root directory does not exist: %(path)s") raise FSError("NO_DIR", expanded_path, msg="Root directory does not exist: %(path)s")
if not os.path.isdir(expanded_path): if not os.path.isdir(expanded_path):
raise FSError("NO_DIR", expanded_path, msg="Root path is not a directory: %(path)s") raise FSError("NO_DIR", expanded_path, msg="Root path is not a directory: %(path)s")
self.root_path = normpath(os.path.abspath(expanded_path)) self.root_path = normpath(os.path.abspath(expanded_path))
#print "Root path", self.root_path #print "Root path", self.root_path
...@@ -282,8 +282,8 @@ class OSFS(FS): ...@@ -282,8 +282,8 @@ class OSFS(FS):
def getsyspath(self, pathname): def getsyspath(self, pathname):
sys_path = os.path.join(self.root_path, makerelative(self._resolve(pathname))) sys_path = os.path.join(self.root_path, makerelative(self._resolve(pathname)))
return sys_path return sys_path
...@@ -327,17 +327,17 @@ class OSFS(FS): ...@@ -327,17 +327,17 @@ class OSFS(FS):
def mkdir(self, path, mode=0777, recursive=False): def mkdir(self, path, mode=0777, recursive=False):
sys_path = self.getsyspath(path) sys_path = self.getsyspath(path)
if recursive: if recursive:
makedirs(sys_path, mode) makedirs(sys_path, mode)
else: else:
makedir(sys_path, mode) makedir(sys_path, mode)
def remove(self, path): def remove(self, path):
sys_path = self.getsyspath(path) sys_path = self.getsyspath(path)
os.remove(sys_path) os.remove(sys_path)
...@@ -474,7 +474,10 @@ if __name__ == "__main__": ...@@ -474,7 +474,10 @@ if __name__ == "__main__":
print osfs print osfs
#print osfs #print osfs
print_fs(osfs) import browsewin
browsewin.browse(osfs)
#print_fs(osfs)
#print osfs.listdir("/projects/fs") #print osfs.listdir("/projects/fs")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment