
    Vh                     z    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  G d de
      Zd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona  
module: xdg_mime
author:
  - "Marcos Alano (@mhalano)"
short_description: Set default handler for MIME types, for applications using XDG tools
version_added: 10.7.0
description:
  - This module allows configuring the default handler for specific MIME types when you use applications that rely on XDG.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  mime_types:
    description:
      - One or more MIME types for which a default handler will be set.
    type: list
    elements: str
    required: true
  handler:
    description:
      - Sets the default handler for the specified MIME types.
      - The desktop file must be installed in the system.
        If the desktop file is not installed, the module
        does not fail, but the handler is not set either.
      - You must pass a handler in the form V(*.desktop), otherwise the module fails.
    type: str
    required: true
notes:
  - This module is a thin wrapper around C(xdg-mime) tool.
  - See man xdg-mime(1) for more details.
seealso:
  - name: C(xdg-mime) command manual page
    description: Manual page for the command.
    link: https://portland.freedesktop.org/doc/xdg-mime.html
  - name: xdg-utils Documentation
    description: Reference documentation for xdg-utils.
    link: https://www.freedesktop.org/wiki/Software/xdg-utils/
a  
- name: Set Chrome as the default handler for HTTPS
  community.general.xdg_mime:
    mime_types: x-scheme-handler/https
    handler: google-chrome.desktop
  register: result

- name: Set Chrome as the default handler for both HTTP and HTTPS
  community.general.xdg_mime:
    mime_types:
      - x-scheme-handler/http
      - x-scheme-handler/https
    handler: google-chrome.desktop
  register: result
a1  
current_handlers:
  description:
    - Currently set handlers for the passed MIME types.
  returned: success
  type: list
  elements: str
  sample:
    - google-chrome.desktop
    - firefox.desktop
version:
  description: Version of the C(xdg-mime) tool.
  type: str
  returned: always
  sample: "1.2.1"
)ModuleHelper)xdg_mime_runnerxdg_mime_getc            	       h    e Zd ZdgZ e e eddd       edd            d      Zd	Zd
 Zd Zy)XdgMimehandlerliststrT)typeelementsrequired)r   r   )
mime_typesr   )argument_specsupports_check_modeFc                 R   t        | j                  d      | _        | j                  d      5 }|j                         \  }}}|j	                  dd      j                         | j                  _        d d d        | j                  j                  j                  d      s| j                  d       g | j                  _        | j                  j                  D ]A  }t        | j                  |      }|sd}| j                  j                  j                  |       C y # 1 sw Y   xY w)	NT)check_rcversionz	xdg-mime  z.desktopzHandler must be a .desktop file)msg)r   modulerunnerrunreplacestripvarsr   r   endswithdo_raisecurrent_handlersr   r   append)selfctxrcouterrmimehandler_values          n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/xdg_mime.py__init_module__zXdgMime.__init_module__l   s    %dkkDA[[# 	Es779LBS #K < B B DDII	E yy  ))*5MM?M@%'		"II(( 	=D(d;M  "II&&--m<		=	E 	Es   ADD&c                     d}t         fd j                  j                  D              rd _         j	                         r j
                  j                  dd|      5 }|j                         \  }}}| j                  _        | j                  _	         j                  j                  d|j                  d       d d d        y y # 1 sw Y   y xY w)	N)r   zModule executed in check moder   c              3   P   K   | ]  }|j                   j                  k7    y wN)r   r   ).0hr#   s     r*   	<genexpr>z"XdgMime.__run__.<locals>.<genexpr>   s      J!qDII%%%Js   #&Tzdefault handler mime_types)
args_ordercheck_mode_skipcheck_mode_returnrun_info   )	verbosity)anyr   r!   changedhas_changedr   contextr   stdoutstderrsetr5   )r#   r4   r$   r%   r&   r'   s   `     r*   __run__zXdgMime.__run__}   s    DJtyy/I/IJJDL$$0L^b  wH$  I E  MP"wwyC#&		 #&		 		j#,,!D	E E E Es   !AC

CN)	__name__
__module____qualname__output_paramsdictr   use_old_vardictr+   r?        r*   r
   r
   `   sH    KM%$Ged3
 !F O="ErG   r
   c                  ,    t         j                          y r.   )r
   executerF   rG   r*   mainrJ      s    OOrG   __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNHansible_collections.community.general.plugins.module_utils.module_helperr   Cansible_collections.community.general.plugins.module_utils.xdg_mimer   r   r
   rJ   r@   rF   rG   r*   <module>rS      sZ    A @)V 
" b m(El (EV zF rG   