def aigp(self, scope, name, command, tokens): try: number = tokens.pop(0) base = 16 if number.lower().startswith('0x') else 10 scope[-1]['announce'][-1].attributes.add( AIGP('\x01\x00\x0b' + pack('!Q', int(number, base)))) return True except (IndexError, ValueError): return self.error.set(self.syntax)
def aigp(tokeniser): if not tokeniser.tokens: raise ValueError('aigp requires number (decimal or hexadecimal 0x prefixed)') value = tokeniser() base = 16 if value.lower().startswith('0x') else 10 try: number = int(value, base) except ValueError: raise ValueError('aigp requires number (decimal or hexadecimal 0x prefixed)') return AIGP(b'\x01\x00\x0b' + pack('!Q', number))