MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/utils/repository.pyc
�
g��fc@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	d�Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZdS(i����N(tCommandError(tcommand_aware_wrapscst���fd��}|S(sZ
    Decorator for snactor commands that require to be run in a repository directory.
    cs(td�std��n�||�S(Nt.s<This command must be executed from the repository directory.(tfind_repository_basedirR(targstkwargs(tf(s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytcheckers(R(RR((Rs:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytrequires_repositoryscCstd|krFdjg|jd�D]}|r"|j�^q"�}ntjdd|�}tjdd|�j�S(s�
    Converts an UpperCaseName to a snake_case_name

    :param name: Name to convert
    :return: converted snake case name
    t-ts(.)([A-Z][a-z]+)s\1_\2s([a-z0-9])([A-Z])(tjointsplitt
capitalizetretsubtlower(tnametpartts1((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyt
to_snake_cases:cCs5djgt|�jd�D]}|j�^q�S(s|
    Converts a snake_case_name to an UpperCaseName

    :param name: Name to convert
    :return: Converted class name
    R
t_(RRRR
(Rtx((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytmake_class_name%scCs
t|�S(su
    Converts a given name to a lower snake case

    :param name: Name to convert
    :return: Lower snake case
    (R(R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyt	make_name/scCsjtjj|�}xQtretjjtjj|d��r@|Stjj|�\}}|sdSqWdS(s
    Tries to find the .leapp directory recursively ascending until it hits the root directory

    :param path: Path to start from (can be relative)
    :return: None if the base directory was not found, otherwise the absolute path to the base directory
    s.leappN(tostpathtrealpathtTruetisdirRRtNone(Rtcurrent((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyR9s	!cCsPt|�}|rLttjj|dd�d��}tj|�SWdQXniS(s?
    Gets the parsed metadata file as a dictionary

    :param path: Path to start loading the metadata from (it can be anywhere within the repository it will use
                 :py:func:`find_repository_dir` to find the repository base directory)
    :return: Dictionary with the metadata or an empty dictionary
    s.leapptinfotrN(RtopenRRRtjsontload(RtbasedirR((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_repository_metadataIs
$cCst|�dS(s�
    Retrieves the repository name from the repository metadata from within the given path. (it can be anywhere within
    the repository it will use :py:func:`find_repositoryt_dir` to find the repository base directory)
    :param path: Path within the leapp repository
    :return: Name of the repository
    :raises: KeyError if no name was found (e.g. not a valid repository path)
    R(R&(R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_repository_nameXscCs~t|�}|rqt|�}ttj��|d<ttjj|dd�d��}t	j
||�WdQXn|jd�S(Ntids.leappR tw(R&Rtstrtuuidtuuid4R"RRRR#tdumptget(RtdataR%R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyt_create_and_set_repository_idcs$cCst|�jdg�S(s�
    Retrieves a list of repository ids that are linked to given repository.

    :param path: Path within the leapp repository
    :return: List of repository ids this repository is linked to
    trepos(R&R.(R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_repository_linksmscCs�t|�}|r�||dkr�t|�}|jdg�j|�ttjj|dd�d��}tj	||�t
SWdQXntS(s�
    Add a link from another repository to the current repository.

    :param path: Path within the leapp repository to modify
    :param repo_id: UUIDv4 string identifier for the repository to link
    :param repo_id: str
    :return: None
    R(R1s.leappR R)N(R&Rt
setdefaulttappendR"RRRR#R-RtFalse(Rtrepo_idR/R%R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytadd_repository_linkws	$
cCsCyt|�dSWn*tk
r>t|�r8t|�S�nXdS(s�
    Retrieves the repository name from the repository metadata from within the given path. (it can be anywhere within
    the repository it will use :py:func:`find_repository_dir` to find the repository base directory)
    :param path: Path within the leapp repository
    :return: ID of the repository
    :raises: KeyError if no name was found (e.g. not a valid repository path)
    R(N(R&tKeyErrorR0(R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_repository_id�s

cCsgtjjtjjd�dd�}ytj|�Wn+tk
rb}|jtjkrc�qcnX|S(s�
    Returns the path to the user configuration directory and creates it if it does not exist already.

    :return: Path to the configuration directory of leapp.
    t~s.configtleapp(RRRt
expandusertmakedirstOSErrorterrnotEEXIST(t
leapp_confte((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_user_config_path�s$
cCstjjt�d�S(s}
    Returns the path to the user config file for repositories.

    :return: Path to the repos.json configuration file.
    s
repos.json(RRRRC(((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_user_config_repos�scCsEt�}tjj|�siSt|��}tj|�SWdQXdS(s^
    Returns the user config repository data.

    :return: Data for user configurations.
    N(RDRRtisfileR"R#R$(R1R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_user_config_repo_data�s
	c
Cs�y�ttjd��x}tjdd|ddgd|�jd�jd�}g|D]0}|j�rUtjj	tjj
|��^qUSWd	QXWntjk
r�d
SXd	S(s�
    Finds repositories within the given path.

    :param path: Path to search for repositories.
    :return: List of strings with found repository paths.
    R)s
/usr/bin/finds-Ls-names.leapptstderrsutf-8s
N((R"Rtdevnullt
subprocesstcheck_outputtdecodeRtstripRtabspathtdirnametCalledProcessError(RRHR/trpath((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyt
find_repos�s0EcCs�d�td�D�}d�td�D�}i}xd|D]\}t|�jdd	�}|scq9ni|d6|d6t|�d6||kd6||<q9W|S(
sj
    Returns the data of all system wide available repositories.

    :return: Repository information
    cSs.h|]$}|j�rtjj|��qS((RLRRR(t.0R((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pys	<setcomp>�s	s/etc/leapp/repos.dcSs.h|]$}|j�rtjj|��qS((RLRRR(RRR((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pys	<setcomp>�s	s/usr/share/leapp-repositoryR(RRtenabledN(RQR&R.RR'(RSt	all_repost	repo_datatrepoR6((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pytget_global_repositories_data�s

(R?R#RRRIR+tleapp.exceptionsRtleapp.utils.clicmdRRRRRRR&R'R0R2R7R9RCRDRFRQRW(((s:/usr/lib/python2.7/site-packages/leapp/utils/repository.pyt<module>s.