defernia.objsimplify — Object simplifier for generic serialization

defernia.objsimplify.simplify(value, identifier_map, type_map={}, url_map=None, user=None, **extra)

Simplifies a given value.

Parameters:
  • value – an object to simplify
  • identifier_map (callable object) – a map function that normalizes multi-word identifiers
  • type_map (dict) – a type to mapping function dictionary
  • url_map (callable object) – a map function that returns an url of a given value object. by default, it is a constant function that just returns None, so simplified dictionaries have no url data
  • user (defernia.user.User) – an user object for signing
defernia.objsimplify.under_scores(identifier)

Concatenates words of the identifier by underscore ('_').

>>> under_scores('key name')
'key_name'
>>> under_scores('encode URL')
'encode_url'

Note

Use this function for simplify() function’s identifier_map option.

defernia.objsimplify.PascalCase(identifier)

Makes the identifier PascalCase.

>>> PascalCase('key name')
'KeyName'
>>> PascalCase('encode URL')
'EncodeURL'

Note

Use this function for simplify() function’s identifier_map option.

defernia.objsimplify.camelCase(identifier)

Makes the identifier camelCase.

>>> camelCase('key name')
'keyName'
>>> camelCase('encode URL')
'encodeUrl'
>>> camelCase('URL encoder')
'urlEncoder'

Note

Use this function for simplify() function’s identifier_map option.

defernia.objsimplify.transform = <typequery.GenericMethod 'transform' at 0x4ba2210>

Warning

Internal use only. Use simplify() instead.

The function that really implements simplification per types, without simplify()‘s type_map option.

Parameters:
  • value – an object to simplify
  • **options – extra options

Project Versions

Previous topic

defernia.creds — User credentials

Next topic

defernia.web — Web frontend

This Page