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

Method put

pcl.py:160–179  ·  view source on GitHub ↗
(self, path, data)

Source from the content-addressed store, hash-verified

158
159 # ------------------------[ put <local file> ]------------------------
160 def put(self, path, data):
161 path = self.basename(path)
162 pclfs = self.dirlist()
163 # re-use macro id if file name already present
164 if path in pclfs:
165 id = pclfs[path][0]
166 # find free macro id not already reserved for file
167 else:
168 id = str(item(set(c.BLOCKRANGE).difference(self.idlist())))
169 # abort if we have used up the whole macro id space
170 if not id:
171 return output().warning("Out of macro slots.")
172 self.chitchat("Using macro id #" + id)
173 # retrieve and update superblock
174 size = str(len(data))
175 date = str(conv().now())
176 pclfs[path] = [id, size, date]
177 self.update_superblock(pclfs)
178 # save data as pcl macro on printer
179 self.define_macro(id, data)
180
181 # ====================================================================
182

Callers

nothing calls this directly

Calls 11

dirlistMethod · 0.95
idlistMethod · 0.95
update_superblockMethod · 0.95
define_macroMethod · 0.95
itemFunction · 0.90
outputClass · 0.90
convClass · 0.90
basenameMethod · 0.80
warningMethod · 0.80
nowMethod · 0.80
chitchatMethod · 0.45

Tested by

no test coverage detected