o e}_P@sRdZddlZddlZddlmZddlZddlmZddZddZ d d d Z dS) aeModule 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 Csgd}tjdddd}|d|jddd d d d |jd dtjd|d}|jdddd|dddd|Dd|jdddd|dddd|Dd|jdd d!d"d#d$gd%d|jd&d'd(d)d*d+|jd,d-d.d(d)d/d+|jd0d1d2td3d4|jd5d6d(d)d7d+|jd8d9d(d)d:d+|jd;d|jd?d@d(d)dAd>|jdBdCdDtdEd4|jdFdGd)t dHd4|jdIdJdKdLdM|S)NN)upperlower capitalize sqlformatzEFormat FILE according to OPTIONS. Use "-" as FILE to read from stdin.z%(prog)s [OPTIONS] FILE, ...)prog descriptionusagefilenamez-oz --outfileoutfileFILEz)write output to FILE (defaults to stdout))destmetavarhelpz --versionversion)actionrzFormatting Optionsz-kz --keywordsCHOICE keyword_casez,change case of keywords, CHOICE is one of {}z, cs|]}d|VqdSz"{}"Nformat.0xr./usr/lib/python3/dist-packages/sqlparse/cli.py ?z create_parser..)rrchoicesrz-iz --identifiersidentifier_casez/change case of identifiers, CHOICE is one of {}csrrrrrrrrGrz-lz --languageLANG output_formatpythonphpzJoutput a snippet in programming language LANG, choices are "python", "php"z--strip-commentsstrip_comments store_trueFzremove comments)rrdefaultrz-rz --reindentreindentzreindent statementsz--indent_width indent_widthz(indentation width (defaults to 2 spaces))rr(typerz--indent_after_firstindent_after_firstz2indent after first line of statement (e.g. SELECT)z--indent_columnsindent_columnszcCstjd|dS)z5Print msg and optionally exit with return code exit_.z [ERROR] {} )sysstderrwriter)msgrrr_errorsrDc Cst}||}|jdkr&ttjj|jd}z |}W| nB| wz!t |j|jd}d | }Wdn1sAwYWnt yb}ztd|j|WYd}~Sd}~wwd}|jrz t |jd|jd}d}Wnt y}ztd|j|WYd}~Sd}~wwtj}t|}ztj|}Wnty}z td |WYd}~Sd}~wwtj|fi|} || ||r|d S) N-)r1zFailed to read {}: {}FwTzFailed to open {}: {}zInvalid options: {}r)r> parse_argsr rr@stdinbufferr1readdetachopenr8 readlinesOSErrorrDrr stdoutvarsr5 formattervalidate_optionsrrBflushclose) argsr<wrapperdatafe close_streamstreamformatter_optssrrrmainsR     r_)N) __doc__r2r@iorr5sqlparse.exceptionsrr>rDr_rrrrs   w