예제 #1
0
 def decode(cls, data):
     data = data.strip()
     if not data:
         # Turn it into default value at the time of writing
         return None
     try:
         value = Integer.decode(data)
     except ValueError:
         value = data
     return value
예제 #2
0
파일: utils.py 프로젝트: kennym/itools
def get_int_value(value, default=0):
    """
    Return the interger representation of value is his decoding succeed
    otherwise the default value
    """
    if not value:
        return default
    try:
        return Integer.decode(value)
    except ValueError:
        return default
예제 #3
0
def get_int_value(value, default=0):
    """
    Return the interger representation of value is his decoding succeed
    otherwise the default value
    """
    if not value:
        return default
    try:
        return Integer.decode(value)
    except ValueError:
        return default
예제 #4
0
 def test_Integer(self):
     for x in range(-10,11):
         data = Integer.encode(x)
         self.assertEqual(x, Integer.decode(data))