6
6
Attempt to detect the current platform.
7
7
"""
8
8
import re
9
-
10
- from adafruit_platformdetect .board import Board
11
- from adafruit_platformdetect .chip import Chip
9
+ from typing import Optional
10
+ from .board import Board
11
+ from .chip import Chip
12
12
13
13
14
14
# Various methods here may retain state in future, so tell pylint not to worry
17
17
class Detector :
18
18
"""Wrap various platform detection functions."""
19
19
20
- def __init__ (self ):
20
+ def __init__ (self ) -> None :
21
21
self .board = Board (self )
22
22
self .chip = Chip (self )
23
23
24
- def get_cpuinfo_field (self , field ) :
24
+ def get_cpuinfo_field (self , field : str ) -> Optional [ str ] :
25
25
"""
26
26
Search /proc/cpuinfo for a field and return its value, if found,
27
27
otherwise None.
@@ -37,7 +37,7 @@ def get_cpuinfo_field(self, field):
37
37
return match .group (1 )
38
38
return None
39
39
40
- def check_dt_compatible_value (self , value ) :
40
+ def check_dt_compatible_value (self , value : str ) -> bool :
41
41
"""
42
42
Search /proc/device-tree/compatible for a value and return True, if found,
43
43
otherwise False.
@@ -49,7 +49,7 @@ def check_dt_compatible_value(self, value):
49
49
50
50
return False
51
51
52
- def get_armbian_release_field (self , field ) :
52
+ def get_armbian_release_field (self , field : str ) -> Optional [ str ] :
53
53
"""
54
54
Search /etc/armbian-release, if it exists, for a field and return its
55
55
value, if found, otherwise None.
@@ -69,7 +69,7 @@ def get_armbian_release_field(self, field):
69
69
70
70
return field_value
71
71
72
- def get_device_model (self ):
72
+ def get_device_model (self ) -> Optional [ str ] :
73
73
"""
74
74
Search /proc/device-tree/model for the device model and return its value, if found,
75
75
otherwise None.
@@ -81,7 +81,7 @@ def get_device_model(self):
81
81
pass
82
82
return None
83
83
84
- def get_device_compatible (self ):
84
+ def get_device_compatible (self ) -> Optional [ str ] :
85
85
"""
86
86
Search /proc/device-tree/compatible for the compatible chip name.
87
87
"""
@@ -94,7 +94,7 @@ def get_device_compatible(self):
94
94
pass
95
95
return None
96
96
97
- def check_board_asset_tag_value (self ):
97
+ def check_board_asset_tag_value (self ) -> Optional [ str ] :
98
98
"""
99
99
Search /sys/devices/virtual/dmi/id for the device model and return its value, if found,
100
100
otherwise None.
@@ -108,7 +108,7 @@ def check_board_asset_tag_value(self):
108
108
pass
109
109
return None
110
110
111
- def check_board_name_value (self ):
111
+ def check_board_name_value (self ) -> Optional [ str ] :
112
112
"""
113
113
Search /sys/devices/virtual/dmi/id for the board name and return its value, if found,
114
114
otherwise None. Debian/ubuntu based
0 commit comments