404

[ Avaa Bypassed ]




Upload:

Command:

botdev@3.129.206.232: ~ $
from ..country_codes import country_codes
from ..enums import ServerTierEnum


class Country:
    """Country Class.
    Use it to get country name and check if country codes exist.

    Exposes method:
        _get_country_name(country_code: String)
        _ensure_country_exists(country_code: String)

    Description:
    _get_country_name()
        Gets a country name based on the provided country code in
        string (ISO) format.
    _ensure_country_exists()
        Ensures that a given country code exists.
    """

    def get_dict_with_country_servername(self, server_list, user_tier=False):
        """Generate dict with {country:[servername]}.

        Args:
            server_list (list)
            tier (int)
        Returns:
            dict: country_code: [servername]
                ie {PT: [PT#5, PT#8]}
        """
        countries = {}
        for server in server_list:
            if user_tier is not False and int(server.tier) <= int(user_tier):
                country = self.get_country_name(server.exit_country)
            elif isinstance(user_tier, bool) and not user_tier:
                country = self.get_country_name(server.exit_country)
            else:
                continue

            if country not in countries.keys():
                countries[country] = []
            countries[country].append(server.name)

        return countries

    def get_dict_with_country_code_servername(self, server_list):
        """Generate dict with {country:[servername]}.

        Args:
            server_list (list)
        Returns:
            dict: country_code: [servername]
                ie {PT: [PT#5, PT#8]}
        """
        countries = {}
        for server in server_list:
            if countries.get(server.exit_country):
                countries[server.exit_country].append(server.name)
            else:
                countries[server.exit_country] = []
                countries[server.exit_country].append(server.name)

        return countries

    def get_country_name(self, country_code):
        """Get country name of a given country code.

        Args:
            country_code (string): ISO format
        """
        return self.extract_country_name(country_code)

    def ensure_country_code_exists(self, country_code):
        """Checks if given country code exists.

        Args:
            country_code (string): ISO format

        Returns:
            bool
        """
        if not self.extract_country_name(country_code):
            raise ValueError(
                "The provided country code {} does not exist.".format(
                    country_code
                )
            )

    def extract_country_name(self, country_code):
        """Extract country name based on specified code.

        Args:
            code (string): country code [PT|SE|CH]

        Returns:
            string:
                country name if found, else returns country code
        """
        return country_codes.get(country_code, country_code)

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
accounting Folder 0755
client_config Folder 0755
connection_backend Folder 0755
dbus Folder 0755
keyring Folder 0755
killswitch Folder 0755
location Folder 0755
metadata Folder 0755
notification Folder 0755
report Folder 0755
servers Folder 0755
session Folder 0755
streaming Folder 0755
user_settings Folder 0755
vpn Folder 0755
__init__.py File 966 B 0644
country.py File 2.95 KB 0644
environment.py File 4.42 KB 0644
status.py File 2.77 KB 0644
subprocess_wrapper.py File 4.1 KB 0644
utilities.py File 5.2 KB 0644
utils.py File 961 B 0644