Mini Shell

Direktori : /lib/python3.6/site-packages/pykickstart/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/pykickstart/__pycache__/version.cpython-36.opt-1.pyc

3

�
Ld��#@sldZddlZddlZddlZddlZddlmZddlmZddl	m
Z
dZdZdZ
d	Zd
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d!Z&d"Z'd#Z(d$Z)d%Z*d&Z+e+Z,e+Z-e+Z.e*Z/e/eeeeeeeeeeeeeeeeee e!e#e$e%e&e'e(e)e*ee
eee"e+d'�"Z0d(d)�Z1d7d+d,�Z2d-d.�Z3d/d0�Z4e/fd1d2�Z5e/fd3d4�Z6d5d6�Z7dS)8aQ
Methods for working with kickstart versions.

This module defines several symbolic constants that specify kickstart syntax
versions.  Each version corresponds roughly to one release of Red Hat Linux,
Red Hat Enterprise Linux, or Fedora Core as these are where most syntax
changes take place.

This module also exports several functions:

    makeVersion - Given a version number, return an instance of the
                  matching handler class.

    returnClassForVersion - Given a version number, return the matching
                            handler class.  This does not return an
                            instance of that class, however.

    stringToVersion - Convert a string representation of a version number
                      into the symbolic constant.

    versionToString - Perform the reverse mapping.

    versionToLongString - Perform the reverse mapping but use long names.

    versionFromFile - Read a kickstart file and determine the version of
                      syntax it uses.  This requires the kickstart file to
                      have a version= comment in it.
�N)�_)�KickstartVersionError)�load_to_stri�i�iLi�i�i�ii�ipiXi@i(#i'i�*i\+i�.i�2i�6i�:i�>ihBiPFi8Ji�Ji NiRi�Ui�Yi�]i�ai�eixii�i)"�DEVEL�FC3�FC4�FC5�FC6�F7�F8�F9�F10�F11�F12�F13�F14�F15�F16�F17�F18�F19�F20�F21�F22�F23�F24�F25�F26�F27�F28�F29�RHEL3�RHEL4�RHEL5�RHEL6�RHEL7�RHEL8cCs�yt|j�Stk
r YnXtjd|tj�}|r�|jd�r�d|jd�tkrdtd|jd�Sd|jd�tkr�td|jd�Sttd�|��tjd|tj�}|r�|jd�r�d|jd�tkr�td|jd�Sttd�|��ttd�|��dS)	z�Convert string into one of the provided version constants.  Raises
       KickstartVersionError if string does not match anything.
    z^fedora.* (\d+)$��FC�Fz!Unsupported version specified: %sz+^red hat enterprise linux.* (\d+)([\.\d]*)$�RHELN)	�
versionMap�upper�KeyError�re�match�I�grouprr)�s�m�r4�/usr/lib/python3.6/version.py�stringToVersionqs"r6FcCs\|r|tdkrdSx0ttj��D] \}}|dkr8q$q$||kr$|Sq$Wttd�|��dS)z�Convert version into a string representation of the version number.
       This is the reverse operation of stringToVersion.  Raises
       KickstartVersionError if version does not match anything.
    rz!Unsupported version specified: %sN)r+�list�itemsrr)�version�	skipDevel�key�valr4r4r5�versionToString�sr=cCs.t|d�}|jdd�jdd�}|jdd�}|S)z@
        Convert version into a long string representation.
    Tr(r)ZFedorar*ZRedHatEnterpriseLinux)r=�replace)r9�resultr4r4r5�versionToLongString�s
r@cCsXt}t|�}xF|jd�D]8}|j�dkr*q|dd�dkrt|dd�j��}PqW|S)z�Given a file or URL, look for a line starting with #version= and
       return the version number.  If no version is found, return DEVEL.
    T�N�	z	#version=)rr�
splitlines�stripr6�rstrip)�f�v�contents�liner4r4r5�versionFromFile�srJcCs�yt|�}dt|dd�}Wn$tk
r@d|}t|�}YnX|j�}ydtjjtjjt	�d�}t
jj|g�tj
|�}x0t|jj��D]\}}|j�jd|�r�|Sq�WWnttd�|��YnXdS)z�Return the class of the syntax handler for version.  version can be
       either a string or the matching constant.  Raises KickstartVersionError
       if version does not match anything.
    z%sT)r:z	handlers/z	%shandlerz!Unsupported version specified: %sN)�intr=�
ValueErrorr6�lower�os�path�join�dirname�__file__�sys�extend�	importlib�
import_moduler7�__dict__r8�endswithrr)r9�module�_pathZloaded�krGr4r4r5�returnClassForVersion�s 
r\cCst|�}|�S)agReturn a new instance of the syntax handler for version.  version can be
       either a string or the matching constant.  This function is useful for
       standalone programs which just need to handle a specific version of
       kickstart syntax (as provided by a command line argument, for example)
       and need to instantiate the correct object.
    )r\)r9Zclr4r4r5�makeVersion�sr]cCst|jjd�dS)Nrr)r+�__name__�split)�clsr4r4r5�getVersionFromCommandClass�sra)F)8�__doc__rNr.rSrUZpykickstart.i18nrZpykickstart.errorsrZpykickstart.loadrr!rr"rrr	r#r
rrr
rrrr$rrrrrrrrr%rrrrrrrr r&ZF30ZF31ZF32rr+r6r=r@rJr\r]rar4r4r4r5�<module>/st




!