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

Method get

postscript.py:229–243  ·  view source on GitHub ↗
(self, path, size=None)

Source from the content-addressed store, hash-verified

227
228 # ------------------------[ get <file> ]------------------------------
229 def get(self, path, size=None):
230 if not size:
231 size = self.file_exists(path)
232 if size != c.NONEXISTENT:
233 # read file, one byte at a time
234 str_recv = self.cmd('/byte (0) def\n'
235 + '/infile (' + path + ') (r) file def\n'
236 + '{infile read {byte exch 0 exch put\n'
237 + '(%stdout) (w) file byte writestring}\n'
238 + '{infile closefile exit} ifelse\n'
239 + '} loop', True, True, True)
240 return (size, str_recv)
241 else:
242 print("File not found.")
243 return c.NONEXISTENT
244
245 # ------------------------[ put <local file> ]------------------------
246 def put(self, path, data, mode='w+'):

Callers

nothing calls this directly

Calls 2

file_existsMethod · 0.95
cmdMethod · 0.95

Tested by

no test coverage detected