From 61d86c381f2ac2382f24472d7dfa69ea647456eb Mon Sep 17 00:00:00 2001 From: Vincent Texier <vit@free.fr> Date: Sat, 7 Mar 2015 19:31:20 +0100 Subject: [PATCH] Display path to account in member window --- src/cutecoin/core/graph.py | 23 ++++++++++++++++++++--- src/cutecoin/gui/views/wot.py | 2 +- src/cutecoin/gui/wot_tab.py | 2 +- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cutecoin/core/graph.py b/src/cutecoin/core/graph.py index b4f1aa8e..12364759 100644 --- a/src/cutecoin/core/graph.py +++ b/src/cutecoin/core/graph.py @@ -9,15 +9,27 @@ from cutecoin.gui.views.wot import NODE_STATUS_HIGHLIGHTED, NODE_STATUS_OUT, ARC class Graph(dict): def __init__(self, community): + """ + Init Graph instance + :param cutecoin.core.community.Community community: + :return: + """ self.community = community self.signature_validity = self.community.get_parameters()['sigValidity'] #Â arc considered strong during 75% of signature validity time self.ARC_STATUS_STRONG_time = int(self.signature_validity * 0.75) def get_shortest_path_between_members(self, from_person, to_person): + """ + Return path list of nodes from from_person to to_person + :param Person from_person: + :param Person to_person: + :return: + """ path = list() graph_tmp = copy.deepcopy(self) + logging.debug("path between %s to %s..." % (from_person.name, to_person.name)) if from_person.pubkey not in graph_tmp.keys(): graph_tmp.add_person(from_person) certifier_list = from_person.certifiers_of(self.community) @@ -39,7 +51,12 @@ class Graph(dict): return path - def explore_to_find_member(self, person, nodes=list(), done=list()): + def explore_to_find_member(self, person, nodes=None, done=None): + # functions keywords args are persistent... Need to reset it with None trick + nodes = nodes or (list() and (nodes is None)) + done = done or (list() and (done is None)) + logging.debug("search %s in " % person.name) + logging.debug([node['text'] for node in nodes]) for node in tuple(nodes): if node['id'] in tuple(done): continue @@ -180,8 +197,8 @@ class Graph(dict): def add_person(self, person, status=0, arcs=None, nodes=None): # functions keywords args are persistent... Need to reset it with None trick - arcs = list() and (arcs is None) - nodes = list() and (nodes is None) + arcs = arcs or (list() and (arcs is None)) + nodes = nodes or (list() and (nodes is None)) self[person.pubkey] = { 'id': person.pubkey, 'arcs': arcs, diff --git a/src/cutecoin/gui/views/wot.py b/src/cutecoin/gui/views/wot.py index e3069078..682c2992 100644 --- a/src/cutecoin/gui/views/wot.py +++ b/src/cutecoin/gui/views/wot.py @@ -282,7 +282,7 @@ class Node(QGraphicsEllipseItem): #Â create node context menus self.menu = QMenu() # action show member - self.action_show_member = QAction('Show member', self.scene()) + self.action_show_member = QAction('Informations', self.scene()) self.menu.addAction(self.action_show_member) self.action_show_member.triggered.connect(self.member_action) #Â action add identity as contact diff --git a/src/cutecoin/gui/wot_tab.py b/src/cutecoin/gui/wot_tab.py index 64f1515c..aa2b5409 100644 --- a/src/cutecoin/gui/wot_tab.py +++ b/src/cutecoin/gui/wot_tab.py @@ -58,7 +58,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): :param dict metadata: Graph node metadata of the identity """ - logging.debug("draw graph !!!!!!!!!!!! - " + metadata['text']) + logging.debug("Draw graph - " + metadata['text']) # create Person from node metadata person = get_person_from_metadata(metadata) -- GitLab