src/pyams_utils/__init__.py
branchdev-tf
changeset 408 cf2304af0fab
parent 387 604807051f00
equal deleted inserted replaced
407:0037199881fb 408:cf2304af0fab
    16 for which dedicated packages are not provided. These features can concern
    16 for which dedicated packages are not provided. These features can concern
    17 date and times management, strings and unicode, lists and dictionaries,
    17 date and times management, strings and unicode, lists and dictionaries,
    18 custom decorators to define several kinds of properties, and so on.
    18 custom decorators to define several kinds of properties, and so on.
    19 """
    19 """
    20 
    20 
       
    21 from pyramid.i18n import TranslationStringFactory
       
    22 from zope.schema.fieldproperty import FieldProperty
       
    23 
       
    24 
    21 __docformat__ = 'restructuredtext'
    25 __docformat__ = 'restructuredtext'
    22 
    26 
    23 from zope.schema.fieldproperty import FieldProperty
       
    24 
       
    25 from pyramid.i18n import TranslationStringFactory
       
    26 _ = TranslationStringFactory('pyams_utils')
    27 _ = TranslationStringFactory('pyams_utils')
    27 
    28 
    28 
    29 
    29 def get_field_doc(self):
    30 def get_field_doc(self):
    30     """Try to get FieldProperty field docstring from field interface"""
    31     """Try to get FieldProperty field docstring from field interface"""
    31     field = self._FieldProperty__field
    32     field = self._FieldProperty__field  # pylint: disable=protected-access
    32     if field.title:
    33     if field.title:
    33         if field.description:
    34         if field.description:
    34             return '{0}: {1}'.format(field.title, field.description)
    35             return '{0}: {1}'.format(field.title, field.description)
    35         else:
    36         return field.title
    36             return field.title
    37     return super(self.__class__, self).__doc__
    37     else:
       
    38         return super(self.__class__, self).__doc__
       
    39 
    38 
    40 
    39 
    41 FieldProperty.__doc__ = property(get_field_doc)
    40 FieldProperty.__doc__ = property(get_field_doc)
    42 
    41 
    43 
    42 
    44 def includeme(config):
    43 def includeme(config):
    45     """pyams_utils features include"""
    44     """pyams_utils features include"""
    46     from .include import include_package
    45     from .include import include_package  # pylint: disable=import-outside-toplevel
    47     include_package(config)
    46     include_package(config)