Changeset - cd2103a83487
[Not reviewed]
default
0 1 0
timeless@gmail.com - 10 years ago 2016-05-03 14:15:59
timeless@gmail.com
spelling: succeeded
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/dbmigrate/migrate/versioning/util/__init__.py
Show inline comments
 
@@ -34,49 +34,49 @@ def load_model(dotted_name):
 
            dotted_name = ':'.join(dotted_name.rsplit('.', 1))
 
        return EntryPoint.parse('x=%s' % dotted_name).load(False)
 
    else:
 
        # Assume it's already loaded.
 
        return dotted_name
 

	
 
def asbool(obj):
 
    """Do everything to use object as bool"""
 
    if isinstance(obj, basestring):
 
        obj = obj.strip().lower()
 
        if obj in ['true', 'yes', 'on', 'y', 't', '1']:
 
            return True
 
        elif obj in ['false', 'no', 'off', 'n', 'f', '0']:
 
            return False
 
        else:
 
            raise ValueError("String is not true/false: %r" % obj)
 
    if obj in (True, False):
 
        return bool(obj)
 
    else:
 
        raise ValueError("String is not true/false: %r" % obj)
 

	
 
def guess_obj_type(obj):
 
    """Do everything to guess object type from string
 

	
 
    Tries to convert to `int`, `bool` and finally returns if not succeded.
 
    Tries to convert to `int`, `bool` and finally returns if not succeeded.
 

	
 
    .. versionadded: 0.5.4
 
    """
 

	
 
    result = None
 

	
 
    try:
 
        result = int(obj)
 
    except:
 
        pass
 

	
 
    if result is None:
 
        try:
 
            result = asbool(obj)
 
        except:
 
            pass
 

	
 
    if result is not None:
 
        return result
 
    else:
 
        return obj
 

	
 
@decorator
 
def catch_known_errors(f, *a, **kw):
0 comments (0 inline, 0 general)