langdev.objsimplify — Object simplifier for generic serialization

langdev.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 (langdev.user.User) – an user object for signing
  • under_list – whether value is contained by a list. False by default
  • under_listbool
Returns:

a simplified object

langdev.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.

langdev.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.

langdev.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.

class langdev.objsimplify.Result

A dictionary subclass that contains the result. All keys are idmap()-ed and all values are simplify()-ed during simplify()-ing.

Note

It assumes that all keys are strings.

langdev.objsimplify.transform = <langdev.util.visitor.Visitor 'transform' at 369d320>

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

langdev.thirdparty — Third-parties

Next topic

langdev.web — LangDev web services

This Page