MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / LocalFileClass

Class LocalFileClass

apps/admin/services.py:1586–1610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1584
1585
1586class LocalFileClass:
1587 def __init__(self, file):
1588 self.file = file
1589 self.path = data_root / "local" / file
1590 if os.path.exists(self.path):
1591 self.ctime = time.strftime(
1592 "%Y-%m-%d %H:%M:%S", time.localtime(os.path.getctime(self.path))
1593 )
1594 self.size = os.path.getsize(self.path)
1595 else:
1596 self.ctime = None
1597 self.size = None
1598
1599 async def read(self):
1600 return open(self.path, "rb")
1601
1602 async def write(self, data):
1603 with open(self.path, "w") as f:
1604 f.write(data)
1605
1606 async def delete(self):
1607 os.remove(self.path)
1608
1609 async def exists(self):
1610 return os.path.exists(self.path)

Callers 3

share_local_fileMethod · 0.85
list_filesMethod · 0.85
delete_fileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected