diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-14 15:08:37 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-14 15:16:04 +0200 |
| commit | 5137d7ea3bf3356f917f6ccf44610cc23ea6492b (patch) | |
| tree | 2785f098bc0b390f307e1bd9f48901eb251ed491 /wrappers/python | |
| parent | ad01ccf4e59f632ead507646b10310e794b8f0c0 (diff) | |
Python: Run black
Diffstat (limited to 'wrappers/python')
| -rw-r--r-- | wrappers/python/eduvpn_common/discovery.py | 7 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/event.py | 9 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/loader.py | 33 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 12 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/server.py | 21 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/types.py | 19 |
6 files changed, 71 insertions, 30 deletions
diff --git a/wrappers/python/eduvpn_common/discovery.py b/wrappers/python/eduvpn_common/discovery.py index 91f29bd..0bf693b 100644 --- a/wrappers/python/eduvpn_common/discovery.py +++ b/wrappers/python/eduvpn_common/discovery.py @@ -1,7 +1,10 @@ from ctypes import POINTER, cast -from eduvpn_common.types import (cDiscoveryOrganizations, cDiscoveryServers, - get_ptr_list_strings) +from eduvpn_common.types import ( + cDiscoveryOrganizations, + cDiscoveryServers, + get_ptr_list_strings, +) class DiscoOrganization: diff --git a/wrappers/python/eduvpn_common/event.py b/wrappers/python/eduvpn_common/event.py index 940d0c0..d2ab952 100644 --- a/wrappers/python/eduvpn_common/event.py +++ b/wrappers/python/eduvpn_common/event.py @@ -1,9 +1,12 @@ from ctypes import CDLL, c_void_p from typing import Any, Callable, Dict, List, Tuple -from eduvpn_common.server import (get_locations, get_servers, - get_transition_profiles, - get_transition_server) +from eduvpn_common.server import ( + get_locations, + get_servers, + get_transition_profiles, + get_transition_server, +) from eduvpn_common.state import State, StateType from eduvpn_common.types import get_ptr_string diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index 55adcb8..170437a 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -4,10 +4,18 @@ from collections import defaultdict from ctypes import CDLL, c_char_p, c_int, c_void_p, cdll from eduvpn_common import __version__ -from eduvpn_common.types import (ConfigError, DataError, VPNStateChange, - cDiscoveryServer, cDiscoveryServers, cError, - cServer, cServerLocations, cServerProfiles, - cServers) +from eduvpn_common.types import ( + ConfigError, + DataError, + VPNStateChange, + cDiscoveryServer, + cDiscoveryServers, + cError, + cServer, + cServerLocations, + cServerProfiles, + cServers, +) def load_lib(): @@ -96,16 +104,19 @@ def initialize_functions(lib: CDLL): c_char_p, ], c_void_p lib.AddInstituteAccess.argtypes, lib.AddInstituteAccess.restype = [ - c_char_p, - c_char_p, + c_char_p, + c_char_p, ], c_void_p - lib.AddSecureInternetHomeServer.argtypes, lib.AddSecureInternetHomeServer.restype = [ - c_char_p, - c_char_p, + ( + lib.AddSecureInternetHomeServer.argtypes, + lib.AddSecureInternetHomeServer.restype, + ) = [ + c_char_p, + c_char_p, ], c_void_p lib.AddCustomServer.argtypes, lib.AddCustomServer.restype = [ - c_char_p, - c_char_p, + c_char_p, + c_char_p, ], c_void_p lib.RemoveInstituteAccess.argtypes, lib.RemoveInstituteAccess.restype = [ c_char_p, diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index c48fce1..b581c5e 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -7,8 +7,7 @@ from eduvpn_common.event import EventHandler from eduvpn_common.loader import initialize_functions, load_lib from eduvpn_common.server import get_servers from eduvpn_common.state import State, StateType -from eduvpn_common.types import (VPNStateChange, decode_res, encode_args, - get_data_error) +from eduvpn_common.types import VPNStateChange, decode_res, encode_args, get_data_error class EduVPN(object): @@ -64,7 +63,11 @@ class EduVPN(object): raise Exception("Already registered") register_err = self.go_function( - self.lib.Register, self.config_directory, self.language, state_callback, debug + self.lib.Register, + self.config_directory, + self.language, + state_callback, + debug, ) if register_err: @@ -262,6 +265,7 @@ class EduVPN(object): return servers + eduvpn_objects: Dict[str, EduVPN] = {} @@ -273,7 +277,6 @@ def state_callback(name: bytes, old_state: int, new_state: int, data: Any): eduvpn_objects[name_decoded].callback(State(old_state), State(new_state), data) - def add_as_global_object(eduvpn: EduVPN) -> bool: global eduvpn_objects if eduvpn.name not in eduvpn_objects: @@ -285,4 +288,3 @@ def add_as_global_object(eduvpn: EduVPN) -> bool: def remove_as_global_object(eduvpn: EduVPN): global eduvpn_objects eduvpn_objects.pop(eduvpn.name, None) - diff --git a/wrappers/python/eduvpn_common/server.py b/wrappers/python/eduvpn_common/server.py index 8dac3c1..eafb334 100644 --- a/wrappers/python/eduvpn_common/server.py +++ b/wrappers/python/eduvpn_common/server.py @@ -2,8 +2,7 @@ from ctypes import CDLL, POINTER, c_void_p, cast from datetime import datetime from typing import List, Optional, Type -from eduvpn_common.types import (cServer, cServerLocations, cServerProfiles, - cServers) +from eduvpn_common.types import cServer, cServerLocations, cServerProfiles, cServers class Profile: @@ -29,7 +28,13 @@ class Profiles: class Server: - def __init__(self, url: str, display_name: str, profiles: Optional[Profiles] = None, expire_time: int = 0): + def __init__( + self, + url: str, + display_name: str, + profiles: Optional[Profiles] = None, + expire_time: int = 0, + ): self.url = url self.display_name = display_name self.profiles = profiles @@ -44,7 +49,14 @@ class Server: class InstituteServer(Server): - def __init__(self, url: str, display_name: str, support_contact: List[str], profiles: Profiles, expire_time: int): + def __init__( + self, + url: str, + display_name: str, + support_contact: List[str], + profiles: Profiles, + expire_time: int, + ): super().__init__(url, display_name, profiles, expire_time) self.support_contact = support_contact @@ -52,6 +64,7 @@ class InstituteServer(Server): def category(self) -> str: return "Institute Access Server" + class SecureInternetServer(Server): def __init__( self, diff --git a/wrappers/python/eduvpn_common/types.py b/wrappers/python/eduvpn_common/types.py index 6d647f1..9f5fba0 100644 --- a/wrappers/python/eduvpn_common/types.py +++ b/wrappers/python/eduvpn_common/types.py @@ -1,5 +1,16 @@ -from ctypes import (CDLL, CFUNCTYPE, POINTER, Structure, c_char_p, c_int, - c_size_t, c_ulonglong, c_void_p, cast, pointer) +from ctypes import ( + CDLL, + CFUNCTYPE, + POINTER, + Structure, + c_char_p, + c_int, + c_size_t, + c_ulonglong, + c_void_p, + cast, + pointer, +) from typing import Any, Callable, Iterator, List, Optional, Tuple from eduvpn_common.error import ErrorLevel, WrappedError @@ -134,9 +145,7 @@ def get_ptr_string(lib: CDLL, ptr: c_void_p) -> str: return "" -def get_ptr_list_strings( - lib: CDLL, strings: pointer, total_strings: int -) -> List[str]: +def get_ptr_list_strings(lib: CDLL, strings: pointer, total_strings: int) -> List[str]: if strings: strings_list = [] for i in range(total_strings): |
