Sat, 20 Apr 2024 18:01:36 +0200
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
3 | # Copyright (c) 2012 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the UML diagram builder base class. |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtCore import QObject |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | class UMLDiagramBuilder(QObject): |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | Class implementing the UML diagram builder base class. |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
17 | |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | def __init__(self, dialog, view, project): |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
21 | |
8289
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
22 | @param dialog reference to the UML dialog |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
23 | @type UMLDialog |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
24 | @param view reference to the view object |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
25 | @type UMLGraphicsView |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
26 | @param project reference to the project object |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
27 | @type Project |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7923
diff
changeset
|
29 | super().__init__(dialog) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
30 | |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.umlView = view |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.scene = self.umlView.scene() |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.project = project |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
2033
4b99609f6a87
Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2031
diff
changeset
|
35 | def initialize(self): |
4b99609f6a87
Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2031
diff
changeset
|
36 | """ |
4b99609f6a87
Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2031
diff
changeset
|
37 | Public method to initialize the object. |
4b99609f6a87
Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2031
diff
changeset
|
38 | """ |
4b99609f6a87
Some more refactorings to prepare loading graphics diagrams from file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2031
diff
changeset
|
39 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
8295 | 41 | def buildErrorMessage(self, msg): |
42 | """ | |
43 | Public method to build an error string to be included in the scene. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
8295 | 45 | @param msg error message |
46 | @type str | |
47 | @return prepared error string | |
48 | @rtype str | |
49 | """ | |
50 | return ( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | "<font color='{0}'>".format(self.umlView.getDrawingColors()[0].name()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | + msg |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
53 | + "</font>" |
8295 | 54 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | def buildDiagram(self): |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | Public method to build the diagram. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
59 | |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | This class must be implemented in subclasses. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
61 | |
2953
703452a2876f
Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
62 | @exception NotImplementedError raised to indicate that this class |
703452a2876f
Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
63 | must be subclassed |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | raise NotImplementedError( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | "Method 'buildDiagram' must be implemented in subclasses." |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
67 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
69 | def parsePersistenceData(self, version, data): # noqa: U100 |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | """ |
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | Public method to parse persisted data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
72 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
73 | @param version version of the data (unused) |
8289
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
74 | @type str |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
75 | @param data persisted data to be parsed (unused) |
8289
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
76 | @type str |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
77 | @return flag indicating success |
871b40c5a77a
Changed some source docu string to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
78 | @rtype bool |
2031
c36c2eb62a75
Refactored the UML graphics code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | """ |
2034
8de0fc1f7fef
Implemented functions to load UML graphics from disc.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2033
diff
changeset
|
80 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
8291 | 82 | def toDict(self): |
83 | """ | |
84 | Public method to collect data to be persisted. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | |
8291 | 86 | @return dictionary containing data to be persisted |
87 | @rtype dict | |
88 | """ | |
89 | return {} | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
91 | def fromDict(self, version, data): # noqa: U100 |
8295 | 92 | """ |
93 | Public method to populate the class with data persisted by 'toDict()'. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
94 | |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
95 | @param version version of the data (unused) |
8295 | 96 | @type str |
10683
779cda568acb
Changed the source code and the source code documentation to improve the indication of unused method/function arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
97 | @param data dictionary containing the persisted data (unused) |
8295 | 98 | @type dict |
99 | @return tuple containing a flag indicating success and an info | |
100 | message in case the diagram belongs to a different project | |
101 | @rtype tuple of (bool, str) | |
102 | """ | |
103 | return True, "" |