Browse Source

add new files

master
Burathar 4 years ago
parent
commit
befc6925f2
  1. 1
      biscd/biscd/models/__init__.py
  2. 37
      biscd/biscd/models/project.py
  3. 12
      installation-files/config_example.yaml
  4. 16
      installation-files/projects_example.yaml

1
biscd/biscd/models/__init__.py

@ -0,0 +1 @@
from .project import Project

37
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

12
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

16
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
Loading…
Cancel
Save