This commit is contained in:
Marc Beninca 2024-03-15 10:32:19 +01:00
parent 3eccd76e8c
commit 2eb71e6412
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
14 changed files with 0 additions and 0 deletions

28
mrmp/package.py Normal file
View file

@ -0,0 +1,28 @@
import os
CHARSET = 'u8'
KEY = '%'
SEPARATOR = f'{os.linesep}{os.linesep}'
class Package:
def __init__(self, package, files):
for binary in [package, files]:
text = binary.decode(CHARSET).strip()
for item in text.split(SEPARATOR):
line, *lines = item.split(os.linesep)
key = line.split(KEY)[1].lower()
if len(lines) == 1:
value = lines[0]
else:
value = lines
setattr(self, key, value)
def __str__(self):
lines = [
f' Name: {self.name}',
f'FileName: {self.filename}',
f' Size: {self.csize}',
f' Hash: {self.sha256sum}',
]
return os.linesep.join(lines)