File: //opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/__pycache__/cli.cpython-311.pyc
�
�(��j�p� �| � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m
Z
mZ ddlm
Z
mZ ddlmZmZmZ ddlmZ dd lmZ ej e� � Zd
edefd�Zd
edefd�Zdedefd�Zdefd�Zdefd�Z defd�Z!defd�Z"defd�Z#defd�Z$defd�Z%defd�Z& ed�� � defd�� � Z'd� Z(defd�Z)dS )u
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Copyright © 2019 Cloud Linux Software Inc.
This software is also available under ImunifyAV commercial license,
see <https://www.imunify360.com/legal/eula>
� N)�Path)�
StrictVersion)� check_run�
CheckRunError�async_lru_cache)�PLUGIN_PATH�PLUGIN_SLUG)�build_command_for_user�get_php_binary_path�
wp_wrapper)�log_message)�WPSite�version_str�returnc � � t | t � � sdS | � � � }|sdS t |� � dS # t $ r Y dS w xY w)z1Validate if a string is a valid semantic version.FT)�
isinstance�str�stripr �
ValueError)r �trimmed_strs �G/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/cli.py�_validate_semverr - su � � �k�3�'�'� ��u� �#�#�%�%�K�� ��u���k�"�"�"��t��� � � ��u�u����s �A �
A�A�outputc �` � | sdS | � � � }|sdS t |� � dk r+|d � � � }t |� � r|S t |� � dk r+|d � � � }t |� � r|S t dd| idd� � � dS )
z�
Extract version from WP CLI output, trying both first and last parts.
Args:
output: The raw output from WP CLI
Returns:
The extracted version string or None if no valid version found
Nr � ���zMFailed to extract valid semver version from WP CLI output. Output: '{output}'r �warningz#wp-plugin-version-extraction-failed)�format_args�level�fingerprint)�split�lenr r r
)r �parts�
first_part� last_parts r �_extract_version_from_outputr&