fdutils/func.py
def default_json(o, encrypt=False, crypto_engine=None):
    """ makes some serializing interpretations of objects for json """
    from uuid import UUID
    import ipaddress

    str_classes = UUID, ipaddress._IPAddressBase

    if any(isinstance(o, str_cls) for str_cls in str_classes):
        if o is None:
            return None
        return str(o)

    if hasattr(o, 'to_json'):
        ret = o.to_json()

    elif o.__dict__:
        ret = o.__dict__

    elif o.__slots__:
        ret = {k:getattr(o, k) for k in o.__slots__ if not k.startswith('_')}

    else:
        raise TypeError

    if encrypt and 'password' in ret:
        crypto_engine = crypto_engine or crypto.get_default_crypto_engine()
        ret['password'] = crypto_engine.encrypt(ret['password'])

    return ret
 makes some serializing interpretations of objects for json 
makes some serializing interpretations of objects for json
makes some serializing interpretations of objects for json
def default_json(o, encrypt=False, crypto_engine=None):
    from uuid import UUID
    import ipaddress
    str_classes = UUID, ipaddress._IPAddressBase
    if any(isinstance(o, str_cls) for str_cls in str_classes):
        if o is None:
            return None
        return str(o)
    if hasattr(o, 'to_json'):
        ret = o.to_json()
    elif o.__dict__:
        ret = o.__dict__
    elif o.__slots__:
        ret = {k:getattr(o, k) for k in o.__slots__ if not k.startswith('_')}
    else:
        raise TypeError
    if encrypt and 'password' in ret:
        crypto_engine = crypto_engine or crypto.get_default_crypto_engine()
        ret['password'] = crypto_engine.encrypt(ret['password'])
    return ret
def default_json ( o , encrypt = False , crypto_engine = None ) : from uuid import UUID import ipaddress str_classes = UUID , ipaddress . _IPAddressBase if any ( isinstance ( o , str_cls ) for str_cls in str_classes ) : if o is None : return None return str ( o ) if hasattr ( o , 'to_json' ) : ret = o . to_json ( ) elif o . __dict__ : ret = o . __dict__ elif o . __slots__ : ret = { k : getattr ( o , k ) for k in o . __slots__ if not k . startswith ( '_' ) } else : raise TypeError if encrypt and 'password' in ret : crypto_engine = crypto_engine or crypto . get_default_crypto_engine ( ) ret [ 'password' ] = crypto_engine . encrypt ( ret [ 'password' ] ) return ret
makes some serializing interpretations of objects for json
makes some serializing interpretations of objects for json
""" makes some serializing interpretations of objects for json """
o
encrypt
crypto_engine