
    Vh                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZmZ d dlmZ  G d d	e
      Zd
 Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: pipx_info
short_description: Rretrieves information about applications installed with pipx
version_added: 5.6.0
description:
  - Retrieve details about Python applications installed in isolated virtualenvs using pipx.
extends_documentation_fragment:
  - community.general.attributes
  - community.general.attributes.info_module
  - community.general.pipx
options:
  name:
    description:
      - Name of an application installed with C(pipx).
    type: str
  include_deps:
    description:
      - Include dependent packages in the output.
    type: bool
    default: false
  include_injected:
    description:
      - Include injected packages in the output.
    type: bool
    default: false
  include_raw:
    description:
      - Returns the raw output of C(pipx list --json).
      - The raw output is not affected by O(include_deps) or O(include_injected).
    type: bool
    default: false
  global:
    version_added: 9.3.0
author:
  - "Alexei Znamensky (@russoz)"
a  
- name: retrieve all installed applications
  community.general.pipx_info: {}

- name: retrieve all installed applications, include dependencies and injected packages
  community.general.pipx_info:
    include_deps: true
    include_injected: true

- name: retrieve application tox
  community.general.pipx_info:
    name: tox
    include_deps: true

- name: retrieve application ansible-lint, include dependencies
  community.general.pipx_info:
    name: ansible-lint
    include_deps: true
a  
application:
  description: The list of installed applications.
  returned: success
  type: list
  elements: dict
  contains:
    name:
      description: The name of the installed application.
      returned: success
      type: str
      sample: "tox"
    version:
      description: The version of the installed application.
      returned: success
      type: str
      sample: "3.24.0"
    dependencies:
      description: The dependencies of the installed application, when O(include_deps=true).
      returned: success
      type: list
      elements: str
      sample: ["virtualenv"]
    injected:
      description: The injected packages for the installed application, when O(include_injected=true).
      returned: success
      type: dict
      sample:
        licenses: "0.6.1"
    pinned:
      description:
        - Whether the installed application is pinned or not.
        - When using C(pipx<=1.6.0), this returns C(null).
      returned: success
      type: bool
      sample:
        pinned: true
      version_added: 10.0.0

raw_output:
  description: The raw output of the C(pipx list) command, when O(include_raw=true). Used for debugging.
  returned: success
  type: dict

cmd:
  description: Command executed to obtain the list of installed applications.
  returned: success
  type: list
  elements: str
  sample: ["/usr/bin/python3.10", "-m", "pipx", "list", "--include-injected", "--json"]

version:
  description: Version of pipx.
  type: str
  returned: always
  sample: "1.7.1"
  version_added: 10.1.0
)ModuleHelper)pipx_runnerpipx_common_argspecmake_process_dict)ansible_factsc            	           e Zd ZdgZ e ed       edd       edd       edd            Zej                  e        eed	      ZdZ	d
 Z
d Zd Zy)PipXInfonamestr)typeboolF)r   default)r   include_depsinclude_injectedinclude_rawT)argument_specsupports_check_modec                    | j                   j                  r| j                   j                  g| _        n(t        | j                  dg      }|d   d   ddg| _        t        | j                  | j                        | _        | j                  d      5 }|j                         \  }}}|j                         | j                   _	        d d d        y # 1 sw Y   y xY w)Npython)gather_subset
executablez-mpipxversion)
varsr   commandr
   moduler   runnerrunstripr   )selffactsctxrcouterrs         o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/pipx_info.py__init_module__zPipXInfo.__init_module__   s    99 II001DL!$++hZHE!(OL94HDL!$++t||<[[# 	,s779LBS #		DII	, 	, 	,s   4CCc                 r   t        | j                  j                  | j                  j                        }| j	                  d|      5 }|j                         \  }}| j                  j                  r|| j                  _        | j                  j                  rL|j                         D cg c]   \  }}|| j                  j                  k(  r|" c}}| j                  _
        n(t        |j                               | j                  _
        | j                  |       d d d        y c c}}w # 1 sw Y   y xY w)Nz_list global)output_process)r	   r   r   r   r    r!   r   
raw_outputr   itemsapplicationlistvalues_capture_results)r#   r,   r%   applicationsraw_datakvs          r)   __run__zPipXInfo.__run__   s    *499+E+EtyyG]G]^[[[G 	'3%(WWY"L(yy$$'/		$yy~~ !- 2 2 4)1DIINN* )		% )-\-@-@-B(C		%!!#&	' 	')	' 	's    A$D-,%D'AD-'D--D6c                     |j                   | j                  _         | j                  dk\  r|j                  | j                  _        y y )N   )cmdr   	verbosityrun_info)r#   r%   s     r)   r2   zPipXInfo._capture_results   s2    		>>Q!$DII     N)__name__
__module____qualname__output_paramsdictr   updater   r   use_old_vardictr*   r7   r2    r=   r)   r   r      sp    HMuvu5659fe4	M ,-# F O	,'".r=   r   c                  ,    t         j                          y )N)r   executerE   r=   r)   mainrH      s    r=   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNHansible_collections.community.general.plugins.module_utils.module_helperr   ?ansible_collections.community.general.plugins.module_utils.pipxr   r   r	   !ansible.module_utils.facts.compatr
   r   rH   r>   rE   r=   r)   <module>rR      s_    A @#J(9
v b   ;..| ..b zF r=   