makefile and docstrings

This commit is contained in:
gwen 2013-09-02 15:06:55 +02:00
parent f379a0fc0a
commit 7dd9394b84
4 changed files with 93 additions and 78 deletions

View File

@ -15,8 +15,16 @@ ifneq ($(DESTDIR),)
PYTHON_OPTS += --root $(DESTDIR) PYTHON_OPTS += --root $(DESTDIR)
endif endif
VERSION := 1.0rc VERSION := `cat VERSION`
VERSION_FILE := version.in
define gettext
if command -v pygettext >/dev/null 2>&1 ; then \
P="pygettext" ; \
else \
P="pygettext.py" ; \
fi ; \
$$P -p translations/ -o $(PACKAGE).pot `find $(PACKAGE)/ -name "*.py"`
endef
# Build translation files # Build translation files
define build_translation define build_translation
@ -27,6 +35,8 @@ define build_translation
fi fi
endef endef
# Install Traduction # Install Traduction
define install_translation define install_translation
if [ -d ${1} ]; then \ if [ -d ${1} ]; then \
@ -43,15 +53,15 @@ all: build-lang
clean: clean:
$(RM) -r build $(RM) -r build
$(RM) -r $(PACKAGE).egg-info/ $(RM) -r $(PACKAGE).egg-info/
$(RM) -r $(VERSION_FILE)
$(RM) -r $(TRADUC_DIR)/*/*.mo $(RM) -r $(TRADUC_DIR)/*/*.mo
#test: clean #test: clean
# py.test # py.test
# Build or update Portable Object Base Translation for gettext # Build or update Portable Object Base Translation for gettext
build-pot: build-pot:
pygettext.py -p translations/ -o $(PACKAGE).pot `find $(PACKAGE)/ -name "*.py"` $(call gettext)
build-lang: build-lang:
$(call build_translation, $(TRADUC_DIR)) $(call build_translation, $(TRADUC_DIR))
@ -60,14 +70,11 @@ install-lang:
$(INSTALL_DIR) $(TRADUC_DEST) $(INSTALL_DIR) $(TRADUC_DEST)
$(call install_translation, $(TRADUC_DIR)) $(call install_translation, $(TRADUC_DIR))
install: version.in install-lang install: install-lang
python setup.py install --no-compile $(PYTHON_OPTS) python setup.py install --no-compile $(PYTHON_OPTS)
# List in .PHONY to force generation at each call
version.in:
echo -n $(VERSION) > $(VERSION_FILE)
dist: dist:
git archive --format=tar --prefix $(PACKAGE)-$(VERSION)/ HEAD | gzip -9 > $(PACKAGE)-$(VERSION).tar.gz git archive --format=tar --prefix $(PACKAGE)-$(VERSION)/ HEAD | gzip -9 > $(PACKAGE)-$(VERSION).tar.gz
.PHONY: all clean build-pot build-lang install-lang install version.in dist # List in .PHONY to force generation at each call
.PHONY: all clean build-pot build-lang install-lang install dist

View File

