| Conditions | 5 |
| Total Lines | 151 |
| Code Lines | 100 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # Create an html output of the verificationMatrix |
||
| 52 | def _publish_lines(tmp_obj): |
||
| 53 | ''' |
||
| 54 | Yield lines for an html verification Matrix |
||
| 55 | |||
| 56 | param tmp_object: tree like object to publish |
||
| 57 | |||
| 58 | ''' |
||
| 59 | |||
| 60 | # Create html-files |
||
| 61 | |||
| 62 | yield '<!DOCTYPE html>' |
||
| 63 | yield '<html lang="en">' |
||
| 64 | yield '<head>' |
||
| 65 | yield '<title>verification matrix</title>' |
||
| 66 | |||
| 67 | yield '<style type="text/css">' |
||
| 68 | yield from _lines_valMatrix_css() |
||
| 69 | yield '</style>' |
||
| 70 | yield '</head>' |
||
| 71 | |||
| 72 | yield '<body>' |
||
| 73 | yield '<div class="background-color"></div>' |
||
| 74 | yield '<div class="Center-align">' |
||
| 75 | yield '<h1 >Verification Matrix</h1>' |
||
| 76 | yield '</div>' |
||
| 77 | |||
| 78 | # Print button |
||
| 79 | yield '<button onclick="Print()">Print</button>' |
||
| 80 | yield '<div class = "float-right"><strong>Hit "ctrl+s" to save changes!</strong></div>' |
||
| 81 | |||
| 82 | yield '<table width=50% >' |
||
| 83 | yield '<tbody>' |
||
| 84 | |||
| 85 | yield '<tr>' |
||
| 86 | yield '<td>Project</td>' |
||
| 87 | # Project |
||
| 88 | yield '<td contenteditable="true">' |
||
| 89 | yield '' |
||
| 90 | yield '</td>' |
||
| 91 | yield '</tr>' |
||
| 92 | |||
| 93 | yield '<tr>' |
||
| 94 | yield '<td>Verification Matrix for</td>' |
||
| 95 | # Name for document of verification |
||
| 96 | yield '<td>' |
||
| 97 | yield tmp_obj.prefix |
||
| 98 | yield '</td>' |
||
| 99 | yield '</tr>' |
||
| 100 | |||
| 101 | yield '<tr>' |
||
| 102 | yield '<td>Date</td>' |
||
| 103 | # Date of creation |
||
| 104 | yield '<td>' |
||
| 105 | yield datetime.today().strftime('%d/%m/%Y') |
||
| 106 | yield '</td>' |
||
| 107 | yield '</tr>' |
||
| 108 | |||
| 109 | yield '<tr>' |
||
| 110 | yield '<td>Owner</td>' |
||
| 111 | # Owner |
||
| 112 | yield '<td contenteditable="true">' |
||
| 113 | yield '' |
||
| 114 | yield '</td>' |
||
| 115 | yield '</tr>' |
||
| 116 | |||
| 117 | yield '<tr>' |
||
| 118 | yield '<td>Issue</td>' |
||
| 119 | # Issue |
||
| 120 | yield '<td contenteditable="true">' |
||
| 121 | yield '' |
||
| 122 | yield '</td>' |
||
| 123 | yield '</tr>' |
||
| 124 | |||
| 125 | yield '</tbody>' |
||
| 126 | yield '</table>' |
||
| 127 | |||
| 128 | |||
| 129 | |||
| 130 | yield '<table width=100% >' |
||
| 131 | yield '<tbody>' |
||
| 132 | yield '<tr>' |
||
| 133 | yield '<th colspan="2" width=20%>Requirements</th>' |
||
| 134 | yield '<th colspan="4" width=40%>Traceabillity</th>' |
||
| 135 | yield '<th colspan="4" width=40%>Verification</th>' |
||
| 136 | yield '</tr>' |
||
| 137 | |||
| 138 | yield '<tr>' |
||
| 139 | yield '<th colspan="2" width=20%>Req. ID</th>' |
||
| 140 | yield '<th colspan="2" width=20%>Parent req. ID</th>' |
||
| 141 | yield '<th colspan="2" width=20%>Rationale</th>' |
||
| 142 | yield '<th colspan="1" width=10%>Verification Method</th>' |
||
| 143 | yield '<th colspan="2" width=20%>Verification evidence Method</th>' |
||
| 144 | yield '<th colspan="1" width=10%>Conclusion</th>' |
||
| 145 | yield '</tr>' |
||
| 146 | |||
| 147 | |||
| 148 | for item in tmp_obj: |
||
| 149 | #Chek ob es sich bei dem Item auch um ein Requirment handelt ... |
||
| 150 | if item.Is_Req: |
||
| 151 | yield '<tr>' |
||
| 152 | |||
| 153 | # write values in Req.ID |
||
| 154 | yield '<td colspan="2" width=20% contenteditable="false">' |
||
| 155 | yield str(item.uid) |
||
| 156 | yield '</td>' |
||
| 157 | |||
| 158 | #write value for parent req. ID |
||
| 159 | yield '<td colspan="2" width=20% contenteditable="false">' |
||
| 160 | if not len(item.links) == 0: |
||
| 161 | for link in item.links: |
||
| 162 | yield str(link) + '<br>' |
||
| 163 | else: |
||
| 164 | yield '' |
||
| 165 | yield '</td>' |
||
| 166 | |||
| 167 | # write rationale |
||
| 168 | yield '<td colspan="2" width=20% contenteditable="false">' |
||
| 169 | yield str(item.Verification_Rationale) |
||
| 170 | yield '</td>' |
||
| 171 | |||
| 172 | #write value for Verification Method |
||
| 173 | yield '<td colspan="1" width=10% contenteditable="true">' |
||
| 174 | yield '<div class="Center-align">' |
||
| 175 | yield str(item.Verification_Mean) |
||
| 176 | yield '</div>' |
||
| 177 | yield '</td>' |
||
| 178 | |||
| 179 | |||
| 180 | #write Verification evidence reference |
||
| 181 | yield '<td colspan="2" width=20% contenteditable="true">' |
||
| 182 | yield '' # muss auch noch genauer spezifiziert werden |
||
| 183 | yield '</td>' |
||
| 184 | |||
| 185 | #write status/conclusion of requirement |
||
| 186 | yield '<td colspan="1" width=20% contenteditable="true">' |
||
| 187 | yield '<div class="Center-align">' |
||
| 188 | yield str(item.Verification_Status) |
||
| 189 | yield '</div>' |
||
| 190 | yield '</td>' |
||
| 191 | |||
| 192 | yield '</tr>' |
||
| 193 | |||
| 194 | yield '</tbody>' |
||
| 195 | yield '</tabele>' |
||
| 196 | |||
| 197 | # Function for the Print Button |
||
| 198 | yield '<script>function Print() {window.print();}</script>' |
||
| 199 | yield '<script>function Safe() {window.safe();}</script>' |
||
| 200 | |||
| 201 | yield '</body>' |
||
| 202 | yield '</html>' |
||
| 203 | |||
| 210 |