Create standalone borg classes
This commit is contained in:
parent
7ded6889d8
commit
06331f4a83
3
src/borg/__init__.py
Normal file
3
src/borg/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from .repo import Repo
|
||||
from .archive import Archive
|
||||
from .stats import Stats
|
21
src/borg/archive.py
Normal file
21
src/borg/archive.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from datetime import datetime
|
||||
|
||||
|
||||
class Archive(object):
|
||||
def __init__(self, fingerprint: str, name: str, start: datetime, end: datetime):
|
||||
self.fingerprint = fingerprint
|
||||
self.name = name
|
||||
self.start = start
|
||||
self.end = end
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: dict):
|
||||
uuid = json['id']
|
||||
name = json['name']
|
||||
start = datetime.fromisoformat(json['start'])
|
||||
end = datetime.fromisoformat(json['end'])
|
||||
return cls(uuid, name, start, end)
|
||||
|
||||
@classmethod
|
||||
def from_sql(cls, sql: list):
|
||||
pass
|
20
src/borg/repo.py
Normal file
20
src/borg/repo.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class Repo(object):
|
||||
def __init__(self, fingerprint: str, location: Path, last_modified: datetime):
|
||||
self.fingerprint = fingerprint
|
||||
self.location = location
|
||||
self.last_modified = last_modified
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: dict):
|
||||
uuid = json['id']
|
||||
location = Path(json['location'])
|
||||
last_modified = datetime.fromisoformat(json['last_modified'])
|
||||
return cls(uuid, location, last_modified)
|
||||
|
||||
@classmethod
|
||||
def from_sql(cls, sql: list):
|
||||
pass
|
18
src/borg/stats.py
Normal file
18
src/borg/stats.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
class Stats(object):
|
||||
def __init__(self, file_count: int, original_size: int, compressed_size: int, deduplicated_size: int):
|
||||
self.file_count = file_count
|
||||
self.original_size = original_size
|
||||
self.compressed_size = compressed_size
|
||||
self.deduplicated_size = deduplicated_size
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json: dict):
|
||||
file_count = json['nfiles']
|
||||
original_size = json['original_size']
|
||||
compressed_size = json['compressed_size']
|
||||
deduplicated_size = json['deduplicated_size']
|
||||
return cls(file_count, original_size, compressed_size, deduplicated_size)
|
||||
|
||||
@classmethod
|
||||
def from_sql(cls, sql: list):
|
||||
pass
|
Loading…
Reference in New Issue
Block a user