Skip to content

Commit b34ed86

Browse files
authored
Merge pull request #51 from davidrecordon/line-lengths
Fix line length lint issues across codebase
2 parents 6491d79 + 1eebb59 commit b34ed86

10 files changed

Lines changed: 110 additions & 106 deletions

File tree

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 88

pyControl4/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ def __init__(self, C4Director, item_id):
33
"""Creates a Control4 object.
44
55
Parameters:
6-
`C4Director` - A `pyControl4.director.C4Director` object that corresponds to the Control4 Director that the device is connected to.
6+
`C4Director` - A `pyControl4.director.C4Director` object that corresponds
7+
to the Control4 Director that the device is connected to.
78
89
`item_id` - The Control4 item ID.
910
"""

pyControl4/account.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ def __init__(
3333
3434
`password` - Control4 account password.
3535
36-
`session` - (Optional) Allows the use of an `aiohttp.ClientSession` object for all network requests. This session will not be closed by the library.
37-
If not provided, the library will open and close its own `ClientSession`s as needed.
36+
`session` - (Optional) Allows the use of an `aiohttp.ClientSession`
37+
object for all network requests. This session will not be closed
38+
by the library. If not provided, the library will open and close
39+
its own `ClientSession`s as needed.
3840
"""
3941
self.username = username
4042
self.password = password
@@ -88,7 +90,10 @@ async def __sendAccountGetRequest(self, uri):
8890
try:
8991
headers = {"Authorization": "Bearer {}".format(self.account_bearer_token)}
9092
except AttributeError:
91-
msg = "The account bearer token is missing - was your username/password correct? "
93+
msg = (
94+
"The account bearer token is missing. "
95+
"Is your username/password correct?"
96+
)
9297
_LOGGER.error(msg)
9398
raise
9499
if self.session is None:
@@ -108,12 +113,16 @@ async def __sendControllerAuthRequest(self, controller_common_name):
108113
entire JSON response from the Control4 auth API.
109114
110115
Parameters:
111-
`controller_common_name`: Common name of the controller. See `getAccountControllers()` for details.
116+
`controller_common_name`: Common name of the controller.
117+
See `getAccountControllers()` for details.
112118
"""
113119
try:
114120
headers = {"Authorization": "Bearer {}".format(self.account_bearer_token)}
115121
except AttributeError:
116-
msg = "The account bearer token is missing - was your username/password correct? "
122+
msg = (
123+
"The account bearer token is missing. "
124+
"Is your username/password correct?"
125+
)
117126
_LOGGER.error(msg)
118127
raise
119128
dataDictionary = {
@@ -150,12 +159,16 @@ async def getAccountBearerToken(self):
150159
self.account_bearer_token = jsonDictionary["authToken"]["token"]
151160
return self.account_bearer_token
152161
except KeyError:
153-
msg = "Did not recieve an account bearer token. Is your username/password correct? "
162+
msg = (
163+
"Did not recieve an account bearer token. "
164+
"Is your username/password correct?"
165+
)
154166
_LOGGER.error(msg + data)
155167
raise
156168

157169
async def getAccountControllers(self):
158-
"""Returns a dictionary of the information for all controllers registered to an account.
170+
"""Returns a dictionary of the information for all controllers registered
171+
to an account.
159172
160173
Returns:
161174
```
@@ -174,7 +187,8 @@ async def getControllerInfo(self, controller_href):
174187
"""Returns a dictionary of the information of a specific controller.
175188
176189
Parameters:
177-
`controller_href` - The API `href` of the controller (get this from the output of `getAccountControllers()`)
190+
`controller_href` - The API `href` of the controller (get this from
191+
the output of `getAccountControllers()`)
178192
179193
Returns:
180194
```
@@ -184,7 +198,7 @@ async def getControllerInfo(self, controller_href):
184198
'blockNotifications': False,
185199
'controllerCommonName': 'control4_MODEL_MACADDRESS',
186200
'controller': {
187-
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/controller'
201+
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/controller' # noqa: E501
188202
},
189203
'created': '2017-08-26T18:33:31Z',
190204
'dealer': {
@@ -196,7 +210,7 @@ async def getControllerInfo(self, controller_href):
196210
'id': 000000,
197211
'lastCheckIn': '2020-06-13T21:52:34Z',
198212
'licenses': {
199-
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/licenses'
213+
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/licenses' # noqa: E501
200214
},
201215
'modified': '2020-06-13T21:52:34Z',
202216
'name': 'Name',
@@ -206,7 +220,7 @@ async def getControllerInfo(self, controller_href):
206220
},
207221
'type': 'Consumer',
208222
'users': {
209-
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/users'
223+
'href': 'https://apis.control4.com/account/v3/rest/accounts/000000/users' # noqa: E501
210224
}
211225
}
212226
```
@@ -219,17 +233,20 @@ async def getControllerOSVersion(self, controller_href):
219233
"""Returns the OS version of a controller as a string.
220234
221235
Parameters:
222-
`controller_href` - The API `href` of the controller (get this from the output of `getAccountControllers()`)
236+
`controller_href` - The API `href` of the controller (get this from
237+
the output of `getAccountControllers()`)
223238
"""
224239
data = await self.__sendAccountGetRequest(controller_href + "/controller")
225240
jsonDictionary = json.loads(data)
226241
return jsonDictionary["osVersion"]
227242

228243
async def getDirectorBearerToken(self, controller_common_name):
229-
"""Returns a dictionary with a director bearer token for making Control4 Director API requests, and its time valid in seconds (usually 86400 seconds)
244+
"""Returns a dictionary with a director bearer token for making Control4
245+
Director API requests, and its time valid in seconds (usually 86400 seconds)
230246
231247
Parameters:
232-
`controller_common_name`: Common name of the controller. See `getAccountControllers()` for details.
248+
`controller_common_name`: Common name of the controller.
249+
See `getAccountControllers()` for details.
233250
"""
234251
data = await self.__sendControllerAuthRequest(controller_common_name)
235252
jsonDictionary = json.loads(data)

pyControl4/alarm.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
"""Controls Control4 security panel and contact sensor (door, window, motion) devices."""
1+
"""Controls Control4 security panel and contact sensor (door, window, motion)
2+
devices.
3+
"""
24

35
import json
46
from pyControl4 import C4Entity
57

68

79
class C4SecurityPanel(C4Entity):
810
async def getArmState(self):
9-
"""Returns the arm state of the security panel as "DISARMED", "ARMED_HOME", or "ARMED_AWAY"."""
11+
"""Returns the arm state of the security panel as "DISARMED", "ARMED_HOME",
12+
or "ARMED_AWAY".
13+
"""
1014
disarmed = await self.director.getItemVariableValue(
1115
self.item_id, "DISARMED_STATE"
1216
)
@@ -47,22 +51,27 @@ async def getTroubleText(self):
4751
async def getPartitionState(self):
4852
"""Returns the partition state of the security panel.
4953
50-
Possible values include "DISARMED_NOT_READY", "DISARMED_READY", "ARMED_HOME", "ARMED_AWAY", "EXIT_DELAY", "ENTRY_DELAY"
54+
Possible values include "DISARMED_NOT_READY", "DISARMED_READY", "ARMED_HOME",
55+
"ARMED_AWAY", "EXIT_DELAY", "ENTRY_DELAY"
5156
"""
5257
partition_state = await self.director.getItemVariableValue(
5358
self.item_id, "PARTITION_STATE"
5459
)
5560
return partition_state
5661

5762
async def getDelayTimeTotal(self):
58-
"""Returns the total exit delay time. Returns 0 if an exit delay is not currently running."""
63+
"""Returns the total exit delay time. Returns 0 if an exit delay is not
64+
currently running.
65+
"""
5966
delay_time_total = await self.director.getItemVariableValue(
6067
self.item_id, "DELAY_TIME_TOTAL"
6168
)
6269
return delay_time_total
6370

6471
async def getDelayTimeRemaining(self):
65-
"""Returns the remaining exit delay time. Returns 0 if an exit delay is not currently running."""
72+
"""Returns the remaining exit delay time. Returns 0 if an exit delay is
73+
not currently running.
74+
"""
6675
delay_time_remaining = await self.director.getItemVariableValue(
6776
self.item_id, "DELAY_TIME_REMAINING"
6877
)
@@ -109,7 +118,8 @@ async def setArm(self, usercode, mode: str):
109118
Parameters:
110119
`usercode` - PIN/code for arming the system.
111120
112-
`mode` - Arm mode to use. This depends on what is supported by the security panel itself.
121+
`mode` - Arm mode to use. This depends on what is supported by the
122+
security panel itself.
113123
"""
114124
usercode = str(usercode)
115125
await self.director.sendPostRequest(
@@ -168,7 +178,8 @@ async def triggerEmergency(self, type):
168178
)
169179

170180
async def sendKeyPress(self, key):
171-
"""Sends a single keypress to the security panel's virtual keypad (if supported).
181+
"""Sends a single keypress to the security panel's virtual keypad (if
182+
supported).
172183
173184
Parameters:
174185
`key` - Keypress to send. Only one key at a time.
@@ -186,15 +197,18 @@ def __init__(self, C4Director, item_id):
186197
"""Creates a Control4 Contact Sensor object.
187198
188199
Parameters:
189-
`C4Director` - A `pyControl4.director.C4Director` object that corresponds to the Control4 Director that the security panel is connected to.
200+
`C4Director` - A `pyControl4.director.C4Director` object that corresponds
201+
to the Control4 Director that the security panel is connected to.
190202
191203
`item_id` - The Control4 item ID of the contact sensor.
192204
"""
193205
self.director = C4Director
194206
self.item_id = item_id
195207

196208
async def getContactState(self):
197-
"""Returns `True` if contact is triggered (door/window is closed, motion is detected), otherwise returns `False`."""
209+
"""Returns `True` if contact is triggered (door/window is closed, motion is
210+
detected), otherwise returns `False`.
211+
"""
198212
contact_state = await self.director.getItemVariableValue(
199213
self.item_id, "ContactState"
200214
)

pyControl4/blind.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55

66
class C4Blind(C4Entity):
77
async def getBatteryLevel(self):
8-
"""Returns the battery of a blind. We currently don't know the range or meaning."""
8+
"""Returns the battery of a blind. We currently don't know the range or
9+
meaning.
10+
"""
911
value = await self.director.getItemVariableValue(self.item_id, "Battery Level")
1012
if value is None:
1113
return None
1214
return int(value)
1315

1416
async def getClosing(self):
15-
"""Returns an indication of whether the blind is moving in the closed direction as a boolean
16-
(True=closing, False=opening). If the blind is stopped, reports the direction it last moved.
17+
"""Returns an indication of whether the blind is moving in the closed direction
18+
as a boolean (True=closing, False=opening). If the blind is stopped, reports
19+
the direction it last moved.
1720
"""
1821
value = await self.director.getItemVariableValue(self.item_id, "Closing")
1922
if value is None:
@@ -46,16 +49,18 @@ async def getLevel(self):
4649
return int(value)
4750

4851
async def getOpen(self):
49-
"""Returns an indication of whether the blind is open as a boolean (True=open, False=closed).
50-
This is true even if the blind is only partially open."""
52+
"""Returns an indication of whether the blind is open as a boolean (True=open,
53+
False=closed). This is true even if the blind is only partially open.
54+
"""
5155
value = await self.director.getItemVariableValue(self.item_id, "Open")
5256
if value is None:
5357
return None
5458
return bool(value)
5559

5660
async def getOpening(self):
57-
"""Returns an indication of whether the blind is moving in the open direction as a boolean
58-
(True=opening, False=closing). If the blind is stopped, reports the direction it last moved.
61+
"""Returns an indication of whether the blind is moving in the open direction
62+
as a boolean (True=opening, False=closing). If the blind is stopped, reports
63+
the direction it last moved.
5964
"""
6065
value = await self.director.getItemVariableValue(self.item_id, "Opening")
6166
if value is None:
@@ -110,16 +115,19 @@ async def setLevelTarget(self, level):
110115
)
111116

112117
async def stop(self):
113-
"""Stops the blind if it is moving. Shortly after stopping, the target level will be
114-
set to the level the blind had actually reached when it stopped."""
118+
"""Stops the blind if it is moving. Shortly after stopping, the target level
119+
will be set to the level the blind had actually reached when it stopped.
120+
"""
115121
await self.director.sendPostRequest(
116122
"/api/v1/items/{}/commands".format(self.item_id),
117123
"STOP",
118124
{},
119125
)
120126

121127
async def toggle(self):
122-
"""Toggles the blind between open and closed. Has no effect if the blind is partially open."""
128+
"""Toggles the blind between open and closed. Has no effect if the blind is
129+
partially open.
130+
"""
123131
await self.director.sendPostRequest(
124132
"/api/v1/items/{}/commands".format(self.item_id),
125133
"TOGGLE",

pyControl4/director.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ async def getItemBindings(self, item_id):
217217
return await self.sendGetRequest("/api/v1/items/{}/bindings".format(item_id))
218218

219219
async def getUiConfiguration(self):
220-
"""Returns a dictionary of the JSON Control4 App UI Configuration enumerating rooms and capabilities
220+
"""Returns a dictionary of the JSON Control4 App UI Configuration enumerating
221+
rooms and capabilities
221222
222223
Returns:
223224

pyControl4/light.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ async def getLevel(self):
1414
return int(value)
1515

1616
async def getState(self):
17-
"""Returns the power state of a dimmer or switch as a boolean (True=on, False=off)."""
17+
"""Returns the power state of a dimmer or switch as a boolean (True=on,
18+
False=off).
19+
"""
1820
value = await self.director.getItemVariableValue(self.item_id, "LIGHT_STATE")
1921
if value is None:
2022
return None

pyControl4/relay.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
"""Controls Control4 Relay devices. These can include locks, and potentially other types of devices."""
1+
"""Controls Control4 Relay devices. These can include locks, and potentially other
2+
types of devices.
3+
"""
24

35
from pyControl4 import C4Entity
46

0 commit comments

Comments
 (0)