Пример #1
0
	def __str__(self):
		output = [Order.__str__(self)]
		for property in self.properties:
			arg = list(getattr(self, property.name))
			output.append(property.pack(arg))
			
		return "".join(output)
Пример #2
0
	def __str__(self):
		args = []
		for name, type in self.names:
			struct, size = ARG_STRUCTMAP[type]
			
			attr = getattr(self, name)
			if size == 1:
				args.append(attr)
			else:
				args += list(attr)

		output = Order.__str__(self)
		try:
			output += pack(self.substruct, *args)
			return output
		except TypeError, e:
			s = str(e)

			causedby = '%s %s' % self.names[int(s[:s.find(' ')])]
			being    = getattr(self, name)

			traceback = sys.exc_info()[2]
			while not traceback.tb_next is None:
				traceback = traceback.tb_next

			raise TypeError, '%s was %s\n%s' % (causedby, being, e), traceback