o ?Og@svdZddlZddlZddejDZgdZdZdZdd Zd d Z d d Z dddZ GdddZ GdddZ dS)aAUtilities to compile possibly incomplete Python source code. This module provides two interfaces, broadly similar to the builtin function compile(), which take program text, a filename and a 'mode' and: - Return code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). The two interfaces are: compile_command(source, filename, symbol): Compiles a single command in the manner described above. CommandCompiler(): Instances of this class have __call__ methods identical in signature to compile_command; the difference is that if the instance compiles program text containing a __future__ statement, the instance 'remembers' and compiles all subsequent program texts with the statement in force. The module also provides another class: Compile(): Instances of this class act like the built-in function compile, but with 'memory' in the sense described above. NcCsg|]}tt|qS)getattr __future__).0Zfnamerr-/opt/alt/python310/lib64/python3.10/codeop.py &sr)compile_commandCompileCommandCompilerii@cCs|dD]}|}|r|ddkrnq|dkrd}t[tdttfz||||WnBtysz||d||WYWddStyp}zdt|vrfWYd}~YWddSWYd}~nd}~wwYnwWdn1s~wY||||S)N r#evalpassignorezincomplete input) splitstripwarningscatch_warnings simplefilter SyntaxWarningDeprecationWarning SyntaxErrorstr)compilersourcefilenamesymbollineerrr_maybe_compile1s8      rcCs4t|}t|}d|vrd|vrdS||krdSdS)Nzwas never closedFT)repr)Zerr1Zerr2Zrep1Zrep2rrr_is_syntax_errorLsr!cCst|||ttBSN)compilePyCF_DONT_IMPLY_DEDENTPyCF_ALLOW_INCOMPLETE_INPUTrrrrrr_compileUsr'singlecCstt|||S)aCompile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "" symbol -- optional grammar start symbol; "single" (default), "exec" or "eval" Return value / exceptions raised: - Return a code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). )rr'r&rrrrXsrc@s eZdZdZddZddZdS)r zInstances of this class behave much like the built-in compile function, but if one is used to compile text containing a future statement, it "remembers" and compiles all subsequent program texts with the statement in force.cCsttB|_dSr")r$r%flagsselfrrr__init__rszCompile.__init__cCs<t||||jd}tD]}|j|j@r|j|jO_q |S)NT)r#r* _featuresco_flagsZ compiler_flag)r,rrrZcodeobZfeaturerrr__call__us  zCompile.__call__N__name__ __module__ __qualname____doc__r-r0rrrrr ms r c@s"eZdZdZddZd ddZdS) r a(Instances of this class have __call__ methods identical in signature to compile_command; the difference is that if the instance compiles program text containing a __future__ statement, the instance 'remembers' and compiles all subsequent program texts with the statement in force.cCs t|_dSr")r rr+rrrr-s zCommandCompiler.__init__r(r)cCst|j|||S)aCompile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "" symbol -- optional grammar start symbol; "single" (default) or "eval" Return value / exceptions raised: - Return a code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError, ValueError or OverflowError if the command is a syntax error (OverflowError and ValueError can be produced by malformed literals). )rr)r,rrrrrrr0szCommandCompiler.__call__Nr(r)r1rrrrr |sr r6)r5rrZall_feature_namesr.__all__r$r%rr!r'rr r rrrrs"