OwlCyberSecurity - MANAGER
Edit File: svg2png.cpython-311.pyc
� ֈ9h� � � � d dl Z d dlZd dlmZ dedefd�Zdee fd�Zdee fd�Zdee fd�Z ded edefd �Z dededefd�ZdS ) � N)�Optional�svg_data�returnc �� � t � � }|rt | |� � S t � � }|rt | |� � S t � � }|rt | |� � S t d� � �)z� Converts SVG data to PNG format using available converters. Args: svg_data (str): The SVG data to convert. Returns: bytes: The converted PNG data. Raises: RuntimeError: If no suitable converter is found. z&No suitable SVG to PNG converter found)�_get_alt_imagemagick_binary�_convert_with_imagemagick�_get_rsvg_convert_binary�_convert_with_rsvg�_get_imagemagick_binary�RuntimeError)r �alt_imagemagick�rsvg_convert�imagemagicks ��/builddir/build/BUILDROOT/lve-stats-4.2.13-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/chart/svg2png.py� svg_to_pngr s~ � � 2�3�3�O�� D�(��?�C�C�C�+�-�-�L�� :�!�(�L�9�9�9�)�+�+�K�� @�(��;�?�?�?� �?� @� @�@� c �L � d} t j � | � � r| S dS )zV Returns the path to the alt-ImageMagick binary if it exists, otherwise None. z'/opt/alt/alt-ImageMagick/usr/bin/magickN��os�path�exists)r s r r r ) s+ � � @�O� �w�~�~�o�&�&� ����4r c �L � d} t j � | � � r| S dS )zR Returns the path to the ImageMagick binary if it exists, otherwise None. z/usr/bin/convertNr )�native_imagemagicks r r r 3 s, � � ,�� �w�~�~�(�)�)� "�!�!��4r c �L � d} t j � | � � r| S dS )zS Returns the path to the rsvg-convert binary if it exists, otherwise None. z/usr/bin/rsvg-convertNr )r s r r r = s* � � +�L� �w�~�~�l�#�#� ����4r r c �$ � t j � � dk rdnd}t j |ddddgt j t j |�� � 5 }|� | � � � � � � \ }}ddd� � n# 1 swxY w Y |S ) z� Converts SVG data to PNG format using rsvg-convert. Args: svg_data (str): The SVG data to convert. rsvg_convert (str): The path to the rsvg-convert binary. Returns: bytes: The converted PNG data. r �/var/lve/tmpNz-f�pngz-bzrgba(255, 255, 255, 255)��stdin�stdout�cwd��input�r �getuid� subprocess�Popen�PIPE�communicate�encode)r r r! �proc�png_data�_s r r r G s� � � �I�K�K�1�,�,�.�.�$�C� � � �t�U�D�*D�E��o���� � � � @� ��&�&�X�_�_�->�->�&�?�?���!� @� @� @� @� @� @� @� @� @� @� @���� @� @� @� @� �Os � ,B�B �B r c � � t j � � dk rdnd}t j |ddgt j t j |�� � 5 }|� | � � � �� � \ }}ddd� � n# 1 swxY w Y |S )z� Converts SVG data to PNG format using ImageMagick. Args: svg_data (str): The SVG data to convert. imagemagick (str): The path to the ImageMagick binary. Returns: bytes: The converted PNG data. r r N�-zpng:-r r"