def get_propeller_setting(setting, default=None):
    """
    Read a setting
    """
    return PROPELLER.get(setting, default) PROPELLER_SET_REQUIRED_SET_DISABLED = DJANGO_VERSION[0] < 2 and DJANGO_VERSION[1] < 10 class PropellerError(PropellerException):

    """Any exception that is an error"""

    pass def render_form(form, **kwargs):
    """Render a form to a Bootstrap layout"""
    renderer_cls = get_form_renderer(**kwargs)
    return renderer_cls(form, **kwargs).render() def render_field(field, **kwargs):
    """Render a field to a Bootstrap layout"""
    renderer_cls = get_field_renderer(**kwargs)
    return renderer_cls(field, **kwargs).render() def render_label(content, label_for=None, label_class=None, label_title=''):
    """Render a label with content"""
    attrs = {}
    if label_for:
        attrs['for'] = label_for
    if label_class:
        attrs['class'] = label_class
    if label_title:
        attrs['title'] = label_title
    return render_tag('label', attrs=attrs, content=content) def render_form_group(content, css_class=FORM_GROUP_CLASS):
    """Render a Bootstrap form group"""
    return '<div class="{klass}">{content}</div>'.format(
        klass=css_class,
        content=content,
    ) def is_widget_with_placeholder(widget):
    """
    Is this a widget that should have a placeholder?
    Only text, search, url, tel, e-mail, password, number have placeholders
    These are all derived form TextInput, except for Textarea
    """
    # PasswordInput inherits from Input in Django 1.4.
    # It was changed to inherit from TextInput in 1.5.
    return isinstance(widget, (TextInput, Textarea, PasswordInput)) FORM_GROUP_CLASS = 'form-group pmd-textfield' def is_widget_required_attribute(widget):
    """Is this widget required?"""
    if PROPELLER_SET_REQUIRED_SET_DISABLED and not get_propeller_setting('set_required'):
        return False
    if not widget.is_required:
        return False
    if isinstance(
            widget, (
                    AdminFileWidget, HiddenInput, FileInput,
                    CheckboxInput, CheckboxSelectMultiple)):
        return False
    return True def text_value(value):
    """
    Force a value to text, render None as an empty string
    """
    if value is None:
        return ''
    return force_text(value) def add_css_class(css_classes, css_class, prepend=False):
    """Add a CSS class to a string of CSS classes"""
    classes_list = split_css_classes(css_classes)
    classes_to_add = [c for c in split_css_classes(css_class)
                      if c not in classes_list]
    if prepend:
        classes_list = classes_to_add + classes_list
    else:
        classes_list += classes_to_add
    return ' '.join(classes_list) def render_template_file(template, context=None):
    """Render a Template to unicode"""
    assert isinstance(context, Mapping)
    template = get_template(template)
    return template.render(context)
    from django.contrib.auth.forms import ReadOnlyPasswordHashWidget
from django.forms import (
    TextInput, DateInput, FileInput, CheckboxInput, MultiWidget,
    ClearableFileInput, Select, RadioSelect, CheckboxSelectMultiple
)
from django.forms.extras import SelectDateWidget
from django.forms.forms import BaseForm, BoundField
from django.forms.formsets import BaseFormSet
from django.utils.html import conditional_escape, escape, strip_tags
from django.utils.safestring import mark_safe
from .propeller import get_propeller_setting, PROPELLER_SET_REQUIRED_SET_DISABLED
from .exceptions import PropellerError
from .forms import (
    render_form, render_field, render_label, render_form_group,
    is_widget_with_placeholder, FORM_GROUP_CLASS,
    is_widget_required_attribute
)
from .text import text_value
from .utils import add_css_class, render_template_file
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

try:
    # If Django is set up without a database, importing this widget gives RuntimeError
except RuntimeError:
    ReadOnlyPasswordHashWidget = None




class BaseRenderer(object):
    """
    A content renderer
    """

    def __init__(self, *args, **kwargs):
        self.layout = kwargs.get('layout', '')
        self.form_group_class = kwargs.get(

            'form_group_class', FORM_GROUP_CLASS)