Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/system/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/system/locale_gen.pyo

�
�Udac@`sQddlmZmZmZeZidd6dgd6dd6ZdZd	Zdd
l	Z	dd
l
Z
ddlmZm
Z
mZddlmZdd
lmZi
dd6dd6dd6dd6dd6dd6dd6dd6dd6d d!6Zd"�Zd#�Zd$�Zd%�Zed&�Zd'�Zd(�Zd)�Zed*krMe�nd
S(+i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: locale_gen
short_description: Creates or removes locales
description:
     - Manages locales by editing /etc/locale.gen and invoking locale-gen.
version_added: "1.6"
author:
- Augustus Kling (@AugustusKling)
options:
    name:
        description:
             - Name and encoding of the locale, such as "en_GB.UTF-8".
        required: true
    state:
      description:
           - Whether the locale shall be present.
      choices: [ absent, present ]
      default: present
sW
- name: Ensure a locale exists
  locale_gen:
    name: de_CH.UTF-8
    state: present
N(tPopentPIPEtcall(t
AnsibleModule(t	to_natives.UTF-8s.utf8s.EUC-JPs.eucjps.ISO-8859-15s
.iso885915s.CP1251s.cp1251s.KOI8-Rs.koi8rs
.ARMSCII-8s	.armscii8s.EUC-KRs.euckrs.GBKs.gbks.GB18030s.gb18030s.EUC-TWs.euctwcC`s�|rd}d}nd}d}tj|�}t|d�}x<|D]4}|j|�}|rF|jd�|krFtSqFW|j�tS(s�Check if the given locale is available on the system. This is done by
    checking either :
    * if the locale is present in /etc/locales.gen
    * or if the locale is present in /usr/share/i18n/SUPPORTEDs)^(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$s/usr/share/i18n/SUPPORTEDs2^#{0,1}\s*(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$s/etc/locale.gentrtlocale(tretcompiletopentmatchtgrouptTruetclosetFalse(tnamet
ubuntuModet__regexpt__locales_availabletre_compiledtfdtlinetresult((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pytis_availableBs	

c`sNtddgdt�j�d}t|�}t�fd�|j�D��S(s2Checks if the given locale is currently installed.Rs-atstdoutic3`s'|]}t��t|�kVqdS(N(tfix_case(t.0R(R(sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pys	<genexpr>\s(RR	tcommunicateRtanyt
splitlines(Rtoutput((RsE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pyt
is_presentXs"cC`s3x,tj�D]\}}|j||�}q
W|S(s�locale -a might return the encoding in either lower or upper case.
    Passing through this function makes them uniform for comparisons.(tLOCALE_NORMALIZATIONtitemstreplace(RtsR
((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pyR!_scC`s�z8tdd�}g|D]}|j||�^q}Wd|j�Xz)tdd�}|jdj|��Wd|j�XdS(s!Replaces lines in /etc/locale.gens/etc/locale.genR
Ntwt(RR*Rtwritetjoin(t
existing_linetnew_linetfRtlines((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pytreplace_linegs)cC`s�d|}|rd|}n
d|}z;tdd�}g|D]}tj|||�^q@}Wd|j�Xz)tdd�}|jdj|��Wd|j�XdS(	s4 Sets the state of the locale. Defaults to enabled. s#{0,1}\s*%s (?P<charset>.+)s%s \g<charset>s# %s \g<charset>s/etc/locale.genR
NR,R-(RRtsubRR.R/(Rtenabledt
search_stringt
new_stringR2RR3((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pyt
set_localeus


,cC`sg|dkrt|dt�nt|dt�td�}|dkrct|dt|���ndS(s�Create or remove locale.

    Keyword arguments:
    targetState -- Desired state, either present or absent.
    name -- Name including encoding such as de_CH.UTF-8.
    tpresentR6s
locale-genis*locale.gen failed to execute, it returned N(R9RRR
tEnvironmentErrortstr(ttargetStateRtlocaleGenExitValue((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pytapply_change�scC`s�|dkr!td|g�}n�ztdd�}|j�}Wd|j�XzUtdd�}x?|D]7}|jd�\}}||krg|j|�qgqgWWd|j�Xtddg�}|d	kr�t|d
t|���ndS(s�Create or remove locale.

    Keyword arguments:
    targetState -- Desired state, either present or absent.
    name -- Name including encoding such as de_CH.UTF-8.
    R:s
locale-gens"/var/lib/locales/supported.d/localR
NR,t s--purgeis*locale.gen failed to execute, it returned (R
Rt	readlinesRtsplitR.R;R<(R=RR>R2tcontentRRtcharset((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pytapply_change_ubuntu�s 
cC`s�tdtdtdddt�dtddddd	d
dg��dt�}|jd}|jd}tjjd�s�tjjd
�r�t}q�|jdd�nt}t	||�s�|jdd�nt
|�r�d}nd
}||k}|jr|jd|�n�|r~y-|tkr8t
||�n
t||�Wq~tk
rz}|jdt|�d|j�q~Xn|jd|d|dd�dS(Nt
argument_specRttypeR<trequiredtstatetdefaultR:tchoicestabsenttsupports_check_modes/etc/locale.gens/var/lib/locales/supported.d/tmsgsg/etc/locale.gen and /var/lib/locales/supported.d/local are missing. Is the package "locales" installed?s:The locale you've entered is not available on your system.tchangedt	exitValuetOK(RtdictRtparamstostpathtexistst	fail_jsonRRR't
check_modet	exit_jsonR?RER;Rterrno(tmoduleRRIRt
prev_stateROte((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pytmain�s8$	

			&t__main__(t
__future__RRRRGt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLESRTRt
subprocessRR	R
tansible.module_utils.basicRtansible.module_utils._textRR(RR'R!R4RR9R?RER^t__name__(((sE/usr/lib/python2.7/site-packages/ansible/modules/system/locale_gen.pyt<module>s@



						"	/

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]