From befc6925f2c9c507200f83d878111813962d606e Mon Sep 17 00:00:00 2001 From: Burathar Date: Sun, 7 Mar 2021 14:31:26 +0100 Subject: [PATCH] add new files --- biscd/biscd/models/__init__.py | 1 + biscd/biscd/models/project.py | 37 ++++++++++++++++++++++++ installation-files/config_example.yaml | 12 ++++++++ installation-files/projects_example.yaml | 16 ++++++++++ 4 files changed, 66 insertions(+) create mode 100644 biscd/biscd/models/__init__.py create mode 100644 biscd/biscd/models/project.py create mode 100644 installation-files/config_example.yaml create mode 100644 installation-files/projects_example.yaml diff --git a/biscd/biscd/models/__init__.py b/biscd/biscd/models/__init__.py new file mode 100644 index 0000000..5ce17c6 --- /dev/null +++ b/biscd/biscd/models/__init__.py @@ -0,0 +1 @@ +from .project import Project diff --git a/biscd/biscd/models/project.py b/biscd/biscd/models/project.py new file mode 100644 index 0000000..6597d2c --- /dev/null +++ b/biscd/biscd/models/project.py @@ -0,0 +1,37 @@ +from pathlib import Path +import yaml +from flask import app +from biscd import config + +class Project: + _storage_file = Path(config.config_dir()) / 'projects.yaml' + + storage = {} + + def __init__(self, name): + self.name = name + + def __repr__(self): + return f"{self.__class__.__name__}(name={self.name})" + + @classmethod + def get(cls, name): + project = cls._get_projects_from_file().get(name) + if project is None: + return None + return Project(project.get('name')) + + @classmethod + def list(cls): + projects = cls._get_projects_from_file() + project_list = [] + for project in projects: + name = [*project][0] + project_list.append(name) + return project_list + + @classmethod + def _get_projects_from_file(cls): + with open(cls._storage_file) as file: + projects = yaml.load(file, yaml.FullLoader).get('projects') + return projects diff --git a/installation-files/config_example.yaml b/installation-files/config_example.yaml new file mode 100644 index 0000000..081a894 --- /dev/null +++ b/installation-files/config_example.yaml @@ -0,0 +1,12 @@ +flask_development_server: + # Options: production, development + flask_env: production + # Options: 127.0.0.1 , 0.0.0.0 + server_host: 127.0.0.1 + port: 5000 + +logging: + log_to_sdout: true + logfile: info.log + +message: Hoi \ No newline at end of file diff --git a/installation-files/projects_example.yaml b/installation-files/projects_example.yaml new file mode 100644 index 0000000..065e1ad --- /dev/null +++ b/installation-files/projects_example.yaml @@ -0,0 +1,16 @@ +projects: + - The Hunt: + url: thehunt + git_repo: https://git.sciuro.org/Burathar/The-Hunt + branch: master + secret: thisissecret + requirements-file: requirements.txt + tests: tests.py + + - Foo: + url: bar + git_repo: https://git.sciuro.org/Burathar/The-Hunt + branch: master + secret: thisissecret + requirements-file: requirements.txt + tests: tests.py \ No newline at end of file