Skip to content

Commit 905c91f

Browse files
committed
Make ConnectionType an string Enum and remove ConnectionTypeByDeviceType
sdbus will properly encode the string enums because they are subclass of string. ConnectionTypeByDeviceType is redundant when you can do getattr(ConnectionType, name).
1 parent 39bb239 commit 905c91f

File tree

2 files changed

+3
-37
lines changed

2 files changed

+3
-37
lines changed

sdbus_async/networkmanager/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
ConnectionStateFlags,
2828
ConnectionStateReason,
2929
ConnectionType,
30-
ConnectionTypeByDeviceType,
3130
ConnectivityState,
3231
DeviceCapabilities,
3332
DeviceInterfaceFlags,
@@ -272,7 +271,7 @@
272271
'AccessPointCapabilities', 'BluetoothCapabilities',
273272
'ConnectionFlags', 'ConnectionState', 'ConnectionStateFlags',
274273
'ConnectionStateReason', 'ConnectivityState', 'ConnectionType',
275-
'ConnectionTypeByDeviceType',
274+
276275
'DeviceCapabilities', 'DeviceInterfaceFlags', 'DeviceMetered',
277276
'DeviceState', 'DeviceStateReason', 'DeviceType', 'IpTunnelMode',
278277
'ModemCapabilities', 'NetworkManagerConnectivityState',

sdbus_async/networkmanager/enums.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
from __future__ import annotations
2121

22-
from enum import IntEnum, IntFlag
22+
from enum import IntEnum, IntFlag, Enum
2323

2424

2525
class AccessPointCapabilities(IntFlag):
@@ -494,7 +494,7 @@ class DeviceStateReason(IntEnum):
494494
# thus there are more ConnectionTypes than DeviceTypes:
495495

496496
# From NetworkManager-1.35:
497-
class ConnectionType():
497+
class ConnectionType(str, Enum):
498498
ADSL = "adsl"
499499
BLUETOOTH = "bluetooth"
500500
BOND = "bond"
@@ -596,39 +596,6 @@ class DeviceType(IntEnum):
596596
VRF = 31
597597

598598

599-
ConnectionTypeByDeviceType = {
600-
"ADSL": "adsl",
601-
"BLUETOOTH": "bluetooth",
602-
"BOND": "bond",
603-
"BRIDGE": "bridge",
604-
"CDMA": "cdma",
605-
"DUMMY": "dummy",
606-
"ETHERNET": "802-3-ethernet",
607-
"INFINIBAND": "infiniband",
608-
"IP_TUNNEL": "ip-tunnel",
609-
"MACSEC": "macsec",
610-
"MACVLAN": "macvlan",
611-
"MODEM": "gsm",
612-
"OLPC_MESH": "802-11-olpc-mesh",
613-
"OVS_BRIDGE": "ovs-bridge",
614-
"OVS_INTERFACE": "ovs-interface",
615-
"OVS_PORT": "ovs-port",
616-
"PPPOE": "pppoe",
617-
"SIXLOWPAN": "6lowpan",
618-
"TEAM": "team",
619-
"TUN": "tun",
620-
"VETH": "veth",
621-
"VLAN": "vlan",
622-
"VPN": "vpn",
623-
"VRF": "vrf",
624-
"VXLAN": "vxlan",
625-
"WIFI": "802-11-wireless",
626-
"WIFI_P2P": "wifi-p2p",
627-
"WIREGUARD": "wireguard",
628-
"WPAN": "wpan",
629-
}
630-
631-
632599
class DeviceMetered(IntEnum):
633600
"""Device Metered state
634601

0 commit comments

Comments
 (0)