mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-17 20:55:09 +01:00
Separate into steps and wrap filesystem access
This commit is contained in:
28
db.py
Normal file
28
db.py
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
from dataclasses import dataclass
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class DB:
|
||||
def __init__(self, path):
|
||||
self.path = Path(path).absolute()
|
||||
os.makedirs(self.path, exist_ok=True)
|
||||
|
||||
def __getitem__(self, key):
|
||||
with open(self.path / key) as f:
|
||||
return f.read()
|
||||
|
||||
def __setitem__(self, key, val):
|
||||
with open(self.path / key, 'w') as f:
|
||||
f.write(val)
|
||||
|
||||
|
||||
# dataclass for all dbs:
|
||||
@dataclass
|
||||
class DBs:
|
||||
memory: DB
|
||||
logs: DB
|
||||
identity: DB
|
||||
input: DB
|
||||
workspace: DB
|
||||
Reference in New Issue
Block a user