Debian Codegraph @

plyer/facades/battery.py

raw symbols SCIP
1 '''
2 Battery
3 =======
4
5 The :class:`Battery` provides information about the battery of your device.
6
7 .. note::
8 On Android the `BATTERY_STATS` permission is needed.
9
10 Simple Example
11 ---------------
12
13 To get battery status::
14
15 >>> from plyer import battery
16 >>> battery.status
17 {'percentage': 82.0, 'isCharging': False}
18
19 Supported Platforms
20 -------------------
21 Android, iOS, Windows, OS X, Linux
22
23 '''
24
25
26 class Battery:
27 '''
28 Battery info facade.
29 '''
30
31 @property
32 def status(self):
33 '''
34 Property that contains a dict with the following fields:
35 * **isCharging** *(bool)*: Battery is charging
36 * **percentage** *(float)*: Battery charge remaining
37
38 .. warning::
39 If any of the fields is not readable, it is set as
40 None.
41 '''
42 return self.get_state()
43
44 def get_state(self):
45 '''
46 Public method for filling battery.status via platform-specific
47 API in plyer.platforms.
48 '''
49 return self._get_state()
50
51 # private
52
53 def _get_state(self):
54 raise NotImplementedError()