(self, context)
| 175 | pass |
| 176 | |
| 177 | def inline_decode(self, context): |
| 178 | node = context.node |
| 179 | if not type(node) == Call: |
| 180 | return |
| 181 | elif not ( |
| 182 | type(node.func) == Attribute |
| 183 | and type(node.func.source) in (String, Bytes) |
| 184 | and node.func.attr == "decode" |
| 185 | ): |
| 186 | return |
| 187 | |
| 188 | elif not all(type(x) in (String, str) for x in node.args): |
| 189 | return |
| 190 | |
| 191 | if len(node.args) > 0: |
| 192 | try: |
| 193 | _ = codecs.getdecoder(str(node.args[0])) |
| 194 | except LookupError: |
| 195 | return |
| 196 | |
| 197 | args = list(map(str, node.args)) |
| 198 | |
| 199 | decoded = codecs.decode(bytes(node.func.source), *args) |
| 200 | if type(decoded) == str: |
| 201 | new_node = String(decoded) |
| 202 | else: |
| 203 | new_node = Bytes(decoded) |
| 204 | |
| 205 | new_node.enrich_from_previous(node) |
| 206 | context.replace(new_node) |
| 207 | |
| 208 | def rewrite_function_call(self, context): |
| 209 | if not isinstance(context.node, Call): |
nothing calls this directly
no test coverage detected