def _mangle_prefix(res):
    """ Mangle prefix result
    """
    # fugly cast from large numbers to string to deal with XML-RPC
    res['total_addresses'] = unicode(res['total_addresses'])
    res['used_addresses'] = unicode(res['used_addresses'])
    res['free_addresses'] = unicode(res['free_addresses'])

    # postgres has notion of infinite while datetime hasn't, if expires
    # is equal to the max datetime we assume it is infinity and instead
    # represent that as None
    if res['expires'].tzinfo is None:
        res['expires'] = pytz.utc.localize(res['expires'])
    if res['expires'] == pytz.utc.localize(datetime.datetime.max):
        res['expires'] = None

    return res
def _mangle_prefix ( res ) : res [ 'total_addresses' ] = unicode ( res [ 'total_addresses' ] ) res [ 'used_addresses' ] = unicode ( res [ 'used_addresses' ] ) res [ 'free_addresses' ] = unicode ( res [ 'free_addresses' ] ) if res [ 'expires' ] . tzinfo is None : res [ 'expires' ] = pytz . utc . localize ( res [ 'expires' ] ) if res [ 'expires' ] == pytz . utc . localize ( datetime . datetime . max ) : res [ 'expires' ] = None return res
Mangle prefix result