
    Vi                         S r SSKJr  SSKrSSKrSSKrSSKrSSKJrJ	r	J
r
JrJrJrJr  SSKJr  SSKrSSKJrJrJr  \R*                  S   S:H  rS rS	 rS
 rS rS r\
" SS/S9S 5       rS rS rSS jrg)a  like jq, but with the full power of python in the spec.

Usage: python -m glom [FLAGS] [spec [target]]

Command-line interface to the glom library, providing nested data
access and data restructuring with the power of Python.


Flags:

  --help / -h                 show this help message and exit
  --target-file TARGET_FILE   path to target data source (optional)
  --target-format TARGET_FORMAT
                              format of the source data (json or python)
                              (defaults to 'json')
  --spec-file SPEC_FILE       path to glom spec definition (optional)
  --spec-format SPEC_FORMAT   format of the glom spec definition (json, python,
                              python-full) (defaults to 'python')
  --indent INDENT             number of spaces to indent the result, 0 to disable
                              pretty-printing (defaults to 2)
  --debug                     interactively debug any errors that come up
  --inspect                   interactively explore the data

try out:
`
curl -s https://api.github.com/repos/mahmoud/glom/events | python -m glom '[{"type": "type", "date": "created_at", "user": "actor.login"}]'

    )print_functionN)CommandFlagface_middleware
PosArgSpecPosArgDisplayCommandLineError
UsageError)isatty)Path	GlomErrorInspect   c                    U(       d  U(       a>  [         R                  R                  (       + n[        UUUU=(       a    UU=(       a    US9n [        R                  " X5      nU(       d  Sn[        [        R                  " XbSS95        g! [
         a0  n[        UR                  R                  < SU< 35         SnAgSnAff = f)zzCommand-line interface to the glom library, providing nested data
access and data restructuring with the power of Python.
)echo	recursive
breakpointpost_mortem: N   T)indent	sort_keys)sysstdinclosedr   glomr   print	__class____name__jsondumps)targetspecr   debuginspect
stdin_openresultges           [/home/james-whalen/.local/share/pipx/venvs/semgrep/lib/python3.13/site-packages/glom/cli.pyglom_clir*   4   s     )))
t#!(")"8j#(#7Z	96(
 	$**Vd
;<
  ",,//45s   B 
C&CCc                  p   [        [        SSS0S9n [        [        U [        /S9nUR                  S[        S SS9  UR                  S	[        S
SS9  UR                  S[        S SS9  UR                  S[        SSS9  UR                  S[        SSS9  UR                  SSSS9  UR                  SSSS9  U$ )N   labelz[spec [target]])	max_countdisplay)posargsmiddlewaresz--target-filezpath to target data source)missingdocz--target-formatr    z*format of the source data (json or python)z--spec-filezpath to glom spec definitionz--spec-formatpythonz>format of the glom spec definition (json, python, python-full)z--indentzCnumber of spaces to indent the result, 0 to disable pretty-printingz--debugTz+interactively debug any errors that come up)parse_asr3   z	--inspectzinteractively explore the data)r   strr   r*   mw_get_targetaddint)r0   cmds     r)   get_commandr;   L   s    G=N3OPG
(G-
ICGGOS$4PGQGGsF<  >GGM32PGQGGOS(P  R GGJQU  W GGI*WGXGGK$,LGMJ    c                 J    [        5       nUR                  U 5      =(       d    S$ )Nr   )r;   run)argvr:   s     r)   mainr@   ^   s    
-C774=Ar<   c                  0   [         R                  " S5      n U (       a  [        [        R                  5         [        R
                  " [        [        R                  5      =(       d    S5        g ! [         a    U (       a  SS KoR                  5         e f = f)NGLOM_CLI_DEBUGr   )
osgetenvr   r   r?   exitr@   	Exceptionpdbr   )_enable_debugrG   s     r)   console_mainrI   c   s\    II./Mchhchh$1% (s   6A/ /&Bc                 t   U (       d  0 $ 0 nUS:X  a  [         R                  nO:US;   a   SSKnUR                  nO"US:X  a  [        R                  nO[        S5      e U" U 5      nU$ ! [         a    [        S5      ef = f! [         a,  n[        SUR                  R                  < S	U< 35      eSnAff = f)
a]  Handles reading in a file specified in cli command.

Args:
    target_text (str): String that specifies where 6
    target_format (str): Valid formats include `.json` and `.yml` or `.yaml`
Returns:
    The content of the file that you specified
Raises:
    CommandLineError: Issue with file format or appropriate file reading package not installed.
r    )yamlymlr   NzENo YAML package found. To process yaml files, run: pip install PyYAMLr4   z9expected target-format to be one of python, json, or yamlz!could not load target data, got: r   )r    loadsrK   loadImportErrorr
   astliteral_evalrF   r   r   )target_texttarget_formatr"   	load_funcrK   es         r)   mw_handle_targetrV   o   s     	FJJ		/	)	f		I 
(	"$$	TUU6;' M  	fdee	f  6KK00!5 6 	66s#   A( B (A>
B7'B22B7r#   r"   )providesc                    Su  pg[        U5      S:X  a  Uu  pgO[        U5      S:X  a  US   S pvU(       a  U(       a  [        S5      eU(       a&   [        US5       nUR                  5       nS S S 5        U(       d  [        5       n
OkUS	:X  a+  US   S
;  a  [        U5      n[        R                  " U5      n
O:US:X  a  [        R                  " U5      n
OUS:X  a  [        U5      n
O[        S5      eU(       a  U(       a  [        S5      eUS:X  d  US:X  a  [        R                  R                  5       nOfU(       a   [        US5      R                  5       nOCU(       d<  [        [        R                  5      (       d  [        R                  R                  5       n[        Xs5      nU " XS9$ ! , (       d  f       GNG= f! [         a  n	[        SU< SU	< 35      eS n	A	ff = f! [         a  n	[        SU< SU	< 35      eS n	A	ff = f)N)NNr,   r   r   z-expected spec file or spec argument, not bothrzcould not read spec file z, got: r4   )"'[{(r    zpython-fullz>expected spec-format to be one of json, python, or python-fullz1expected target file or target argument, not both-zcould not read target file )r#   r"   )lenr
   openreadIOErrorr   reprrP   rQ   r    rM   _eval_python_full_specr   r   r   rV   )next_posargs_target_filerS   	spec_filespec_format	spec_textrR   foser#   r"   s               r)   r7   r7      s   'I
8}!)	;	X!	!)!d;YHII		Xi%FFH	 &
 v		 Q<88YI	*		zz)$		%%i0YZZ{LMM		{c1iinn&		\{C0557K 		!2!2iinn&k9Fd**C &% 	XyRUVWW	X0  	\VYZ[[	\sN   F> F,,F> =G# ,
F;6F> ;F> >
G GG #
H-H  Hc                     [        [        R                  5      n S H  nU R                  US 5        M     [	        U R                  5       5       H4  u  p[        U5      [        [        5      :X  d  M#  U R                  U5        M6     U $ )N)__builtins__r   __doc____package__)dictr   __dict__poplistitemstype)retkvs      r)   _from_glom_import_starr{      sb    
t}}
CC4 DSYY[!7d4j GGAJ " Jr<   c                 D    SnU< SU < 3n[        5       n[        X!US9nU$ )N__cli_glom_spec__z = )nameenv)r{   _compile_code)py_textr~   code_strr   r#   s        r)   re   re      s*    D '*H
 
"C#6DKr<   c                     [        U SS5      nU(       a  [        U 5        Uc  0 n[        (       a  [        XB5        X!   $ [        S5        X!   $ )Nz<glom-generated code>singlezexec code in env)compiler   PY3exec)r   r~   r   verbosecodes        r)   r   r      sN    84h?Dh
{
sT 9 	 9r<   )NF) rp   
__future__r   rC   rP   r   r    facer   r   r   r   r   r	   r
   
face.utilsr   r   r   r   r   version_infor   r*   r;   r@   rI   rV   r7   r{   re   r    r<   r)   <module>r      s   < & 	 
 
      ) )
a0$
	#L 68,-,+ .,+^r<   