OpenSlides/server/make/parser.py
FinnStutzenstein 2bcab5d098
Repository restructure
- moved all server related things into the folder `server`, so this
configuration is parallel to the client.
- All main "services" are now folders in the root directory
- Added Dockerfiles to each service (currently server and client)
- Added a docker compose configuration to start everything together.
Currently there are heavy dependencies into https://github.com/OpenSlides/openslides-docker-compose
- Resturctured the .gitignore. If someone needs something excluded,
please add it to the right section.
- Added initial build setup with Docker and docker-compose.
- removed setup.py. We won't deliver OpenSlides via pip anymore.
2020-08-21 08:11:13 +02:00

55 lines
1.3 KiB
Python

from argparse import ArgumentParser
from subprocess import call as _call
parser = ArgumentParser(description="Development scripts for OpenSlides")
subparsers = parser.add_subparsers()
def command(*args, **kwargs):
"""
Decorator to create a argparse command.
The arguments to this decorator are used as arguments for the argparse
command.
"""
class decorator:
def __init__(self, func):
self.parser = subparsers.add_parser(*args, **kwargs)
self.parser.set_defaults(func=func)
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
return decorator
def argument(*args, **kwargs):
"""
Decorator to create arguments for argparse commands.
The arguments to this decorator are used as arguments for the argparse
argument.
Does only work if the decorated function was decorated with the
command-decorator before.
"""
def decorator(func):
func.parser.add_argument(*args, **kwargs)
def wrapper(*func_args, **func_kwargs):
return func(*func_args, **func_kwargs)
return wrapper
return decorator
def call(*args, **kwargs):
"""
Calls a command in a shell.
"""
return _call(shell=True, *args, **kwargs)