MCPcopy Index your code
hub / github.com/algorithmiaio/algorithmia-python / cp

Method cp

Algorithmia/CLI.py:248–291  ·  view source on GitHub ↗
(self, src, dest, client)

Source from the content-addressed store, hash-verified

246
247 # algo cp <src> <dest>
248 def cp(self, src, dest, client):
249
250 if (src is None or dest is None):
251 print("expected algo cp <src> <dest>")
252 else:
253
254 destLocation = client.file(dest)
255 for f in src:
256
257 # if dest is a directory apend the src name
258 # if there are multiple src files only the final one will be copied if dest is not a directory
259 destPath = dest
260
261 path = dest.split('/')
262
263 if (os.path.isdir(dest) or client.dir(dest).exists() and len(path) <= 5):
264 if (dest[-1] == '/' and path[-1] == ''):
265 destPath += client.file(f).getName()
266 elif (len(path) == 4 or "data://" not in dest):
267 destPath += '/' + client.file(f).getName()
268
269 if (f[-1] == '*'):
270 src += ['data://' + file.path for file in client.dir(f[:len(f) - 2]).files()]
271
272 # if src is local and dest is remote
273 elif ("data://" not in f and "data://" in dest):
274 client.file(destPath).putFile(f)
275
276 # if src and dest are remote
277 elif ("data://" in f and "data://" in dest):
278 file = client.file(f).getFile()
279 filename = file.name
280 file.close()
281
282 client.file(destPath).putFile(filename)
283
284 # if src is remote and dest is local
285 elif ("data://" in f and "data://" not in dest):
286 file = client.file(f).getFile()
287 filename = file.name
288 file.close()
289 shutil.move(filename, destPath)
290 else:
291 print("at least one of the operands must be a path to a remote data source data://")
292
293 def get_environment_by_language(self, language, client):
294 response = client.get_environment(language)

Callers 6

mainFunction · 0.80
test_catMethod · 0.80
test_cp_L2RMethod · 0.80
test_cp_R2RMethod · 0.80
test_cp_R2LMethod · 0.80
test_rmMethod · 0.80

Calls 7

fileMethod · 0.45
existsMethod · 0.45
dirMethod · 0.45
getNameMethod · 0.45
filesMethod · 0.45
putFileMethod · 0.45
getFileMethod · 0.45

Tested by 5

test_catMethod · 0.64
test_cp_L2RMethod · 0.64
test_cp_R2RMethod · 0.64
test_cp_R2LMethod · 0.64
test_rmMethod · 0.64