diff --git a/docs/init_template.txt b/docs/init_template.txt new file mode 100644 index 00000000..920c0c2f --- /dev/null +++ b/docs/init_template.txt @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +{} {} +~~~~~~~~~~~~~~~~~~~ + +{} + +:copyright: (c) {} {} +:license: {} + +""" + +__title__ = '{}' +__author__ = '{}' +__license__ = '{}' +__copyright__ = '{}' +__version__ = '{}' + +from collections import namedtuple + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') + +version_info = VersionInfo(major={}, minor={}, micro={}) diff --git a/docs/structure.md b/docs/structure.md new file mode 100644 index 00000000..71f2f0ea --- /dev/null +++ b/docs/structure.md @@ -0,0 +1,10 @@ +- sh_edraft + - common # Contains Interfaces and models for the hole library + - interface + - model + - configuration # Contains classes for app configuration by JSON, ENV vars and arguments + - discord # Contains classes for better use of discord.py + - logging # Contains classes for logging + - mailing # Contains classes for mailing + - messenger # Contains classes for sh_messenger_server client + - service # Contains classes to provide and use the services defined in this library \ No newline at end of file diff --git a/docs/todo.md b/docs/todo.md new file mode 100644 index 00000000..5d5a99b8 --- /dev/null +++ b/docs/todo.md @@ -0,0 +1,2 @@ +- create logger +- use logger in publisher \ No newline at end of file diff --git a/src/setup.py b/src/setup.py new file mode 100644 index 00000000..4f86d310 --- /dev/null +++ b/src/setup.py @@ -0,0 +1,12 @@ +import setuptools + +setuptools.setup( + name='sh_edraft', + version='2020.0.1', + packages=setuptools.find_packages(), + url='https://www.sh-edraft.de', + license='MIT', + author='Sven Heidemann', + author_email='edraft.sh@gmail.com', + description='sh-edraft python common lib' +) diff --git a/src/sh_edraft/__init__.py b/src/sh_edraft/__init__.py new file mode 100644 index 00000000..96602fbe --- /dev/null +++ b/src/sh_edraft/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +""" +sh_edraft python common lib +~~~~~~~~~~~~~~~~~~~ + +Common python functions and classes for sh-edraft.de ecosystem + +:copyright: (c) 2020 edraft +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'sh_edraft.de' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright 2020 sh-edraft.de' +__version__ = '2020.12.0.1' + +from collections import namedtuple + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') + +version_info = VersionInfo(major=2020, minor=12, micro=0.1) diff --git a/src/sh_edraft/common/__init__.py b/src/sh_edraft/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/common/interface/__init__.py b/src/sh_edraft/common/interface/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/common/interface/ipublisher.py b/src/sh_edraft/common/interface/ipublisher.py new file mode 100644 index 00000000..a1df83e8 --- /dev/null +++ b/src/sh_edraft/common/interface/ipublisher.py @@ -0,0 +1,24 @@ +from abc import ABC, abstractmethod +from typing import List + +from sh_edraft.publish.model.template import Template + + +class IPublisher(ABC): + + @abstractmethod + def __init__(self, local_path: str): + pass + + @property + @abstractmethod + def local_path(self) -> str: + pass + + @abstractmethod + def create(self, templates: List[Template]): + pass + + @abstractmethod + def publish(self): + pass diff --git a/src/sh_edraft/common/model/__init__.py b/src/sh_edraft/common/model/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/configuration/__init__.py b/src/sh_edraft/configuration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/discord/__init__.py b/src/sh_edraft/discord/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/logging/__init__.py b/src/sh_edraft/logging/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/mailing/__init__.py b/src/sh_edraft/mailing/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/messenger/__init__.py b/src/sh_edraft/messenger/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/publish/__init__.py b/src/sh_edraft/publish/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/publish/model/__init__.py b/src/sh_edraft/publish/model/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/sh_edraft/publish/model/template.py b/src/sh_edraft/publish/model/template.py new file mode 100644 index 00000000..7e1b1f57 --- /dev/null +++ b/src/sh_edraft/publish/model/template.py @@ -0,0 +1,16 @@ +from typing import Optional + + +class Template: + + def __init__(self, name: Optional[str] = None, path: Optional[str] = None): + self._name: Optional[str] = name + self._path: Optional[str] = path + + @property + def name(self): + return self._name + + @property + def path(self): + return self._path diff --git a/src/sh_edraft/publish/publisher.py b/src/sh_edraft/publish/publisher.py new file mode 100644 index 00000000..ab1fd5a5 --- /dev/null +++ b/src/sh_edraft/publish/publisher.py @@ -0,0 +1,22 @@ +from typing import List + +from sh_edraft.common.interface.ipublisher import IPublisher +from sh_edraft.publish.model.template import Template + + +class Publisher(IPublisher): + + def __init__(self, local_path: str): + super().__init__(local_path) + self._local_path = local_path + self._templates: List[Template] = [] + + @property + def local_path(self) -> str: + return self._local_path + + def create(self, templates: List[Template]): + self._templates = templates + + def publish(self): + print(self._local_path, [(t.name, t.path) for t in self._templates]) diff --git a/src/sh_edraft/service/__init__.py b/src/sh_edraft/service/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/test.py b/src/test.py new file mode 100644 index 00000000..aed60e3b --- /dev/null +++ b/src/test.py @@ -0,0 +1,10 @@ +from sh_edraft.publish.model.template import Template +from sh_edraft.publish.publisher import Publisher + +if __name__ == '__main__': + publisher = Publisher('./') + templates = [ + Template('*', '../docs/init_template.txt') + ] + publisher.create(templates) + publisher.publish()