<commit_before>from xmlrpc.server import SimpleXMLRPCServer

from ecc import ECC

class A2MXClientInterface():
	def __init__(self, node):
		self.node = node

	def find_routes(self, destination):
		try:
			return self._find_routes(destination)
		except Exception as e:
			import traceback
			traceback.print_exc()

	def _find_routes(self, destination):
		dst = ECC.b58decode(destination.encode('ascii'))
		if dst not in self.node.paths:
			return False
		me = self.node.ecc.pubkey_hash()
		pathlist = self.node.paths[dst]
		if len(pathlist) == 0:
			return False

		def find_path(pathlist, thispath=None):
			if thispath == None:
				thispath = [dst]
			for path in pathlist:
				lasthop = path.lasthop.pubkey_hash()
				if lasthop == me:
					ytp = thispath[:]
					ytp.append(lasthop)
					yield ytp
					continue
				if lasthop == dst:
					continue
				if lasthop in thispath:
					continue
				tp = thispath[:]
				tp.append(lasthop)
				for p in find_path(self.node.paths[lasthop], tp):
					yield p

		return [ p for p in find_path(pathlist) ]

		pi = 0
		for p in find_path(pathlist):
			s = 'path {}:'.format(pi)
			for hop in p:
				s+= ' ' + ECC.b58(hop).decode('ascii')
			print(s)
			pi += 1

		return True

class A2MXXMLRPCServer(SimpleXMLRPCServer):
	def __init__(self, node, bind):
		SimpleXMLRPCServer.__init__(self, bind, logRequests=False)
		self.register_introspection_functions()
		self.register_instance(A2MXClientInterface(node))

	def select_r(self):
		self.handle_request()
	def select_w(self):
		assert False
	def select_e(self):
		assert False

	def finish(self):
		pass
<commit_msg>cleanup<commit_after>from xmlrpc.server import SimpleXMLRPCServer

from ecc import ECC

class A2MXClientInterface():
	def __init__(self, node):
		self.node = node

	def find_routes(self, destination):
		try:
			return self._find_routes(destination)
		except Exception as e:
			import traceback
			traceback.print_exc()

	def _find_routes(self, destination):
		dst = ECC.b58decode(destination.encode('ascii'))
		if dst not in self.node.paths:
			return False
		me = self.node.ecc.pubkey_hash()
		pathlist = self.node.paths[dst]
		if len(pathlist) == 0:
			return False

		def find_path(pathlist, thispath=None):
			if thispath == None:
				thispath = [dst]
			for path in pathlist:
				lasthop = path.lasthop.pubkey_hash()
				if lasthop == me:
					ytp = thispath[:]
					ytp.append(lasthop)
					yield ytp
					continue
				if lasthop == dst:
					continue
				if lasthop in thispath:
					continue
				tp = thispath[:]
				tp.append(lasthop)
				for p in find_path(self.node.paths[lasthop], tp):
					yield p

		return [ p for p in find_path(pathlist) ]

class A2MXXMLRPCServer(SimpleXMLRPCServer):
	def __init__(self, node, bind):
		SimpleXMLRPCServer.__init__(self, bind, logRequests=False)
		self.register_introspection_functions()
		self.register_instance(A2MXClientInterface(node))

	def select_r(self):
		self.handle_request()
	def select_w(self):
		assert False
	def select_e(self):
		assert False

	def finish(self):
		pass

{'fraction_non_alphanumeric': 0.10483075911929017, 'fraction_numerical': 0.0052579691094314825, 'mean_word_length': 3.683076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3903063', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1065, 'n_words': 264}