Beispiel #1
0
def od (value):
	def spaced (value):
		even = None
		for v in value:
			if even is False:
				yield ' '
			yield '%02X' % ordinal(v)
			even = not even
	return concat_strs_i(spaced(value))
Beispiel #2
0
def od(value):
    def spaced(value):
        even = None
        for v in value:
            if even is False:
                yield ' '
            yield '%02X' % ordinal(v)
            even = not even

    return concat_strs_i(spaced(value))
Beispiel #3
0
	def json (self, compact=None):
		string = []
		for index in sorted(self.rules):
			rules = self.rules[index]
			s = []
			for idx,rule in enumerate(rules):
				# only add ' ' after the first element
				if idx and not rule.operations & NumericOperator.AND:
					s.append(', ')
				if rule.FLAG:
					s.append(', '.join('"%s"' % flag for flag in rule.value.named_bits()))
				else:
					s.append('"%s"' % rule)
			string.append(' "%s": [ %s ]' % (rules[0].NAME,concat_strs_i(str(_) for _ in s).replace('""','')))
		nexthop = ', "next-hop": "%s"' % self.nexthop if self.nexthop is not NoNextHop else ''
		rd = '' if self.rd is RouteDistinguisher.NORD else ', %s' % self.rd.json()
		compatibility = ', "string": "%s"' % self.extensive()
		return '{' + ','.join(string) + rd + nexthop + compatibility + ' }'
Beispiel #4
0
	def json (self, compact=None):
		string = []
		for index in sorted(self.rules):
			rules = self.rules[index]
			s = []
			for idx,rule in enumerate(rules):
				# only add ' ' after the first element
				if idx and not rule.operations & NumericOperator.AND:
					s.append(', ')
				if rule.FLAG:
					s.append(', '.join('"%s"' % flag for flag in rule.value.named_bits()))
				else:
					s.append('"%s"' % rule)
			string.append(' "%s": [ %s ]' % (rules[0].NAME,concat_strs_i(str(_) for _ in s).replace('""','')))
		nexthop = ', "next-hop": "%s"' % self.nexthop if self.nexthop is not NoNextHop else ''
		rd = '' if self.rd is RouteDistinguisher.NORD else ', %s' % self.rd.json()
		compatibility = ', "string": "%s"' % self.extensive()
		return '{' + ','.join(string) + rd + nexthop + compatibility + ' }'