<commit_before># -*- coding: utf-8 -*-

import time
import datetime
from PyQt5.QtWidgets import QWidget

from ..gen_resources.wot_tab_uic import Ui_WotTabWidget
from cutecoin.gui.views.wot import NODE_STATUS_HIGHLIGHTED, NODE_STATUS_SELECTED, ARC_STATUS_STRONG, ARC_STATUS_WEAK
from ucoinpy.api import bma


class WotTabWidget(QWidget, Ui_WotTabWidget):
    def __init__(self, account, community, parent=None):
        """

        :param cutecoin.core.account.Account account:
        :param cutecoin.core.community.Community community:
        :param parent:
        :return:
        """
        super().__init__(parent)

        # construct from qtDesigner
        self.setupUi(self)

        # add combobox events
        self.comboBoxSearch.lineEdit().textEdited.connect(self.search)
        self.comboBoxSearch.lineEdit().returnPressed.connect(self.combobox_return_pressed)

        # add scene events
        self.graphicsView.scene().node_signed.connect(self.sign_node)
        self.graphicsView.scene().node_clicked.connect(self.draw_graph)

        self.account = account
        self.community = community

        # nodes list for menu from search
        self.nodes = list()
        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)
        self.draw_graph(self.account.pubkey)

    def draw_graph(self, public_key):
        """
        Draw community graph centered on public_key identity

        :param public_key: Public key of the identity
        """
        graph = dict()
        # add wallet node
        node_status = (NODE_STATUS_HIGHLIGHTED and (public_key == self.account.pubkey)) or 0
        node_status += NODE_STATUS_SELECTED
        certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key})

        graph[public_key] = {'arcs': [], 'text': certifiers['uid'], 'tooltip': public_key, 'status': node_status}

        # add certifiers of uid
        for certifier in certifiers['certifications']:<commit_msg>Fix bug in wot if public key is unknown<commit_after># -*- coding: utf-8 -*-

import time
import datetime
import logging
from PyQt5.QtWidgets import QWidget

from ..gen_resources.wot_tab_uic import Ui_WotTabWidget
from cutecoin.gui.views.wot import NODE_STATUS_HIGHLIGHTED, NODE_STATUS_SELECTED, ARC_STATUS_STRONG, ARC_STATUS_WEAK
from ucoinpy.api import bma


class WotTabWidget(QWidget, Ui_WotTabWidget):
    def __init__(self, account, community, parent=None):
        """

        :param cutecoin.core.account.Account account:
        :param cutecoin.core.community.Community community:
        :param parent:
        :return:
        """
        super().__init__(parent)

        # construct from qtDesigner
        self.setupUi(self)

        # add combobox events
        self.comboBoxSearch.lineEdit().textEdited.connect(self.search)
        self.comboBoxSearch.lineEdit().returnPressed.connect(self.combobox_return_pressed)

        # add scene events
        self.graphicsView.scene().node_signed.connect(self.sign_node)
        self.graphicsView.scene().node_clicked.connect(self.draw_graph)

        self.account = account
        self.community = community

        # nodes list for menu from search
        self.nodes = list()
        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)
        self.draw_graph(self.account.pubkey)

    def draw_graph(self, public_key):
        """
        Draw community graph centered on public_key identity

        :param public_key: Public key of the identity
        """
        try:
            certifiers = self.community.request(bma.wot.CertifiersOf, {'search': public_key})
        except ValueError as e:
            logging.debug('bma.wot.CertifiersOf request error : ' + str(e))
            return False

        # reset graph
        graph = dict()

        # add wallet node
        node_status = (NODE_STATUS_HIGHLIGHTED and (public_key == self.account.pubkey)) or 0
        node_status += NODE_STATUS_SELECTED

        # highlighted node (wallet)
        graph[public_key] = {'arcs': [], 'text': certifiers['uid'], 'tooltip': public_key, 'status': node_status}

        # add certifiers of uid
        for certifier in certifiers['certifications']:
{'fraction_non_alphanumeric': 0.09522752497225305, 'fraction_numerical': 0.003551609322974473, 'mean_word_length': 2.9491673970201577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '5909321', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1314, 'n_words': 297}