def __new__(cls,n,on_fail='die'): if type(n) == cls: return n cls.arg_chk(cls,on_fail) from mmgen.util import is_int try: assert is_int(n),"'{}': value is not an integer".format(n) me = int.__new__(cls,n) return me except Exception as e: m = "{!r}: value cannot be converted to ETH nonce ({})" return cls.init_fail(m.format(n,e[0]),on_fail)
def __new__(cls, n, on_fail='die'): if type(n) == cls: return n cls.arg_chk(on_fail) from mmgen.util import is_int try: assert is_int(n), "'{}': value is not an integer".format(n) n = int(n) assert n >= 0, "'{}': value is negative".format(n) return int.__new__(cls, n) except Exception as e: return cls.init_fail(e, n)
def __new__(cls,n,on_fail='die'): if type(n) == cls: return n cls.arg_chk(on_fail) from mmgen.util import is_int try: assert is_int(n),"'{}': value is not an integer".format(n) n = int(n) assert n >= 0,"'{}': value is negative".format(n) return int.__new__(cls,n) except Exception as e: return cls.init_fail(e,n)
def __new__(cls,s,on_fail='die'): if type(s) == cls: return s cls.arg_chk(on_fail) try: assert issubclass(type(s),str),'not a string or string subclass' idx = s[:-1] if s[-1] in 'SsLl' else s from mmgen.util import is_int assert is_int(idx),"valid format: an integer, plus optional letter 'S','s','L' or 'l'" idx = int(idx) assert idx >= SubSeedIdxRange.min_idx, 'subseed index < {:,}'.format(SubSeedIdxRange.min_idx) assert idx <= SubSeedIdxRange.max_idx, 'subseed index > {:,}'.format(SubSeedIdxRange.max_idx) sstype,ltr = ('short','S') if s[-1] in 'Ss' else ('long','L') me = str.__new__(cls,str(idx)+ltr) me.idx = idx me.type = sstype return me except Exception as e: return cls.init_fail(e,s)
def __new__(cls, s, on_fail='die'): if type(s) == cls: return s cls.arg_chk(on_fail) try: assert issubclass(type(s), str), 'not a string or string subclass' idx = s[:-1] if s[-1] in 'SsLl' else s from mmgen.util import is_int assert is_int( idx ), "valid format: an integer, plus optional letter 'S','s','L' or 'l'" idx = int(idx) assert idx >= SubSeedIdxRange.min_idx, 'subseed index < {:,}'.format( SubSeedIdxRange.min_idx) assert idx <= SubSeedIdxRange.max_idx, 'subseed index > {:,}'.format( SubSeedIdxRange.max_idx) sstype, ltr = ('short', 'S') if s[-1] in 'Ss' else ('long', 'L') me = str.__new__(cls, str(idx) + ltr) me.idx = idx me.type = sstype return me except Exception as e: return cls.init_fail(e, s)