secretproject/main.py

25 lines
436 B
Python
Raw Normal View History

2024-06-28 14:59:00 +02:00
from dataclasses import dataclass
from io import BufferedRandom
@dataclass
class Shard:
size: int
file: BufferedRandom
@staticmethod
def load_shard(filename: str) -> 'Shard':
file = open(filename, 'rb+')
size = int.from_bytes(file.read(8), 'big')
return Shard(size, file)
@dataclass
class Entry:
shard: Shard
content: bytearray
shart = Shard.load_shard('myfile')
print(shart.size)