• 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.5
/trnsysGUI/connection/addSinglePipeConnectionCommand.py
1
from __future__ import annotations
1✔
2

3
import typing as _tp
1✔
4

5
import PyQt5.QtWidgets as _qtw
1✔
6
import pytrnsys.utils.result as _res
1✔
7

8
import trnsysGUI.connection.singlePipeConnection as _spc
1✔
9
import trnsysGUI.connection.undo as _cundo
1✔
10
import trnsysGUI.hydraulicLoops.merge as _hlmerge
1✔
11
import trnsysGUI.hydraulicLoops.split as _hlsplit
1✔
12
import trnsysGUI.names.undo as _nu
1✔
13
import trnsysGUI.warningsAndErrors as _werrors
1✔
14

15
if _tp.TYPE_CHECKING:
1✔
16
    import trnsysGUI.diagram.Editor as _ed
×
17

18

19
class AddSinglePipeConnectionCommand(_qtw.QUndoCommand):
1✔
20
    def __init__(
1✔
21
        self,
22
        connection: _spc.SinglePipeConnection,
23
        undoNamingHelper: _nu.UndoNamingHelper,
24
        editor: _ed.Editor,  # type: ignore[name-defined]
25
    ):
26
        super().__init__("Create single pipe connection")
×
27
        self._connection = connection
×
28
        self._undoNamingHelper = undoNamingHelper
×
29
        self._editor = editor
×
30

31
        self._mergeSummary: _tp.Optional[_hlmerge.MergeSummary] = None
×
32

33
    def redo(self):
1✔
NEW
34
        mergedLoopSummary = (
×
35
            self._mergeSummary.after if self._mergeSummary else None
36
        )  # pylint: disable=no-member
37

38
        cancellable = _hlmerge.merge(
×
39
            self._connection,
40
            self._editor.hydraulicLoops,
41
            self._editor.fluids.fluids,
42
            self._editor.fluids.WATER,
43
            mergedLoopSummary,
44
        )
45
        if cancellable == "cancelled" or _res.isError(cancellable):
×
46
            if _res.isError(cancellable):
×
47
                error = _res.error(cancellable)
×
NEW
48
                _werrors.showMessageBox(
×
49
                    error.message, "Cannot create connection"
50
                )
51

52
            self.setObsolete(True)
×
53
            return
×
54

55
        mergeSummary = cancellable
×
56

57
        self._mergeSummary = mergeSummary
×
58

59
        _cundo.setDisplayNameForReAdd(self._connection, self._undoNamingHelper)
×
60
        _cundo.reAddConnection(self._connection)
×
61
        self._editor.diagramScene.addItem(self._connection)
×
62

63
    def undo(self):
1✔
NEW
64
        splitLoopsSummary = (
×
65
            self._mergeSummary.before if self._mergeSummary else None
66
        )  # pylint: disable=no-member
67

68
        cancellable = _hlsplit.split(
×
69
            self._connection,
70
            self._editor.hydraulicLoops,
71
            self._editor.fluids.fluids,
72
            splitLoopsSummary,
73
        )
74
        assert cancellable != "cancelled"
×
75

76
        self._editor.diagramScene.removeItem(self._connection)
×
77
        self._connection.deleteConnection()
×
NEW
78
        self._undoNamingHelper.removeNameForDelete(
×
79
            self._connection.displayName
80
        )
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