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

SPF-OST / pytrnsys_gui / 11576810878

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

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

35.71
/trnsysGUI/components/ddckFolderHelpers.py
1
from __future__ import annotations
1✔
2

3
import pathlib as _pl
1✔
4
import shutil as _su
1✔
5
import typing as _tp
1✔
6

7
import PyQt5.QtWidgets as _qtw
1✔
8

9
import trnsysGUI.internalPiping as _ip
1✔
10
import trnsysGUI.warningsAndErrors as _werrors
1✔
11

12
if _tp.TYPE_CHECKING:
1✔
13
    import trnsysGUI.BlockItem as _bi
×
14

15

16
def moveComponentDdckFolderIfNecessary(
1✔
17
    blockItem: _bi.BlockItem,
18
    newName: str,
19
    oldName: str,
20
    projectDirPath: _pl.Path,
21
) -> None:
22
    if not hasComponentDdckFolder(blockItem):
×
23
        return
×
24

25
    oldComponentDirPath = getComponentDdckDirPath(oldName, projectDirPath)
×
26

27
    if oldComponentDirPath.is_dir():
×
28
        newComponentDirPath = getComponentDdckDirPath(newName, projectDirPath)
×
29
        _su.move(oldComponentDirPath, newComponentDirPath)
×
30
    else:
31
        _werrors.showMessageBox(
×
32
            f"The old ddck directory was not found at `{oldComponentDirPath} when trying to rename it to {newName}",
33
            _werrors.Title.WARNING,
34
        )
35
        createComponentDdckFolder(newName, projectDirPath)
×
36

37

38
def hasComponentDdckFolder(blockItem: _bi.BlockItem) -> bool:
1✔
NEW
39
    hasDdckFolder = (
×
40
        blockItem.hasDdckDirectory()
41
        if isinstance(blockItem, _ip.HasInternalPiping)
42
        else False
43
    )
UNCOV
44
    return hasDdckFolder
×
45

46

47
def getComponentDdckDirPath(
1✔
48
    displayName: str, projectDirPath: _pl.Path
49
) -> _pl.Path:
50
    oldComponentDirPath = projectDirPath / "ddck" / displayName
1✔
51
    return oldComponentDirPath
1✔
52

53

54
def createComponentDdckFolder(name: str, projectDirPath: _pl.Path) -> None:
1✔
55
    newComponentDirPath = getComponentDdckDirPath(name, projectDirPath)
×
56
    newComponentDirPath.mkdir()
×
57

58

59
def maybeDeleteNonEmptyComponentDdckFolder(
1✔
60
    blockItem: _bi.BlockItem, projectFolder: _pl.Path
61
) -> None:
62
    if not hasComponentDdckFolder(blockItem):
×
63
        return
×
64

65
    displayName = blockItem.displayName
×
66

67
    dirPath = getComponentDdckDirPath(displayName, projectFolder)
×
68

69
    if not dirPath.is_dir():
×
70
        return
×
71

72
    childItems = list(dirPath.iterdir())
×
73
    if childItems:
×
74
        formattedChildItems = "\n".join(p.name for p in childItems)
×
75
        message = f"""\
×
76
You're about to delete component `{displayName}`. Its component ddck folder is not empty
77
and contains the following items:
78

79
{formattedChildItems}
80

81
Would you like to delete the component ddck folder nonetheless? This cannot be undone.
82
"""
NEW
83
        standardButton = _qtw.QMessageBox.question(
×
84
            None, "Delete component ddck folder?", message
85
        )
86

NEW
87
        if (
×
88
            standardButton
89
            != _qtw.QMessageBox.StandardButton.Yes  # pylint: disable=no-member
90
        ):
UNCOV
91
            return
×
92

93
    _su.rmtree(dirPath)
×
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