@ -1,19 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from distutils.core import setup from distutils.core import setup
from os.path import isfile
version_file = 'version.in'
def fetch_version(): def fetch_version():
"""Get version from version.in""" """Get version from version.in"""
return file('VERSION', 'r').readline().strip()
if not isfile(version_file):
raise Exception('Please use "make && make" install instead of '
'setup.py directly')
return file(version_file).readline().strip()
setup( setup(
@ -26,6 +18,7 @@ setup(
packages=['tiramisu'], packages=['tiramisu'],
classifiers=[ classifiers=[
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
"Environment :: Other Environment", "Environment :: Other Environment",

View File

@ -92,9 +92,21 @@ class BaseInformation(object):
class BaseOption(BaseInformation): class BaseOption(BaseInformation):
"""This abstract base class stands for attribute access
in options that have to be set only once, it is of course done in the
__setattr__ method
"""
__slots__ = ('_readonly',) __slots__ = ('_readonly',)
def __setattr__(self, name, value): def __setattr__(self, name, value):
"""set once and only once some attributes in the option,
like `_name`. `_name` cannot be changed one the option and
pushed in the :class:`tiramisu.option.OptionDescription`.
if the attribute `_readonly` is set to `True`, the option is
"frozen" (which has noting to do with the high level "freeze"
propertie or "read_only" property)
"""
is_readonly = False is_readonly = False
# never change _name # never change _name
if name == '_name': if name == '_name':
@ -102,7 +114,7 @@ class BaseOption(BaseInformation):
self._name self._name
#so _name is already set #so _name is already set
is_readonly = True is_readonly = True
except: except AttributeError:
pass pass
try: try:
if self._readonly is True: if self._readonly is True:
@ -988,6 +1000,9 @@ class OptionDescription(BaseOption):
return value return value
def impl_export(self, descr=None): def impl_export(self, descr=None):
"""enables us to export into a dict
:param descr: parent :class:`tiramisu.option.OptionDescription`
"""
if descr is None: if descr is None:
descr = self descr = self
export = super(OptionDescription, self).impl_export(descr) export = super(OptionDescription, self).impl_export(descr)

View File

@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2013-08-31 09:52+CEST\n" "POT-Creation-Date: 2013-09-02 11:30+CEST\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -75,231 +75,231 @@ msgstr ""
msgid "'{0}' ({1}) object attribute '{2}' is read-only" msgid "'{0}' ({1}) object attribute '{2}' is read-only"
msgstr "" msgstr ""
#: tiramisu/option.py:159 #: tiramisu/option.py:208
msgid "invalid name: {0} for option" msgid "invalid name: {0} for option"
msgstr "" msgstr ""
#: tiramisu/option.py:169 #: tiramisu/option.py:218
msgid "validator must be a function" msgid "validator must be a function"
msgstr "" msgstr ""
#: tiramisu/option.py:176 #: tiramisu/option.py:225
msgid "a default_multi is set whereas multi is False in option: {0}" msgid "a default_multi is set whereas multi is False in option: {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:182 #: tiramisu/option.py:231
msgid "invalid default_multi value {0} for option {1}: {2}" msgid "invalid default_multi value {0} for option {1}: {2}"
msgstr "" msgstr ""
#: tiramisu/option.py:187 #: tiramisu/option.py:236
msgid "default value not allowed if option: {0} is calculated" msgid "default value not allowed if option: {0} is calculated"
msgstr "" msgstr ""
#: tiramisu/option.py:190 #: tiramisu/option.py:239
msgid "params defined for a callback function but no callback defined yet for option {0}" msgid "params defined for a callback function but no callback defined yet for option {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:212 tiramisu/option.py:753 #: tiramisu/option.py:261 tiramisu/option.py:809
msgid "invalid properties type {0} for {1}, must be a tuple" msgid "invalid properties type {0} for {1}, must be a tuple"
msgstr "" msgstr ""
#: tiramisu/option.py:285 #: tiramisu/option.py:334
msgid "invalid value {0} for option {1} for object {2}" msgid "invalid value {0} for option {1} for object {2}"
msgstr "" msgstr ""
#: tiramisu/option.py:293 tiramisu/value.py:468 #: tiramisu/option.py:342 tiramisu/value.py:468
msgid "invalid value {0} for option {1}: {2}" msgid "invalid value {0} for option {1}: {2}"
msgstr "" msgstr ""
#: tiramisu/option.py:305 #: tiramisu/option.py:354
msgid "invalid value {0} for option {1} which must be a list" msgid "invalid value {0} for option {1} which must be a list"
msgstr "" msgstr ""
#: tiramisu/option.py:374 #: tiramisu/option.py:423
msgid "invalid value {0} for option {1} must be different as {2} option" msgid "invalid value {0} for option {1} must be different as {2} option"
msgstr "" msgstr ""
#: tiramisu/option.py:396 #: tiramisu/option.py:445
msgid "values must be a tuple for {0}" msgid "values must be a tuple for {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:399 #: tiramisu/option.py:448
msgid "open_values must be a boolean for {0}" msgid "open_values must be a boolean for {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:420 #: tiramisu/option.py:469
msgid "value {0} is not permitted, only {1} is allowed" msgid "value {0} is not permitted, only {1} is allowed"
msgstr "" msgstr ""
#: tiramisu/option.py:432 #: tiramisu/option.py:481
msgid "value must be a boolean" msgid "value must be a boolean"
msgstr "" msgstr ""
#: tiramisu/option.py:442 #: tiramisu/option.py:491
msgid "value must be an integer" msgid "value must be an integer"
msgstr "" msgstr ""
#: tiramisu/option.py:452 #: tiramisu/option.py:501
msgid "value must be a float" msgid "value must be a float"
msgstr "" msgstr ""
#: tiramisu/option.py:462 #: tiramisu/option.py:511
msgid "value must be a string, not {0}" msgid "value must be a string, not {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:480 #: tiramisu/option.py:529
msgid "value must be an unicode" msgid "value must be an unicode"
msgstr "" msgstr ""
#: tiramisu/option.py:490 #: tiramisu/option.py:539
msgid "malformed symlinkoption must be an option for symlink {0}" msgid "malformed symlinkoption must be an option for symlink {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:526 #: tiramisu/option.py:581
msgid "IP mustn't not be in reserved class" msgid "IP mustn't not be in reserved class"
msgstr "" msgstr ""
#: tiramisu/option.py:528 #: tiramisu/option.py:583
msgid "IP must be in private class" msgid "IP must be in private class"
msgstr "" msgstr ""
#: tiramisu/option.py:566 #: tiramisu/option.py:621
msgid "inconsistency in allowed range" msgid "inconsistency in allowed range"
msgstr "" msgstr ""
#: tiramisu/option.py:571 #: tiramisu/option.py:626
msgid "max value is empty" msgid "max value is empty"
msgstr "" msgstr ""
#: tiramisu/option.py:608 #: tiramisu/option.py:663
msgid "network mustn't not be in reserved class" msgid "network mustn't not be in reserved class"
msgstr "" msgstr ""
#: tiramisu/option.py:640 #: tiramisu/option.py:695
msgid "invalid network {0} ({1}) with netmask {2} ({3}), this network is an IP" msgid "invalid network {0} ({1}) with netmask {2} ({3}), this network is an IP"
msgstr "" msgstr ""
#: tiramisu/option.py:645 #: tiramisu/option.py:700
msgid "invalid IP {0} ({1}) with netmask {2} ({3}), this IP is a network" msgid "invalid IP {0} ({1}) with netmask {2} ({3}), this IP is a network"
msgstr "" msgstr ""
#: tiramisu/option.py:650 #: tiramisu/option.py:705
msgid "invalid IP {0} ({1}) with netmask {2} ({3})" msgid "invalid IP {0} ({1}) with netmask {2} ({3})"
msgstr "" msgstr ""
#: tiramisu/option.py:652 #: tiramisu/option.py:707
msgid "invalid network {0} ({1}) with netmask {2} ({3})" msgid "invalid network {0} ({1}) with netmask {2} ({3})"
msgstr "" msgstr ""
#: tiramisu/option.py:672 #: tiramisu/option.py:727
msgid "unknown type_ {0} for hostname" msgid "unknown type_ {0} for hostname"
msgstr "" msgstr ""
#: tiramisu/option.py:675 #: tiramisu/option.py:730
msgid "allow_ip must be a boolean" msgid "allow_ip must be a boolean"
msgstr "" msgstr ""
#: tiramisu/option.py:704 #: tiramisu/option.py:759
msgid "invalid value for {0}, must have dot" msgid "invalid value for {0}, must have dot"
msgstr "" msgstr ""
#: tiramisu/option.py:707 #: tiramisu/option.py:762
msgid "invalid domainname's length for {0} (max {1})" msgid "invalid domainname's length for {0} (max {1})"
msgstr "" msgstr ""
#: tiramisu/option.py:710 #: tiramisu/option.py:765
msgid "invalid domainname's length for {0} (min 2)" msgid "invalid domainname's length for {0} (min 2)"
msgstr "" msgstr ""
#: tiramisu/option.py:714 #: tiramisu/option.py:769
msgid "invalid domainname" msgid "invalid domainname"
msgstr "" msgstr ""
#: tiramisu/option.py:731 #: tiramisu/option.py:787
msgid "invalid name: {0} for optiondescription" msgid "invalid name: {0} for optiondescription"
msgstr "" msgstr ""
#: tiramisu/option.py:743 #: tiramisu/option.py:799
msgid "duplicate option name: {0}" msgid "duplicate option name: {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:769 #: tiramisu/option.py:825
msgid "unknown Option {0} in OptionDescription {1}" msgid "unknown Option {0} in OptionDescription {1}"
msgstr "" msgstr ""
#: tiramisu/option.py:820 #: tiramisu/option.py:874
msgid "duplicate option: {0}" msgid "duplicate option: {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:850 #: tiramisu/option.py:904
msgid "no option for path {0}" msgid "no option for path {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:856 #: tiramisu/option.py:910
msgid "no option {0} found" msgid "no option {0} found"
msgstr "" msgstr ""
#: tiramisu/option.py:866 #: tiramisu/option.py:920
msgid "cannot change group_type if already set (old {0}, new {1})" msgid "cannot change group_type if already set (old {0}, new {1})"
msgstr "" msgstr ""
#: tiramisu/option.py:879 #: tiramisu/option.py:933
msgid "master group {0} shall not have a subgroup" msgid "master group {0} shall not have a subgroup"
msgstr "" msgstr ""
#: tiramisu/option.py:882 #: tiramisu/option.py:936
msgid "master group {0} shall not have a symlinkoption" msgid "master group {0} shall not have a symlinkoption"
msgstr "" msgstr ""
#: tiramisu/option.py:885 #: tiramisu/option.py:939
msgid "not allowed option {0} in group {1}: this option is not a multi" msgid "not allowed option {0} in group {1}: this option is not a multi"
msgstr "" msgstr ""
#: tiramisu/option.py:896 #: tiramisu/option.py:950
msgid "master group with wrong master name for {0}" msgid "master group with wrong master name for {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:905 #: tiramisu/option.py:959
msgid "no child has same nom has master group for: {0}" msgid "no child has same nom has master group for: {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:908 #: tiramisu/option.py:962
msgid "group_type: {0} not allowed" msgid "group_type: {0} not allowed"
msgstr "" msgstr ""
#: tiramisu/option.py:946 #: tiramisu/option.py:1021
msgid "malformed requirements type for option: {0}, must be a dict" msgid "malformed requirements type for option: {0}, must be a dict"
msgstr "" msgstr ""
#: tiramisu/option.py:962 #: tiramisu/option.py:1037
msgid "malformed requirements for option: {0} require must have option, expected and action keys" msgid "malformed requirements for option: {0} require must have option, expected and action keys"
msgstr "" msgstr ""
#: tiramisu/option.py:967 #: tiramisu/option.py:1042
msgid "malformed requirements for option: {0} inverse must be boolean" msgid "malformed requirements for option: {0} inverse must be boolean"
msgstr "" msgstr ""
#: tiramisu/option.py:971 #: tiramisu/option.py:1046
msgid "malformed requirements for option: {0} transitive must be boolean" msgid "malformed requirements for option: {0} transitive must be boolean"
msgstr "" msgstr ""
#: tiramisu/option.py:975 #: tiramisu/option.py:1050
msgid "malformed requirements for option: {0} same_action must be boolean" msgid "malformed requirements for option: {0} same_action must be boolean"
msgstr "" msgstr ""
#: tiramisu/option.py:979 #: tiramisu/option.py:1054
msgid "malformed requirements must be an option in option {0}" msgid "malformed requirements must be an option in option {0}"
msgstr "" msgstr ""
#: tiramisu/option.py:982 #: tiramisu/option.py:1057
msgid "malformed requirements option {0} should not be a multi" msgid "malformed requirements option {0} should not be a multi"
msgstr "" msgstr ""
#: tiramisu/option.py:988 #: tiramisu/option.py:1063
msgid "malformed requirements second argument must be valid for option {0}: {1}" msgid "malformed requirements second argument must be valid for option {0}: {1}"
msgstr "" msgstr ""
#: tiramisu/option.py:993 #: tiramisu/option.py:1068
msgid "inconsistency in action types for option: {0} action: {1}" msgid "inconsistency in action types for option: {0} action: {1}"
msgstr "" msgstr ""