mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
feature: web project
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import pickle
|
||||
|
||||
from typing import List, Tuple
|
||||
from model.settings import Settings
|
||||
|
||||
|
||||
class Project():
|
||||
def __init__(self, name: str, settings: Settings):
|
||||
self.name = name
|
||||
self.settings: Settings = settings
|
||||
|
||||
|
||||
class Storage():
|
||||
def __init__(self):
|
||||
self.data: List[Project] = self.get_data()
|
||||
|
||||
def get_project(self, name):
|
||||
for project in self.data:
|
||||
if project.name == name:
|
||||
return project
|
||||
return None
|
||||
|
||||
def add_project(self, project):
|
||||
self.data.append(project)
|
||||
self.save_data()
|
||||
|
||||
def get_data(self):
|
||||
print("Read data")
|
||||
with open("app/data.pickle", "rb") as f:
|
||||
data = f.read()
|
||||
data = pickle.loads(data)
|
||||
|
||||
for project in data:
|
||||
print(" {}".format(project.name))
|
||||
|
||||
return data
|
||||
|
||||
def save_data(self):
|
||||
print("Save data")
|
||||
with open("app/data.pickle", "wb") as f:
|
||||
f.write(pickle.dumps(self.data))
|
||||
|
||||
storage = Storage()
|
||||
Reference in New Issue
Block a user