How to use the lektor.utils.bool_from_string function in Lektor

To help you get started, we’ve selected a few Lektor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lektor / lektor / lektor / types / primitives.py View on Github external
def value_from_raw(self, raw):
        if raw.value is None:
            return raw.missing_value('Missing boolean')
        val = bool_from_string(raw.value.strip().lower())
        if val is None:
            return raw.bad_value('Bad boolean value')
        return val
github lektor / lektor-archive / lektor / environment.py View on Github external
def get_server(self, name, public=False):
        """Looks up a server info by name."""
        info = self.values['SERVERS'].get(name)
        if info is None:
            return None
        target = info.get('target')
        if target is None:
            return None
        if public:
            target = secure_url(target)
        return ServerInfo(
            id=name,
            name_i18n=get_i18n_block(info, 'name'),
            target=target,
            enabled=bool_from_string(info.get('enabled'), True),
            default=bool_from_string(info.get('default'), False)
        )
github ulope / pyformat.info / vendor / lektor / lektor / environment.py View on Github external
def get_server(self, name, public=False):
        """Looks up a server info by name."""
        info = self.values['SERVERS'].get(name)
        if info is None or 'target' not in info:
            return None
        info = info.copy()
        target = info.pop('target')
        if public:
            target = secure_url(target)
        return ServerInfo(
            id=name,
            name_i18n=get_i18n_block(info, 'name', pop=True),
            target=target,
            enabled=bool_from_string(info.pop('enabled', None), True),
            default=bool_from_string(info.pop('default', None), False),
            extra=info
        )
github lektor / lektor-archive / lektor / environment.py View on Github external
def get_server(self, name, public=False):
        """Looks up a server info by name."""
        info = self.values['SERVERS'].get(name)
        if info is None:
            return None
        target = info.get('target')
        if target is None:
            return None
        if public:
            target = secure_url(target)
        return ServerInfo(
            id=name,
            name_i18n=get_i18n_block(info, 'name'),
            target=target,
            enabled=bool_from_string(info.get('enabled'), True),
            default=bool_from_string(info.get('default'), False)
        )
github ulope / pyformat.info / vendor / lektor / lektor / environment.py View on Github external
def get_server(self, name, public=False):
        """Looks up a server info by name."""
        info = self.values['SERVERS'].get(name)
        if info is None or 'target' not in info:
            return None
        info = info.copy()
        target = info.pop('target')
        if public:
            target = secure_url(target)
        return ServerInfo(
            id=name,
            name_i18n=get_i18n_block(info, 'name', pop=True),
            target=target,
            enabled=bool_from_string(info.pop('enabled', None), True),
            default=bool_from_string(info.pop('default', None), False),
            extra=info
        )
github ulope / pyformat.info / vendor / lektor / lektor / datamodel.py View on Github external
def to_json(self, pad, record=None, alt=PRIMARY_ALT):
        return {
            'name': self.name,
            'label': self.label,
            'label_i18n': self.label_i18n,
            'hide_label': bool_from_string(self.options.get('hide_label'),
                                           default=False),
            'description_i18n': self.description_i18n,
            'type': self.type.to_json(pad, record, alt),
            'default': self.default,
        }
github nixjdm / lektor-tags / lektor_tags.py View on Github external
def ignore_missing(self):
        return bool_from_string(self.get_config().get("ignore_missing"), False)
github lektor / lektor-archive / lektor / datamodel.py View on Github external
def to_json(self, pad, record=None, alt=PRIMARY_ALT):
        return {
            'name': self.name,
            'label': self.label,
            'label_i18n': self.label_i18n,
            'hide_label': bool_from_string(self.options.get('hide_label'),
                                           default=False),
            'description_i18n': self.description_i18n,
            'type': self.type.to_json(pad, record, alt),
            'default': self.default,
        }
github lektor / lektor-archive / lektor / types / primitives.py View on Github external
def value_from_raw(self, raw):
        if raw.value is None:
            return raw.missing_value('Missing boolean')
        val = bool_from_string(raw.value.strip().lower())
        if val is None:
            return raw.bad_value('Bad boolean value')
        return val
github lektor / lektor / lektor / environment.py View on Github external
def get_server(self, name, public=False):
        """Looks up a server info by name."""
        info = self.values['SERVERS'].get(name)
        if info is None or 'target' not in info:
            return None
        info = info.copy()
        target = info.pop('target')
        if public:
            target = secure_url(target)
        return ServerInfo(
            id=name,
            name_i18n=get_i18n_block(info, 'name', pop=True),
            target=target,
            enabled=bool_from_string(info.pop('enabled', None), True),
            default=bool_from_string(info.pop('default', None), False),
            extra=info
        )