def aggregator(self, scope, name, command, tokens): try: if tokens: if tokens.pop(0) != '(': raise ValueError('invalid aggregator syntax') asn, address = tokens.pop(0).split(':') if tokens.pop(0) != ')': raise ValueError('invalid aggregator syntax') local_as = ASN(asn) local_address = RouterID(address) else: local_as = scope[-1]['local-as'] local_address = scope[-1]['local-address'] except (ValueError, IndexError): return self.error.set(self.syntax) except KeyError: return self.error( 'local-as and/or local-address missing from neighbor/group to make aggregator' ) except ValueError: return self.error.set(self.syntax) scope[-1]['announce'][-1].attributes.add( Aggregator(local_as, local_address)) return True
def aggregator(tokeniser): agg = tokeniser() eat = True if agg == '(' else False if eat: agg = tokeniser() if agg.endswith(')'): eat = False agg = agg[:-1] elif agg.startswith('('): if agg.endswith(')'): eat = False agg = agg[1:-1] else: eat = True agg = agg[1:] try: as_number, address = agg.split(':') local_as = ASN.from_string(as_number) local_address = RouterID(address) except (ValueError, IndexError): raise ValueError('invalid aggregator') if eat: if tokeniser() != ')': raise ValueError('invalid aggregator') return Aggregator(local_as, local_address)
def aggregator(tokeniser): eat = True if tokeniser.tokens[0] == '(' else False if eat: tokeniser() value = tokeniser() if value != '(': tokeniser.rewind(value) return None try: as_number, address = tokeniser().split(':') local_as = ASN.from_string(as_number) local_address = RouterID(address) except (ValueError, IndexError): raise ValueError('invalid aggregator') if eat: value = tokeniser() if value != ')': raise ValueError('invalid aggregator') # XXX: This is buggy it can be an Aggregator4 return Aggregator(local_as, local_address)
def aggregator(tokeniser): first = tokeniser.peek() eat = True if first == '(' else False if eat: tokeniser() try: as_number, address = tokeniser().split(':') local_as = ASN.from_string(as_number) local_address = RouterID(address) except (ValueError, IndexError): raise ValueError('invalid aggregator') if eat: if tokeniser() != ')': raise ValueError('invalid aggregator') return Aggregator(local_as, local_address)
def aggregator (tokeniser): value = tokeniser() if value != '(': tokeniser.rewind(value) return None try: as_number,address = tokeniser().split(':') except (ValueError,IndexError): raise ValueError('invalid aggregator') value = tokeniser() if value != ')': raise ValueError('invalid aggregator') local_as = ASN(as_number) local_address = RouterID(address) # XXX: This is buggy it can be an Aggregator4 return Aggregator(local_as,local_address)
def aggregator(tokeniser): eat = tokeniser.tokens and tokeniser.tokens[0] == '(' if eat: tokeniser() try: as_number, address = tokeniser().split(':') local_as = ASN.from_string(as_number) local_address = RouterID(address) except (ValueError, IndexError): raise ValueError('invalid aggregator') if eat: if tokeniser() != ')': raise ValueError('invalid aggregator') # XXX: This could be buggy - check it if local_as.asn4(): return Aggregator4(local_as, local_address) return Aggregator(local_as, local_address)