[config] Adds __doc__ to option/service. Fix variable names in Option.__get__() that would have an unpredicatable behaviour in the rare case of using get on a type. Update to Medikit.
This commit is contained in:
18
Makefile
18
Makefile
@ -1,7 +1,5 @@
|
|||||||
# This file has been auto-generated.
|
# This file has been auto-generated by Medikit. All changes will be lost.
|
||||||
# All changes will be lost, see Projectfile.
|
# Updated on 2017-10-21.
|
||||||
#
|
|
||||||
# Updated at 2017-10-05 18:56:33.985014
|
|
||||||
|
|
||||||
PACKAGE ?= bonobo
|
PACKAGE ?= bonobo
|
||||||
PYTHON ?= $(shell which python)
|
PYTHON ?= $(shell which python)
|
||||||
@ -22,7 +20,7 @@ YAPF ?= $(PYTHON) -m yapf
|
|||||||
YAPF_OPTIONS ?= -rip
|
YAPF_OPTIONS ?= -rip
|
||||||
VERSION ?= $(shell git describe 2>/dev/null || echo dev)
|
VERSION ?= $(shell git describe 2>/dev/null || echo dev)
|
||||||
|
|
||||||
.PHONY: $(SPHINX_SOURCEDIR) clean format install install-dev test
|
.PHONY: $(SPHINX_SOURCEDIR) clean format install install-dev test update update-requirements
|
||||||
|
|
||||||
# Installs the local project dependencies.
|
# Installs the local project dependencies.
|
||||||
install:
|
install:
|
||||||
@ -40,6 +38,16 @@ install-dev:
|
|||||||
clean:
|
clean:
|
||||||
rm -rf build dist *.egg-info
|
rm -rf build dist *.egg-info
|
||||||
|
|
||||||
|
# Update project artifacts using medikit, after installing it eventually.
|
||||||
|
update:
|
||||||
|
python -c 'import medikit; print(medikit.__version__)' || pip install medikit;
|
||||||
|
$(PYTHON) -m medikit update
|
||||||
|
|
||||||
|
# Remove requirements files and update project artifacts using medikit, after installing it eventually.
|
||||||
|
update-requirements:
|
||||||
|
rm -rf requirements*.txt
|
||||||
|
$(MAKE) update
|
||||||
|
|
||||||
test: install-dev
|
test: install-dev
|
||||||
$(PYTEST) $(PYTEST_OPTIONS) tests
|
$(PYTEST) $(PYTEST_OPTIONS) tests
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# bonobo (see github.com/python-edgy/project)
|
# bonobo's description for medikit
|
||||||
|
|
||||||
from edgy.project import require
|
from medikit import require
|
||||||
|
|
||||||
pytest = require('pytest')
|
pytest = require('pytest')
|
||||||
python = require('python')
|
python = require('python')
|
||||||
|
|||||||
@ -53,21 +53,23 @@ class Option:
|
|||||||
|
|
||||||
_creation_counter = 0
|
_creation_counter = 0
|
||||||
|
|
||||||
def __init__(self, type=None, *, required=True, positional=False, default=None):
|
def __init__(self, type=None, *, required=True, positional=False, default=None, __doc__=None):
|
||||||
self.name = None
|
self.name = None
|
||||||
self.type = type
|
self.type = type
|
||||||
self.required = required if default is None else False
|
self.required = required if default is None else False
|
||||||
self.positional = positional
|
self.positional = positional
|
||||||
self.default = default
|
self.default = default
|
||||||
|
|
||||||
|
self.__doc__ = __doc__ or self.__doc__
|
||||||
|
|
||||||
# This hack is necessary for python3.5
|
# This hack is necessary for python3.5
|
||||||
self._creation_counter = Option._creation_counter
|
self._creation_counter = Option._creation_counter
|
||||||
Option._creation_counter += 1
|
Option._creation_counter += 1
|
||||||
|
|
||||||
def __get__(self, inst, typ):
|
def __get__(self, inst, type_):
|
||||||
# XXX If we call this on the type, then either return overriden value or ... ???
|
# XXX If we call this on the type, then either return overriden value or ... ???
|
||||||
if inst is None:
|
if inst is None:
|
||||||
return vars(type).get(self.name, self)
|
return vars(type_).get(self.name, self)
|
||||||
|
|
||||||
if not self.name in inst._options_values:
|
if not self.name in inst._options_values:
|
||||||
inst._options_values[self.name] = self.get_default()
|
inst._options_values[self.name] = self.get_default()
|
||||||
|
|||||||
@ -49,8 +49,8 @@ class Service(Option):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name, __doc__=None):
|
||||||
super().__init__(str, required=False, default=name)
|
super().__init__(str, required=False, default=name, __doc__=__doc__)
|
||||||
|
|
||||||
def __set__(self, inst, value):
|
def __set__(self, inst, value):
|
||||||
inst._options_values[self.name] = validate_service_name(value)
|
inst._options_values[self.name] = validate_service_name(value)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -1,4 +1,4 @@
|
|||||||
# This file is autogenerated by edgy.project code generator.
|
# This file is autogenerated by medikit code generator.
|
||||||
# All changes will be overwritten.
|
# All changes will be overwritten.
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|||||||
Reference in New Issue
Block a user