MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / write

Method write

src/Site/SiteStorage.py:226–243  ·  view source on GitHub ↗
(self, inner_path, content)

Source from the content-addressed store, hash-verified

224
225 # Write content to file
226 def write(self, inner_path, content):
227 file_path = self.getPath(inner_path)
228 # Create dir if not exist
229 file_dir = os.path.dirname(file_path)
230 if not os.path.isdir(file_dir):
231 os.makedirs(file_dir)
232 # Write file
233 if hasattr(content, 'read'): # File-like object
234 with open(file_path, "wb") as file:
235 shutil.copyfileobj(content, file) # Write buff to disk
236 else: # Simple string
237 if inner_path == "content.json" and os.path.isfile(file_path):
238 helper.atomicWrite(file_path, content)
239 else:
240 with open(file_path, "wb") as file:
241 file.write(content)
242 del content
243 self.onUpdated(inner_path)
244
245 # Remove file from filesystem
246 def delete(self, inner_path):

Callers 15

writeJsonMethod · 0.95
updateFunction · 0.45
saveValueMethod · 0.45
main.pyFile · 0.45
siteCreateMethod · 0.45
actionFileWriteMethod · 0.45
is_testnetFunction · 0.45
helloblock_unspentFunction · 0.45
historyFunction · 0.45
downloadContentMethod · 0.45
handleStreamMethod · 0.45
downloaderMethod · 0.45

Calls 2

getPathMethod · 0.95
onUpdatedMethod · 0.95

Tested by

no test coverage detected