(s)
return n
Convert a number field to a python number.
Convert a number field to a python number.
Convert a number field to a python number .
def nti(s):
    """Convert a number field to a python number.
    """
    # There are two possible encodings for a number field, see
    # itn() below.
    if s[0] in (0o200, 0o377):
        n = 0
        for i in range(len(s) - 1):
            n <<= 8
            n += s[i + 1]
        if s[0] == 0o377:
            n = -(256 ** (len(s) - 1) - n)
    else:
        try:
            s = nts(s, "ascii", "strict")
            n = int(s.strip() or "0", 8)
        except ValueError:
            raise InvalidHeaderError("invalid header")
    return n
def nti ( s ) : # There are two possible encodings for a number field, see # itn() below. if s [ 0 ] in ( 0o200 , 0o377 ) : n = 0 for i in range ( len ( s ) - 1 ) : n <<= 8 n += s [ i + 1 ] if s [ 0 ] == 0o377 : n = - ( 256 ** ( len ( s ) - 1 ) - n ) else : try : s = nts ( s , "ascii" , "strict" ) n = int ( s . strip ( ) or "0" , 8 ) except ValueError : raise InvalidHeaderError ( "invalid header" ) return n