Changeset 4ed10ae for fedd/fedd_util.py


Ignore:
Timestamp:
Nov 14, 2008 5:13:10 PM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
afa43a8
Parents:
2dafa0c
Message:

Proxy key additions working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_util.py

    r2dafa0c r4ed10ae  
    287287
    288288
     289def strip_unicode(obj):
     290    """Walk through a message and convert all strings to non-unicode strings"""
     291    if isinstance(obj, dict):
     292        for k in obj.keys():
     293            obj[k] = strip_unicode(obj[k])
     294        return obj
     295    elif isinstance(obj, basestring):
     296        return str(obj)
     297    elif getattr(obj, "__iter__", None):
     298        return [ strip_unicode(x) for x in obj]
     299    else:
     300        return obj
     301
     302def make_unicode(obj):
     303    """Walk through a message and convert all strings to unicode"""
     304    if isinstance(obj, dict):
     305        for k in obj.keys():
     306            obj[k] = make_unicode(obj[k])
     307        return obj
     308    elif isinstance(obj, basestring):
     309        return unicode(obj)
     310    elif getattr(obj, "__iter__", None):
     311        return [ make_unicode(x) for x in obj]
     312    else:
     313        return obj
     314
     315
    289316def generate_fedid(subj, bits=2048, log=None, dir=None, trace=sys.stderr):
    290317    """
     
    396423    return handler
    397424
     425
    398426def set_log_level(config, sect, log):
    399427    """ Set the logging level to the value passed in sect of config."""
Note: See TracChangeset for help on using the changeset viewer.