ó
    ¨Rj  ã                   óT   • S r SSKrSSKrSSKJr  SSKrSSKJr  S rS r	S r
S	S jrg)
ae  Module that contains the command line app.

Why does this file exist, and why not put this in __main__?
  You might be tempted to import things from __main__ later, but that will
  cause problems: the code will get executed twice:
  - When you run `python -m sqlparse` python will execute
    ``__main__.py`` as a script. That means there won't be any
    ``sqlparse.__main__`` in ``sys.modules``.
  - When you import __main__ it will get executed again (as a module) because
    there's no ``sqlparse.__main__`` in ``sys.modules``.
  Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration
é    N)ÚTextIOWrapper)ÚSQLParseErrorc                  óÚ  • / SQn [         R                  " SSSS9nUR                  SSSS	9  UR                  S
SSSSS9  UR                  SSSSSS9  UR                  SS[        R                  S9  UR                  S5      nUR                  SSSSU SR                  SR                  S  U  5       5      5      S!9  UR                  S"S#SS$U S%R                  SR                  S& U  5       5      5      S!9  UR                  S'S(S)S*S+S,/S-S!9  UR                  S.S/SSS0S9  UR                  S1S2S3SSS4S9  UR                  S5S6S7[        S8S99  UR                  S:S;SSS<S9  UR                  S=S>SSS?S9  UR                  S@SASSSBSC9  UR                  SDSESSSFSC9  UR                  SGSHSI[        SJS99  UR                  SKSLS[        SMS99  UR                  SNSOS[        SPS99  UR                  SQSRSSSTSU9  U$ )VN)ÚupperÚlowerÚ
capitalizeÚ	sqlformatzEFormat FILE according to OPTIONS. Use "-" as FILE to read from stdin.z"%(prog)s [OPTIONS] FILE [FILE ...])ÚprogÚdescriptionÚusageÚfilenameÚ+z%file(s) to format (use "-" for stdin))ÚnargsÚhelpz-oz	--outfileÚoutfileÚFILEz)write output to FILE (defaults to stdout))ÚdestÚmetavarr   z
--in-placeÚinplaceÚ
store_trueFz0format files in-place (overwrite existing files))r   ÚactionÚdefaultr   z	--versionÚversion)r   r   zFormatting Optionsz-kz
--keywordsÚCHOICEÚkeyword_casez,change case of keywords, CHOICE is one of {}z, c              3   ó.   #   • U  H  nS U S 3v •  M     g7f©Ú"N© ©Ú.0Úxs     Ú8D:\diplom_project\venv\Lib\site-packages\sqlparse/cli.pyÚ	<genexpr>Ú create_parser.<locals>.<genexpr>G   ó   é € Ð6ª 1˜˜!˜˜A•hªùó   ‚)r   r   Úchoicesr   z-iz--identifiersÚidentifier_casez/change case of identifiers, CHOICE is one of {}c              3   ó.   #   • U  H  nS U S 3v •  M     g7fr   r   r    s     r#   r$   r%   O   r&   r'   z-lz
--languageÚLANGÚoutput_formatÚpythonÚphpzJoutput a snippet in programming language LANG, choices are "python", "php"z--strip-commentsÚstrip_commentszremove commentsz-rz
--reindentÚreindentzreindent statementsz--indent_widthÚindent_widthé   z(indentation width (defaults to 2 spaces))r   r   Útyper   z--indent_after_firstÚindent_after_firstz2indent after first line of statement (e.g. SELECT)z--indent_columnsÚindent_columnsz<indent all columns by indent_width instead of keyword lengthz-az--reindent_alignedz%reindent statements to aligned format)r   r   r   z-sz--use_space_around_operatorsz*place spaces around mathematical operatorsz--wrap_afterÚ
wrap_afterr   z*Column after which lists should be wrappedz--comma_firstÚcomma_firstz-Insert linebreak before comma (default False)z	--compactÚcompactz2Try to produce more compact output (default False)z
--encodingÚencodingzutf-8z*Specify the input encoding (default utf-8))r   r   r   )
ÚargparseÚArgumentParserÚadd_argumentÚsqlparseÚ__version__Úadd_argument_groupÚformatÚjoinÚintÚbool)Ú_CASE_CHOICESÚparserÚgroups      r#   Úcreate_parserrG      s  € Ú4€Mä×$Ò$Øð*à2ñ	€Fð ×ÑØØØ4ð ñ 6ð
 ×ÑØˆkØØØ8ð	 ñ :ð ×ÑØØØØØ?ð ñ Að ×ÑØØÜ×$Ñ$ð ñ &ð
 ×%Ñ%Ð&:Ó;€Eà	×ÑØˆlØØØØ;×BÑBØ�I‰IÑ6©Ó6Ó6ó8ð ñ 9ð 
