• 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

37.93
/trnsysGUI/proforma/dialogs/convertDialog.py
1
import dataclasses as _dc
1✔
2
import pathlib as _pl
1✔
3
import collections.abc as _cabc
1✔
4

5
import PyQt5.QtWidgets as _qtw
1✔
6
import PyQt5.QtCore as _qtc
1✔
7

8
import trnsysGUI.common.cancelled as _cancel
1✔
9
import trnsysGUI.dialogs as _dlgs
1✔
10
import trnsysGUI.internalPiping as _ip
1✔
11

12
_dlgs.assertThatLocalGeneratedUIModuleAndResourcesExist(
1✔
13
    __name__, moduleName="_UI_convert_generated"
14
)
15

16
from . import _UI_convert_generated as _uigen  # type: ignore[import]  # pylint: disable=wrong-import-position
1✔
17

18

19
@_dc.dataclass
1✔
20
class DialogResult:
1✔
21
    internalPiping: _ip.InternalPiping
1✔
22
    outputFilePath: _pl.Path
1✔
23

24

25
class ConvertDialog(_qtw.QDialog, _uigen.Ui_Convert):
1✔
26
    def __init__(
1✔
27
        self,
28
        hasInternalPipings: _cabc.Sequence[_ip.HasInternalPiping],
29
        outputFilePath: _pl.Path,
30
    ) -> None:
31
        super().__init__()
×
32
        self.setupUi(self)
×
33

34
        if not hasInternalPipings:
×
35
            raise ValueError("Must have at least one internal piping.")
×
36

37
        self.outputFilePathLineEdit.setText(str(outputFilePath))
×
NEW
38
        self.outputFilePathLineEdit.textChanged.connect(
×
39
            self._onOutputFilePathLineEditTextChanged
40
        )
41

42
        self._configureComponentComboBox(hasInternalPipings)
×
43

44
        componentName = outputFilePath.parent.name
×
NEW
45
        currentInternalPiping = self._setAndGetCurrentInternalPiping(
×
46
            componentName
47
        )
48

49
        self.dialogResult = DialogResult(currentInternalPiping, outputFilePath)
×
50

NEW
51
        self.chooseOutputFilePathPushButton.pressed.connect(
×
52
            self._onChooseOutputFilePathPushButtonPressed
53
        )
54

55
        self.okCancelButtonBox.accepted.connect(self.accept)
×
56
        self.okCancelButtonBox.rejected.connect(self.reject)
×
57

58
    def _configureComponentComboBox(
1✔
59
        self, hasInternalPipings: _cabc.Sequence[_ip.HasInternalPiping]
60
    ) -> None:
61
        def getDisplayName(hip: _ip.HasInternalPiping) -> str:
×
62
            return hip.getDisplayName()
×
63

NEW
64
        sortedHasInternalPiping = sorted(
×
65
            hasInternalPipings, key=getDisplayName
66
        )
67
        for hasInternalPiping in sortedHasInternalPiping:
×
68
            displayName = hasInternalPiping.getDisplayName()
×
69
            internalPiping = hasInternalPiping.getInternalPiping()
×
70

71
            self.componentComboBox.addItem(displayName, internalPiping)
×
72

73
    def _setAndGetCurrentInternalPiping(
1✔
74
        self, componentName: str
75
    ) -> _ip.InternalPiping:
NEW
76
        currentIndex = self.componentComboBox.findText(
×
77
            componentName, _qtc.Qt.MatchContains
78
        )
79
        currentIndex = max(0, currentIndex)
×
80
        self.componentComboBox.setCurrentIndex(currentIndex)
×
81
        currentInternalPiping = self.componentComboBox.currentData()
×
82
        return currentInternalPiping
×
83

84
    def _onOutputFilePathLineEditTextChanged(self, newText: str) -> None:
1✔
85
        self.dialogResult.outputFilePath = _pl.Path(newText)
×
86

87
    def _onChooseOutputFilePathPushButtonPressed(self) -> None:
1✔
88
        currentOutputFilePathString = self.outputFilePathLineEdit.text()
×
89

90
        newOutputFilePathString, _ = _qtw.QFileDialog.getSaveFileName(
×
91
            None, "Select ouput file path...", currentOutputFilePathString
92
        )
93

94
        if not newOutputFilePathString:
×
95
            return
×
96

97
        self.outputFilePathLineEdit.setText(newOutputFilePathString)
×
98

99
    @staticmethod
1✔
100
    def showDialogAndGetResults(
1✔
101
        hasInternalPipings: _cabc.Sequence[_ip.HasInternalPiping],
102
        outputFilePath: _pl.Path,
103
    ) -> _cancel.MaybeCancelled[DialogResult]:
104
        dialog = ConvertDialog(hasInternalPipings, outputFilePath)
×
105
        returnValue = dialog.exec()
×
106

107
        if returnValue == _qtw.QDialog.Rejected:
×
108
            return _cancel.CANCELLED
×
109

110
        return dialog.dialogResult
×
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