HEX
Server: LiteSpeed
System: Linux srv1.dhviews.com 5.14.0-570.23.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 24 11:27:16 EDT 2025 x86_64
User: bdedition (1723)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.9/site-packages/wordfence/api/licensing.py
from typing import Union, Optional

from .exceptions import ApiException


LICENSE_URL = 'https://www.wordfence.com/products/wordfence-cli/'


class License:

    def __init__(self, key: str):
        self.key = key
        self.paid = False

    def __eq__(self, other):
        return other.key == self.key

    def __str__(self) -> str:
        return self.key


def to_license(license: Union[License, str]) -> License:
    if isinstance(license, License):
        return license
    return License(license)


class LicenseRequiredException(ApiException):

    def __init__(self):
        super().__init__(
                'License required',
                'A valid Wordfence CLI license is required'
            )


class LicenseSpecific:

    def __init__(self, license: Optional[License]):
        self.license = license

    def is_compatible_with_license(self, license: License):
        return self.license is None or self.license == license

    def assign_license(self, license: Optional[License]):
        self.license = license

    def clear_license(self):
        self.assign_license(None)