×ÑØˆoØØØØ>×EÑEØ�I‰IÑ6©Ó6Ó6ó8ð ñ 9ð 
×ÑØˆlØØØ˜5Ð!ð+ð ñ ,ð 
×ÑØØØØØð ñ  ð 
×ÑØˆlØØØØ"ð ñ $ð 
×ÑØØØÜØ7ð ñ 9ð 
×ÑØØ!ØØØAð ñ Cð 
×ÑØØØØØKð ñ Mð 
×ÑØÐ"ØØØ4ð	 ñ 6ð 
×ÑØÐ,ØØØ9ð	 ñ ;ð 
×ÑØØØÜØ9ð ñ ;ð 
×ÑØØØÜØ<ð ñ >ð 
×ÑØØØÜØAð ñ Cð 
×ÑØØØØ9ð	 ñ ;ð €Mó    c                 óJ   • [         R                  R                  SU  S35        g)z5Print msg and optionally exit with return code exit_.z[ERROR] Ú
é   )ÚsysÚstderrÚwrite)Úmsgs    r#   Ú_errorrP   ¦   s    € ä‡J�J×Ñ�x ˜u BÐ'Ô(ØrH   c                 óØ  • U S:X  a  UR                   (       a  [        S5      $ U S:X  aN  [        [        R                  R
                  UR                  S9n UR                  5       nUR                  5         O< [        XR                  S9 nSR                  UR                  5       5      nSSS5        SnUR                   (       a   [        U S	UR                  S9nS
nODUR                  (       a#   [        UR                  S	UR                  S9nS
nO[        R                  n[        U5      n [         R"                  R%                  U5      n[         R(                  " W40 UD6n	UR+                  U	5        UR-                  5         U(       a  UR/                  5         g! UR                  5         f = f! , (       d  f       GN= f! [         a  n[        SU  SU 35      s SnA$ SnAff = f! [         a  n[        SU  SU 35      s SnA$ SnAff = f! [         a%  n[        SUR                   SU 35      s SnA$ SnAff = f! [&         a  n[        SU 35      s SnA$ SnAff = f)z\Process a single file with the given formatting options.

Returns 0 on success, 1 on error.
Ú-z Cannot use --in-place with stdin)r9   Ú NzFailed to read z: FÚwTzFailed to open zInvalid options: r   )r   rP   r   rL   ÚstdinÚbufferr9   ÚreadÚdetachÚopenrA   Ú	readlinesÚOSErrorr   ÚstdoutÚvarsr=   Ú	formatterÚvalidate_optionsr   r@   rN   ÚflushÚclose)
r   ÚargsÚwrapperÚdataÚfÚeÚclose_streamÚstreamÚformatter_optsÚss
             r#   Ú_process_filerk   ¬   sþ  € ð �3ƒ˜4Ÿ<Ÿ<ÜÐ8Ó9Ð9ð �3ƒÜ¤§	¡	× 0Ñ 0¸4¿=¹=ÑIˆð	Ø—<‘<“>ˆDà�N‰NÕð	=Ü�h¯©Ò7¸1Ø—w‘w˜qŸ{™{›}Ó-�÷ 8ð €LØ‡|‡|ð	=Ü˜( C°$·-±-Ñ@ˆFØ‰Lð 
��ð	AÜ˜$Ÿ,™,¨°d·m±mÑDˆFØ‰Lô —‘ˆô ˜$“Z€Nð/Ü!×+Ñ+×<Ñ<¸^ÓLˆô 	�Š˜Ñ/ Ñ/€AØ
‡L�L�„OØ
‡L�L„NÞØ�‰ŒØøðK �N‰NÕú÷ 8Ö7ûäó 	=Ü˜O¨H¨:°R¸°sÐ;Ó<Õ<ûð	=ûô ó 	=Ü˜O¨H¨:°R¸°sÐ;Ó<Õ<ûð	=ûô ó 	AÜ˜O¨D¯L©L¨>¸¸A¸3Ð?Ó@Õ@ûð	Aûô ó /ÜÐ)¨!¨Ð-Ó.Õ.ûð/ús¢   ÁF Á8G Â F3Â+G ÃG- Ã1!H Ä/I ÆF0Æ3
GÆ=G ÇG Ç
G*ÇG%ÇG*Ç%G*Ç-
HÇ7HÈHÈHÈ
IÈH?È9IÈ?IÉ
I)ÉI$ÉI)É$I)c                 ó2  • [        5       nUR                  U 5      n [        U R                  5      S:”  a8  U R                  (       a  [        S5      $ U R                  (       d  [        S5      $ SnU R                   H  n[        X05      nUS:w  d  M  UnM     U$ )NrK   z+Cannot use -o/--outfile with multiple filesz&Multiple files require --in-place flagr   )rG   Ú
parse_argsÚlenr   r   rP   r   rk   )rb   rE   Ú	exit_coder   Úresults        r#   Úmainrq   ã   s…   € Ü‹_€FØ×Ñ˜TÓ"€Dô ˆ4�=‰=Ó˜AÓØ�<�<ÜÐGÓHÐHØ�|�|ÜÐBÓCÐCð €IØ—M”MˆÜ˜xÓ.ˆØ�Q�;ØŠIñ "ð ÐrH   )N)Ú__doc__r:   rL   Úior   r=   Úsqlparse.exceptionsr   rG   rP   rk   rq   r   rH   r#   Ú<module>ru      s2   ðñó Û 
Ý ã Ý -ò
EòPò4õnrH   