How to use the lucidity.error.FormatError function in Lucidity

To help you get started, we’ve selected a few Lucidity 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 4degrees / lucidity / test / unit / View on Github external
def test_format_failure(pattern, data):
    '''Format incomplete data against pattern.'''
    template = Template('test', pattern)
    with pytest.raises(FormatError):
github 4degrees / lucidity / source / lucidity / View on Github external
def _format(match):
            '''Return value from data for *match*.'''
            placeholder =
            parts = placeholder.split('.')

                value = data
                for part in parts:
                    value = value[part]

            except (TypeError, KeyError):
                raise lucidity.error.FormatError(
                    'Could not format data {0!r} due to missing key {1!r}.'
                    .format(data, placeholder)

                return value