<commit_before>#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
GraphicsItem to model a component

author: <NAME>

"""

import sys
from PyQt5.QtWidgets import QWidget, QGraphicsItem, QPushButton, QVBoxLayout, QMenu, QAction, QInputDialog, QMessageBox
from PyQt5.QtCore import QRectF, QRect, QPointF, QPoint, Qt, QVariant
from PyQt5.QtGui import QColor, QPainter, QBrush, QPainterPath, QLinearGradient, QFont, QContextMenuEvent
from collections import Counter
from socketgi import SocketGI
import schemastyle

class ComponentGI(QGraphicsItem):

    def __init__(self, name, leftSockets=[], rightSockets=[]):
        super().__init__()
        
        self.compWidth = 150
        self.compHeight = 50
        self.snappingIsOn = True

        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
        self.setAcceptHoverEvents(True)
        self.hovering = False

        self.compName = name
        self.leftSocketGItems = {}
        self.rightSocketGItems = {}

        # Create sockets for the left side
        for ind, lsn in enumerate(leftSockets):
            lsockGItem = SocketGI(lsn, SocketGI.LEFT, self)
            hoffs = -(len(leftSockets) - 1) * 20 // 2
            lsockGItem.moveBy(-self.compWidth // 2, hoffs + ind * 20)
            lsockGItem.setParentItem(self)
            self.leftSocketGItems[lsn] = lsockGItem

        # Create sockets for the right side
        for ind, rsn in enumerate(rightSockets):
            rsockGItem = SocketGI(rsn, SocketGI.RIGHT, self)
            hoffs = -(len(rightSockets) - 1) * 20 // 2
            rsockGItem.moveBy(self.compWidth // 2, hoffs + ind * 20)
            rsockGItem.setParentItem(self)
            self.rightSocketGItems[rsn] = rsockGItem

    @property<commit_msg>sockets are now ordered properly.<commit_after>#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
GraphicsItem to model a component

author: <NAME>

"""

import sys
from PyQt5.QtWidgets import QWidget, QGraphicsItem, QPushButton, QVBoxLayout, QMenu, QAction, QInputDialog, QMessageBox
from PyQt5.QtCore import QRectF, QRect, QPointF, QPoint, Qt, QVariant
from PyQt5.QtGui import QColor, QPainter, QBrush, QPainterPath, QLinearGradient, QFont, QContextMenuEvent
from collections import Counter, OrderedDict
from socketgi import SocketGI
import schemastyle

class ComponentGI(QGraphicsItem):

    def __init__(self, name, leftSockets=[], rightSockets=[]):
        super().__init__()
        
        self.compWidth = 150
        self.compHeight = 50
        self.snappingIsOn = True

        self.setFlag(QGraphicsItem.ItemIsSelectable, True)
        self.setFlag(QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
        self.setAcceptHoverEvents(True)
        self.hovering = False

        self.compName = name
        self.leftSocketGItems = OrderedDict()
        self.rightSocketGItems = OrderedDict()

        # Create sockets for the left side
        for ind, lsn in enumerate(leftSockets):
            lsockGItem = SocketGI(lsn, SocketGI.LEFT, self)
            hoffs = -(len(leftSockets) - 1) * 20 // 2
            lsockGItem.moveBy(-self.compWidth // 2, hoffs + ind * 20)
            lsockGItem.setParentItem(self)
            self.leftSocketGItems[lsn] = lsockGItem

        # Create sockets for the right side
        for ind, rsn in enumerate(rightSockets):
            rsockGItem = SocketGI(rsn, SocketGI.RIGHT, self)
            hoffs = -(len(rightSockets) - 1) * 20 // 2
            rsockGItem.moveBy(self.compWidth // 2, hoffs + ind * 20)
            rsockGItem.setParentItem(self)
            self.rightSocketGItems[rsn] = rsockGItem

    @property
{'fraction_non_alphanumeric': 0.09541478929234032, 'fraction_numerical': 0.012721971905645375, 'mean_word_length': 2.792964824120603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '54766', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1171, 'n_words': 278}