File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/virtualenv.zip
Back
PK J\�Z��,d� � config/convert.pynu �[��� from __future__ import annotations import logging import os from typing import ClassVar LOGGER = logging.getLogger(__name__) class TypeData: def __init__(self, default_type, as_type) -> None: self.default_type = default_type self.as_type = as_type def __repr__(self) -> str: return f"{self.__class__.__name__}(base={self.default_type}, as={self.as_type})" def convert(self, value): return self.default_type(value) class BoolType(TypeData): BOOLEAN_STATES: ClassVar[dict[str, bool]] = { "1": True, "yes": True, "true": True, "on": True, "0": False, "no": False, "false": False, "off": False, } def convert(self, value): if value.lower() not in self.BOOLEAN_STATES: msg = f"Not a boolean: {value}" raise ValueError(msg) return self.BOOLEAN_STATES[value.lower()] class NoneType(TypeData): def convert(self, value): if not value: return None return str(value) class ListType(TypeData): def _validate(self): """no op.""" def convert(self, value, flatten=True): # noqa: ARG002, FBT002 values = self.split_values(value) result = [] for a_value in values: sub_values = a_value.split(os.pathsep) result.extend(sub_values) return [self.as_type(i) for i in result] def split_values(self, value): """ Split the provided value into a list. First this is done by newlines. If there were no newlines in the text, then we next try to split by comma. """ if isinstance(value, (str, bytes)): # Use `splitlines` rather than a custom check for whether there is # more than one line. This ensures that the full `splitlines()` # logic is supported here. values = value.splitlines() if len(values) <= 1: values = value.split(",") values = filter(None, [x.strip() for x in values]) else: values = list(value) return values def convert(value, as_type, source): """Convert the value as a given type where the value comes from the given source.""" try: return as_type.convert(value) except Exception as exception: LOGGER.warning("%s failed to convert %r as %r because %r", source, value, as_type, exception) raise _CONVERT = {bool: BoolType, type(None): NoneType, list: ListType} def get_type(action): default_type = type(action.default) as_type = default_type if action.type is None else action.type return _CONVERT.get(default_type, TypeData)(default_type, as_type) __all__ = [ "convert", "get_type", ] PK J\�Z�]�LA A * config/__pycache__/env_var.cpython-310.pycnu �[��� o }h� � @ s6 d dl mZ d dlmZ ddlmZ dd� ZdgZdS )� )�annotations)�suppress� )�convertc C sj d| � � � �}|�|�r3|| }tt�� d|� �}t|||�}||fW d � S 1 s.w Y dS )z� Get the environment variable option. :param key: the config key requested :param as_type: the type we would like to convert it to :param env: environment variables to use :return: �VIRTUALENV_zenv var N)�upper�getr � Exceptionr )�key�as_type�env�environ_key�value�source� r �D/usr/local/lib/python3.10/dist-packages/virtualenv/config/env_var.py�get_env_var s �r N)� __future__r � contextlibr r r �__all__r r r r �<module> s �PK J\�Z�(�q� � + config/__pycache__/__init__.cpython-310.pycnu �[��� o }h � @ s d S )N� r r r �E/usr/local/lib/python3.10/dist-packages/virtualenv/config/__init__.py�<module> s PK J\�Z=8 1^ ^ * config/__pycache__/convert.cpython-310.pycnu �[��� o }h� � @ s� d dl mZ d dlZd dlZd dlmZ e�e�ZG dd� d�Z G dd� de �Z G dd � d e �ZG d d� de �Zdd � Z ee ed�eeeiZdd� Zd dgZdS )� )�annotationsN)�ClassVarc @ s( e Zd Zddd�Zddd�Zdd � Zd S ) �TypeData�return�Nonec C s || _ || _d S �N)�default_type�as_type)�selfr r � r �D/usr/local/lib/python3.10/dist-packages/virtualenv/config/convert.py�__init__ s zTypeData.__init__�strc C s | j j� d| j� d| j� d�S )Nz(base=z, as=�))� __class__�__name__r r �r r r r �__repr__ s zTypeData.__repr__c C s | � |�S r )r �r �valuer r r �convert s zTypeData.convertN)r r )r r )r � __module__�__qualname__r r r r r r r r s r c @ s4 e Zd ZU ddddddddd�Zded<