|
1 |
| -import enum |
2 |
| -from typing import Dict, List |
3 |
| - |
4 | 1 | from gi.overrides.Gtk import ListStore # type: ignore
|
5 | 2 | from gi.repository import GLib
|
6 | 3 |
|
7 |
| -from eduvpn.discovery import DiscoOrganization, DiscoServer |
8 | 4 | from eduvpn.i18n import retrieve_country_name
|
9 |
| -from eduvpn.server import InstituteServer, SecureInternetServer, Server |
| 5 | +from eduvpn.server import SecureInternetServer, ServerGroup, group_servers |
10 | 6 | from eduvpn.ui.utils import show_ui_component
|
11 | 7 | from eduvpn.utils import run_in_background_thread, run_in_glib_thread
|
12 | 8 |
|
13 |
| - |
14 |
| -class ServerGroup(enum.Enum): |
15 |
| - INSTITUTE_ACCESS = enum.auto() |
16 |
| - SECURE_INTERNET = enum.auto() |
17 |
| - OTHER = enum.auto() |
18 |
| - |
19 |
| - |
20 | 9 | group_scroll_component = {
|
21 | 10 | ServerGroup.INSTITUTE_ACCESS: "institute_list",
|
22 | 11 | ServerGroup.SECURE_INTERNET: "secure_internet_list",
|
@@ -82,29 +71,6 @@ def show_search_results(window: "EduVpnGtkWindow", show: bool) -> None: # type:
|
82 | 71 | show_ui_component(window.server_list_container, show)
|
83 | 72 |
|
84 | 73 |
|
85 |
| -def group_servers(servers): |
86 |
| - """ |
87 |
| - Separate the servers into three groups. |
88 |
| - """ |
89 |
| - groups: Dict[ServerGroup, List[Server]] = { # type: ignore |
90 |
| - ServerGroup.INSTITUTE_ACCESS: [], |
91 |
| - ServerGroup.SECURE_INTERNET: [], |
92 |
| - ServerGroup.OTHER: [], |
93 |
| - } |
94 |
| - for server in servers: |
95 |
| - if isinstance(server, InstituteServer) or ( |
96 |
| - isinstance(server, DiscoServer) and server.server_type == "institute_access" |
97 |
| - ): |
98 |
| - groups[ServerGroup.INSTITUTE_ACCESS].append(server) |
99 |
| - elif isinstance(server, SecureInternetServer) or isinstance(server, DiscoOrganization): |
100 |
| - groups[ServerGroup.SECURE_INTERNET].append(server) |
101 |
| - elif isinstance(server, Server): |
102 |
| - groups[ServerGroup.OTHER].append(server) |
103 |
| - else: |
104 |
| - continue |
105 |
| - return groups |
106 |
| - |
107 |
| - |
108 | 74 | def show_group_tree(window: "EduVpnGtkWindow", group: ServerGroup, show: bool) -> None: # type: ignore # noqa: F821
|
109 | 75 | """
|
110 | 76 | Set the visibility of the tree of result for a server type.
|
|
0 commit comments