MCPcopy
hub / github.com/rocky/python-uncompyle6 / __init__

Method __init__

uncompyle6/semantics/pysource.py:218–333  ·  view source on GitHub ↗

`version' is the Python version of the Python dialect of both the syntax tree and language we should produce. `out' is IO-like file pointer to where the output should go. It would have a getvalue() method. `scanner' is a method to call when we need to scan tokens. S

(
        self,
        version: tuple,
        out,
        scanner,
        showast=TREE_DEFAULT_DEBUG,
        debug_parser=PARSER_DEFAULT_DEBUG,
        compile_mode="exec",
        is_pypy=IS_PYPY,
        linestarts={},
        tolerate_errors=False,
    )

Source from the content-addressed store, hash-verified

216 stacked_params = ("f", "indent", "is_lambda", "_globals")
217
218 def __init__(
219 self,
220 version: tuple,
221 out,
222 scanner,
223 showast=TREE_DEFAULT_DEBUG,
224 debug_parser=PARSER_DEFAULT_DEBUG,
225 compile_mode="exec",
226 is_pypy=IS_PYPY,
227 linestarts={},
228 tolerate_errors=False,
229 ):
230 """`version' is the Python version of the Python dialect
231 of both the syntax tree and language we should produce.
232
233 `out' is IO-like file pointer to where the output should go. It
234 would have a getvalue() method.
235
236 `scanner' is a method to call when we need to scan tokens. Sometimes
237 in producing output we will run across further tokens that need
238 to be scanned.
239
240 If `showast' is True, we print the syntax tree.
241
242 `compile_mode` is is either `exec`, `single` or `lambda`.
243
244 For `lambda`, the grammar that can be used in lambda
245 expressions is used. Otherwise, it is the compile mode that
246 was used to create the Syntax Tree and specifies a grammar
247 variant within a Python version to use.
248
249 `is_pypy` should be True if the Syntax Tree was generated for PyPy.
250
251 `linestarts` is a dictionary of line number to bytecode offset. This
252 can sometimes assist in determining which kind of source-code construct
253 to use when there is ambiguity.
254
255 """
256 GenericASTTraversal.__init__(self, ast=None)
257
258 self.scanner = scanner
259 params = {"f": out, "indent": ""}
260 self.version = version
261 self.p = get_python_parser(
262 version,
263 debug_parser=dict(debug_parser),
264 compile_mode=compile_mode,
265 is_pypy=is_pypy,
266 )
267
268 self.ERROR = None
269 self.ast_errors = []
270 self.classes = []
271 self.compile_mode = compile_mode
272 self.currentclass = None
273 self.debug_parser = dict(debug_parser)
274 self.is_pypy = is_pypy
275 self.linemap = {}

Callers

nothing calls this directly

Calls 4

get_python_parserFunction · 0.90
TreeTransformClass · 0.90
customize_for_versionFunction · 0.90
copyMethod · 0.80

Tested by

no test coverage detected