Simplify archiving process (#469)

* simplify args

* Fix tests

* Black format
This commit is contained in:
Anton Osika
2023-07-02 16:43:13 +02:00
committed by GitHub
parent 60e0a7e1dd
commit 20ea0c126a
6 changed files with 40 additions and 45 deletions

View File

@@ -1,6 +1,8 @@
import datetime
import shutil
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
# This class represents a simple database that stores its data as files in a directory.
@@ -49,3 +51,15 @@ class DBs:
input: DB
workspace: DB
archive: DB
def archive(dbs: DBs):
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
shutil.move(
str(dbs.memory.path), str(dbs.archive.path / timestamp / dbs.memory.path.name)
)
shutil.move(
str(dbs.workspace.path),
str(dbs.archive.path / timestamp / dbs.workspace.path.name),
)
return []