decompile Python byte-code file (.pyc). Return objects to all of the deparsed objects found in `filename`.
(
filename: str,
outstream: Optional[TextIO] = None,
showasm: Optional[str] = None,
showast={},
showgrammar=False,
source_encoding=None,
mapstream=None,
do_fragments=False,
start_offset=0,
stop_offset=-1,
)
| 198 | |
| 199 | |
| 200 | def decompile_file( |
| 201 | filename: str, |
| 202 | outstream: Optional[TextIO] = None, |
| 203 | showasm: Optional[str] = None, |
| 204 | showast={}, |
| 205 | showgrammar=False, |
| 206 | source_encoding=None, |
| 207 | mapstream=None, |
| 208 | do_fragments=False, |
| 209 | start_offset=0, |
| 210 | stop_offset=-1, |
| 211 | ) -> Any: |
| 212 | """ |
| 213 | decompile Python byte-code file (.pyc). Return objects to |
| 214 | all of the deparsed objects found in `filename`. |
| 215 | """ |
| 216 | |
| 217 | filename = check_object_path(filename) |
| 218 | code_objects = {} |
| 219 | version, timestamp, magic_int, co, is_pypy, source_size, _ = load_module( |
| 220 | filename, code_objects |
| 221 | ) |
| 222 | |
| 223 | if isinstance(co, list): |
| 224 | deparsed = [] |
| 225 | for bytecode in co: |
| 226 | deparsed.append( |
| 227 | decompile( |
| 228 | bytecode, |
| 229 | version, |
| 230 | outstream, |
| 231 | showasm, |
| 232 | showast, |
| 233 | timestamp, |
| 234 | showgrammar, |
| 235 | source_encoding, |
| 236 | code_objects=code_objects, |
| 237 | is_pypy=is_pypy, |
| 238 | magic_int=magic_int, |
| 239 | mapstream=mapstream, |
| 240 | start_offset=start_offset, |
| 241 | stop_offset=stop_offset, |
| 242 | ), |
| 243 | ) |
| 244 | else: |
| 245 | deparsed = [ |
| 246 | decompile( |
| 247 | co, |
| 248 | version, |
| 249 | outstream, |
| 250 | showasm, |
| 251 | showast, |
| 252 | timestamp, |
| 253 | showgrammar, |
| 254 | source_encoding, |
| 255 | code_objects=code_objects, |
| 256 | source_size=source_size, |
| 257 | is_pypy=is_pypy, |