forked from useblocks/groundwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
105 lines (88 loc) · 4.22 KB
/
setup.py
File metadata and controls
105 lines (88 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"""
groundwork
----------
groundwork is a Python based microframework for highly reusable applications and their components.
Its functionality is based on exchangeable, documented and tested plugins and patterns.
It is designed to support any kind of Python application: command line scripts, desktop programs or web applications.
groundwork enables applications to activate and deactivate plugins during runtime and to control dynamic plugin
behaviors like plugin status, used signals, registered commands and much more.
The functionality of plugins can easily be extended by the usage of inheritable patterns.
Thus, groundwork supports developers with time-saving solutions for:
* Command line interfaces
* Loose inter-plugin communication via signals and receivers
* Shared objects to provide and request content to and from other plugins
* Static and dynamic documents for an overall documentation
Example
~~~~~~~
The following code defines a plugin with command line support and creates a groundwork application which activates
the plugin::
from groundwork import App
from groundwork.patterns import GwCommandsPattern
class MyPlugin(GwCommandsPattern):
def _init_(self, *args, **kwargs):
self.name = "My Plugin"
super().__init__(*args, **kwargs)
def activate(self):
self.commands.register(command='hello',
description='prints "hello world"',
function=self.greetings)
def greetings(self):
print("Hello world")
if __name__ == "__main__":
my_app = App(plugins=[MyPlugin]) # Creates app and registers MyPlugin
my_app.plugins.activate(["My Plugin"]) # Initialise and activates 'My Plugin'
my_app.commands.start_cli() # Starts the command line interface
The following commands can be used on a command line now::
python my_app.py hello # Prints 'Hello world'
python my_app.py # Prints a list of available commands
python my_app.yp hello -h # Prints syntax help for the hello command
"""
from setuptools import setup, find_packages
import re
import ast
_version_re = re.compile(r'__version__\s+=\s+(.*)')
with open('groundwork/version.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search(
f.read().decode('utf-8')).group(1)))
setup(
name='groundwork',
version=version,
url='http://groundwork.readthedocs.org',
license='MIT',
author='team useblocks',
author_email='info@useblocks.com',
description="A plugin-based microframework for highly reusable applications and their components",
long_description=__doc__,
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
# package_data={'': ['*.conf'], 'groundwork/recipes': ['*']},
package_data={'': ['*.conf'], 'groundwork/recipes': ['*']},
platforms='any',
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-flake8'],
install_requires=["pathlib", "click", "blinker", "jinja2", "cookiecutter", "docutils"],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
entry_points={
'console_scripts': ["groundwork = groundwork.applications.gw_base_app:start_app"],
'groundwork.plugin': [
'gw_plugins_info = groundwork.plugins.gw_plugins_info:GwPluginsInfo',
'gw_signals_info = groundwork.plugins.gw_signals_info:GwSignalsInfo',
'gw_commands_info = groundwork.plugins.gw_commands_info:GwCommandsInfo',
'gw_documents_info = groundwork.plugins.gw_documents_info:GwDocumentsInfo',
'gw_recipes_builder = groundwork.plugins.gw_recipes_builder:GwRecipesBuilder',
]
}
)