##// END OF EJS Templates
ipy_fsops: inherit pathobj from path
vivainio -
Show More
@@ -185,7 +185,7 def pathobj_unmangle(s):
185
185
186
186
187
187
188 class PathObj:
188 class PathObj(path):
189 def __init__(self,p):
189 def __init__(self,p):
190 self.path = p
190 self.path = p
191 if p != '.':
191 if p != '.':
@@ -223,9 +223,11 class PathObj:
223 os.chdir(self.path)
223 os.chdir(self.path)
224
224
225 def complete_pathobj(obj, prev_completions):
225 def complete_pathobj(obj, prev_completions):
226
227 if hasattr(obj,'__complete__'):
226 if hasattr(obj,'__complete__'):
228 return obj.__complete__()
227 res = obj.__complete__()
228 if res:
229 return res
230 # just return normal attributes of 'path' object if the dir is empty
229 raise IPython.ipapi.TryNext
231 raise IPython.ipapi.TryNext
230
232
231 complete_pathobj = IPython.generics.complete_object.when_type(PathObj)(complete_pathobj)
233 complete_pathobj = IPython.generics.complete_object.when_type(PathObj)(complete_pathobj)
@@ -234,9 +236,9 def test_pathobj():
234 #p = PathObj('c:/prj')
236 #p = PathObj('c:/prj')
235 #p2 = p.cgi
237 #p2 = p.cgi
236 #print p,p2
238 #print p,p2
237 croot = PathObj("c:/")
239 rootdir = PathObj("/")
238 startmenu = PathObj("d:/Documents and Settings/All Users/Start Menu/Programs")
240 startmenu = PathObj("d:/Documents and Settings/All Users/Start Menu/Programs")
239 cwd = PathObj('.')
241 cwd = PathObj('.')
240 ip.to_user_ns("croot startmenu cwd")
242 ip.to_user_ns("rootdir startmenu cwd")
241
243
242 #test_pathobj() No newline at end of file
244 #test_pathobj()
General Comments 0
You need to be logged in to leave comments. Login now