• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / pytrnsys_gui / 11662562960

29 Oct 2024 03:09PM UTC coverage: 67.508% (-0.08%) from 67.591%
11662562960

push

github

web-flow
Merge pull request #564 from SPF-OST/560-black-change-line-length-to-pep8-standard-of-79-and-check-ci-reaction

changed line length in black to 79

1054 of 1475 new or added lines in 174 files covered. (71.46%)

150 existing lines in 74 files now uncovered.

10399 of 15404 relevant lines covered (67.51%)

0.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.76
/trnsysGUI/modifyRelativeHeightsDialog.py
1
import dataclasses as _dc
1✔
2
import typing as _tp
1✔
3

4
import PyQt5.QtCore as _qtc
1✔
5
import PyQt5.QtWidgets as _qwt
1✔
6

7
NewHeight = float | _tp.Literal["empty"]
1✔
8

9

10
@_dc.dataclass
1✔
11
class NewRelativeHeights:
1✔
12
    input: NewHeight
1✔
13
    output: NewHeight
1✔
14

15

16
class ModifyRelativeHeightsDialog(_qwt.QDialog):
1✔
17
    """
1✔
18
    A dialog box lets the user choose the path and the name of folder for a new project
19
    """
20

21
    def __init__(
1✔
22
        self,
23
        relativeInputHeight: float,
24
        relativeOutputHeight: float,
25
        parent=None,
26
    ):
UNCOV
27
        super().__init__(parent)
×
28

29
        self.newRelativeHeights: _tp.Optional[NewRelativeHeights] = None
×
30

NEW
31
        inputLabel = _qwt.QLabel(
×
32
            f"New input height (was {relativeInputHeight * 100:.0f}%): "
33
        )
34
        self._inputLineEdit = _qwt.QLineEdit()
×
35
        inputLayout = _qwt.QHBoxLayout()
×
36
        inputLayout.addWidget(inputLabel)
×
37
        inputLayout.addWidget(self._inputLineEdit)
×
38

NEW
39
        outputLabel = _qwt.QLabel(
×
40
            f"New output height (was {relativeOutputHeight * 100:.0f}%): "
41
        )
42
        self._outputLineEdit = _qwt.QLineEdit()
×
43
        outputLayout = _qwt.QHBoxLayout()
×
44
        outputLayout.addWidget(outputLabel)
×
45
        outputLayout.addWidget(self._outputLineEdit)
×
46

47
        okButton = _qwt.QPushButton("Done")
×
48
        okButton.setFixedWidth(50)
×
49
        buttonLayout = _qwt.QHBoxLayout()
×
50
        buttonLayout.addWidget(okButton, alignment=_qtc.Qt.AlignCenter)
×
51

52
        overallLayout = _qwt.QVBoxLayout()
×
53
        overallLayout.addLayout(inputLayout)
×
54
        overallLayout.addLayout(outputLayout)
×
55
        overallLayout.addLayout(buttonLayout)
×
56
        self.setLayout(overallLayout)
×
57
        self.setFixedWidth(400)
×
58

59
        okButton.clicked.connect(self._onOk)
×
60
        self.setWindowTitle("Modify direct port couple")
×
61
        self.exec()
×
62

63
    def _onOk(self):
1✔
64
        inputText = self._inputLineEdit.text()
×
65
        newRelativeInputHeight = self._getNewRelativeHeight(inputText, "input")
×
66
        if not newRelativeInputHeight:
×
67
            return
×
68

69
        outputText = self._outputLineEdit.text()
×
NEW
70
        newRelativeOutputHeight = self._getNewRelativeHeight(
×
71
            outputText, "output"
72
        )
73
        if not newRelativeOutputHeight:
×
74
            return
×
75

NEW
76
        self.newRelativeHeights = NewRelativeHeights(
×
77
            newRelativeInputHeight, newRelativeOutputHeight
78
        )
79

80
        self.close()
×
81

82
    @classmethod
1✔
83
    def _getNewRelativeHeight(
1✔
84
        cls, relativeHeightInPercentAsText: str, portName: str
85
    ) -> _tp.Optional[NewHeight]:
86
        if not relativeHeightInPercentAsText:
×
87
            return "empty"
×
88

89
        try:
×
90
            relativeHeightInPercent = int(relativeHeightInPercentAsText)
×
91
        except ValueError:
×
92
            cls._showFormattingError(portName)
×
93
            return None
×
94

95
        if not 1 <= relativeHeightInPercent <= 99:
×
96
            cls._showFormattingError(portName)
×
97
            return None
×
98

99
        return relativeHeightInPercent / 100
×
100

101
    @staticmethod
1✔
102
    def _showFormattingError(portName: str) -> None:
1✔
103
        messageBox = _qwt.QMessageBox()
×
NEW
104
        messageBox.setText(
×
105
            f"Value for '{portName}' must be an integer between 1 and 99 inclusive."
106
        )
UNCOV
107
        messageBox.exec()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc