MCPcopy
hub / github.com/RUB-NDS/PRET / do_ls

Method do_ls

postscript.py:180–203  ·  view source on GitHub ↗

List contents of remote directory: ls

(self, arg)

Source from the content-addressed store, hash-verified

178
179 # ------------------------[ ls <path> ]-------------------------------
180 def do_ls(self, arg):
181 "List contents of remote directory: ls <path>"
182 path = self.rpath(arg) + self.get_sep(arg)
183 list = self.dirlist(arg)
184 cwdlist = []
185 # create file list without subdirs
186 for name in list:
187 max = len(path.split(c.SEP))
188 name = c.SEP.join(name.split(c.SEP)[:max])
189 # add new and non-empty filenames to list
190 if not name in cwdlist and re.sub("^(%.*%)", '', name):
191 cwdlist.append(name)
192 # get metadata for files in cwd
193 for name in cwdlist:
194 isdir = self.dir_exists(name, list) # check if file is directory
195 metadata = self.file_exists(name, True) if not isdir else None
196 if metadata == c.FILE_EXISTS or isdir: # create dummy metadata
197 (size, otime, mtime) = ('-', conv().lsdate(0), conv().lsdate(0))
198 elif metadata != c.NONEXISTENT:
199 size, otime, mtime = metadata
200 if metadata != c.NONEXISTENT: # we got real or dummy metadata
201 output().psdir(isdir, size, otime, self.basename(name), mtime)
202 else:
203 output().errmsg("Crippled filename", 'Bad interpreter')
204
205 # ------------------------[ find <path> ]-----------------------------
206 def do_find(self, arg):

Callers

nothing calls this directly

Calls 12

dirlistMethod · 0.95
dir_existsMethod · 0.95
file_existsMethod · 0.95
convClass · 0.90
outputClass · 0.90
rpathMethod · 0.80
get_sepMethod · 0.80
lsdateMethod · 0.80
psdirMethod · 0.80
basenameMethod · 0.80
errmsgMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected