<commit_before>import networkx as nx
import itertools
import pprint
import time
from autonetkit.ank_utils import unwrap_edges, unwrap_nodes
import autonetkit.log as log
import functools
import string

try:
    import cPickle as pickle
except ImportError:
    import pickle

class AutoNetkitException(Exception):
    pass

class OverlayNotFound(AutoNetkitException):
    def __init__(self, errors):
        self.Errors = errors

    def __str__(self):
        return "Overlay %s not found" % self.Errors

#TODO: rename to OverlayInterface
class overlay_interface(object):
    def __init__(self, anm, overlay_id, node_id, interface_id):
        object.__setattr__(self, 'anm', anm)
        object.__setattr__(self, 'overlay_id', overlay_id)
        object.__setattr__(self, 'node_id', node_id)
        object.__setattr__(self, 'interface_id', interface_id)

    def __repr__(self):
        description = self.description or self.interface_id
        return "(%s, %s)" % (self.node_id, description)

    def __eq__(self, other):
        return (self.node_id, self.interface_id) == (other.node_id, other.interface_id)

    def __nonzero__(self):
        #TODO: work out why description and type being set/copied to each overlay
        return len(self._interface) > 0  # if interface data set

    def __lt__(self, other):
        #TODO: check how is comparing the nodes
        return ((self.node, self.interface_id) < (other.node, other.interface_id))

    @property
    def is_bound(self):
        """Returns if this interface is bound to an edge on this layer"""
        return len(self.edges()) > 0

    def __str__(self):
        return self.__repr__()

    @property
    def _graph(self):
        """Return graph the node belongs to"""
        return self.anm.overlay_nx_graphs[self.overlay_id]

    @property
    def _node(self):
        """Return graph data the node belongs to"""<commit_msg>better handling for non existent interfaces - eg oob added to nidb<commit_after>import networkx as nx
import itertools
import pprint
import time
from autonetkit.ank_utils import unwrap_edges, unwrap_nodes
import autonetkit.log as log
import functools
import string

try:
    import cPickle as pickle
except ImportError:
    import pickle

class AutoNetkitException(Exception):
    pass

class OverlayNotFound(AutoNetkitException):
    def __init__(self, errors):
        self.Errors = errors

    def __str__(self):
        return "Overlay %s not found" % self.Errors

#TODO: rename to OverlayInterface
class overlay_interface(object):
    def __init__(self, anm, overlay_id, node_id, interface_id):
        object.__setattr__(self, 'anm', anm)
        object.__setattr__(self, 'overlay_id', overlay_id)
        object.__setattr__(self, 'node_id', node_id)
        object.__setattr__(self, 'interface_id', interface_id)

    def __repr__(self):
        description = self.description or self.interface_id
        return "(%s, %s)" % (self.node_id, description)

    def __eq__(self, other):
        return (self.node_id, self.interface_id) == (other.node_id, other.interface_id)

    def __nonzero__(self):
        #TODO: work out why description and type being set/copied to each overlay
        try:
            interface = self._interface
        except KeyError:
            return False

        return len(interface) > 0  # if interface data set

    def __lt__(self, other):
        #TODO: check how is comparing the nodes
        return ((self.node, self.interface_id) < (other.node, other.interface_id))

    @property
    def is_bound(self):
        """Returns if this interface is bound to an edge on this layer"""
        return len(self.edges()) > 0

    def __str__(self):
        return self.__repr__()

    @property
    def _graph(self):
        """Return graph the node belongs to"""
        return self.anm.overlay_nx_graphs[self.overlay_id]

    @property
    def _node(self):
        """Return graph data the node belongs to"""
{'fraction_non_alphanumeric': 0.0917617237008872, 'fraction_numerical': 0.0010139416983523447, 'mean_word_length': 3.18895966029724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '461080', 'n_tokens_mistral': 1194, 'n_tokens_neox': 1154, 'n_words': 360}