24
24
__copyright__ = "Copyright 2017-2022 DaveL17"
25
25
__license__ = "MIT"
26
26
__title__ = "DLFramework"
27
- __version__ = "0.1.04 "
27
+ __version__ = "0.1.05 "
28
28
29
29
# supported operators for eval expressions
30
30
OPERATORS = {
@@ -63,17 +63,14 @@ def __init__(self, plugin):
63
63
self .pluginPrefs = plugin .pluginPrefs
64
64
65
65
log_format = '%(asctime)s.%(msecs)03d\t %(levelname)-10s\t %(name)s.%(funcName)-28s %(msg)s'
66
- self .plugin .plugin_file_handler .setFormatter (
67
- logging .Formatter (fmt = log_format , datefmt = '%Y-%m-%d %H:%M:%S' )
68
- )
66
+ self .plugin .plugin_file_handler .setFormatter (logging .Formatter (fmt = log_format , datefmt = '%Y-%m-%d %H:%M:%S' ))
69
67
70
68
# =============================================================================
71
69
def pluginEnvironment (self ): # noqa
72
70
"""
73
- The pluginEnvironment method prints selected information about the pluginEnvironment that
74
- the plugin is running in. It pulls some of this information from the calling plugin and
75
- some from the server pluginEnvironment. It uses the legacy "indigo.server.log" method to
76
- write to the log.
71
+ The pluginEnvironment method prints selected information about the pluginEnvironment that the plugin is running
72
+ in. It pulls some of this information from the calling plugin and some from the server pluginEnvironment. It
73
+ uses the legacy "indigo.server.log" method to write to the log.
77
74
78
75
:return:
79
76
"""
@@ -98,10 +95,10 @@ def pluginEnvironment(self): # noqa
98
95
# =============================================================================
99
96
def pluginEnvironmentLogger (self ): # noqa
100
97
"""
101
- The pluginEnvironmentLogger method prints selected information about the pluginEnvironment
102
- that the plugin is running in. It pulls some of this information from the calling plugin
103
- and some from the server pluginEnvironment. This method differs from the pluginEnvironment()
104
- method in that it leverages Indigo's logging hooks using the Python Logger framework.
98
+ The pluginEnvironmentLogger method prints selected information about the pluginEnvironment that the plugin is
99
+ running in. It pulls some of this information from the calling plugin and some from the server
100
+ pluginEnvironment. This method differs from the pluginEnvironment() method in that it leverages Indigo's
101
+ logging hooks using the Python Logger framework.
105
102
106
103
:return:
107
104
"""
@@ -128,13 +125,11 @@ def pluginErrorHandler(self, sub_error): # noqa
128
125
"""
129
126
Centralized handling of traceback messages
130
127
131
- Centralized handling of traceback messages formatted for pretty display in the plugin log
132
- file. If sent here, they will not be displayed in the Indigo Events log. Use the following
133
- syntax to send exceptions here::
128
+ Centralized handling of traceback messages formatted for pretty display in the plugin log file. If sent here,
129
+ they will not be displayed in the Indigo Events log. Use the following syntax to send exceptions here:
134
130
135
131
self.pluginErrorHandler(traceback.format_exc())
136
132
137
-
138
133
:param traceback object sub_error:
139
134
:return:
140
135
"""
@@ -150,10 +145,9 @@ def pluginErrorHandler(self, sub_error): # noqa
150
145
# =============================================================================
151
146
def convertDebugLevel (self , debug_val ): # noqa
152
147
"""
153
- The convertDebugLevel method is used to standardize the various implementations of debug
154
- level settings across plugins. Its main purpose is to convert an old string-based setting
155
- to account for older plugin versions. Over time, this method will become obsolete and
156
- should be deprecated.
148
+ The convertDebugLevel method is used to standardize the various implementations of debug level settings across
149
+ plugins. Its main purpose is to convert an old string-based setting to account for older plugin versions. Over
150
+ time, this method will become obsolete and should be deprecated.
157
151
158
152
:param str debug_val:
159
153
:return:
@@ -188,8 +182,8 @@ def deviceList(dev_filter=None): # noqa
188
182
@staticmethod
189
183
def deviceListEnabled (dev_filter = None ): # noqa
190
184
"""
191
- Returns a list of tuples containing Indigo devices for use in config dialogs (etc.) Returns
192
- enabled devices only.
185
+ Returns a list of tuples containing Indigo devices for use in config dialogs (etc.) Returns enabled devices
186
+ only.
193
187
194
188
:param str dev_filter:
195
189
:return: [(ID, "Name"), (ID, "Name")]
@@ -237,8 +231,7 @@ def deviceAndVariableList(): # noqa
237
231
@staticmethod
238
232
def deviceAndVariableListClean (): # noqa
239
233
"""
240
- Returns a list of tuples containing Indigo devices and variables for use in config dialogs
241
- (etc.)
234
+ Returns a list of tuples containing Indigo devices and variables for use in config dialogs (etc.)
242
235
243
236
:return: [(ID, "(D) Name"), (ID, "(V) Name")]
244
237
"""
@@ -255,8 +248,8 @@ def deviceAndVariableListClean(): # noqa
255
248
@staticmethod
256
249
def launchWebPage (launch_url ): # noqa
257
250
"""
258
- The launchWebPage method is used to direct a call to the registered default browser and
259
- open the page referenced by the parameter 'URL'.
251
+ The launchWebPage method is used to direct a call to the registered default browser and open the page
252
+ referenced by the parameter 'URL'.
260
253
261
254
:param str launch_url:
262
255
:return:
@@ -267,8 +260,8 @@ def launchWebPage(launch_url): # noqa
267
260
@staticmethod
268
261
def generatorStateOrValue (dev_id ): # noqa
269
262
"""
270
- The generator_state_or_value() method returns a list to populate the relevant device
271
- states or variable value to populate a menu control.
263
+ The generator_state_or_value() method returns a list to populate the relevant device states or variable value
264
+ to populate a menu control.
272
265
273
266
:param int dev_id:
274
267
:return:
@@ -302,8 +295,7 @@ def audit_server_version(self, min_ver):
302
295
"""
303
296
Audit Indigo Version
304
297
305
- Compare current Indigo version to the minimum version required to successfully run the
306
- plugin.
298
+ Compare current Indigo version to the minimum version required to successfully run the plugin.
307
299
308
300
309
301
:param int min_ver:
@@ -312,9 +304,7 @@ def audit_server_version(self, min_ver):
312
304
313
305
ver = self .plugin .versStrToTuple (indigo .server .version )
314
306
if ver [0 ] < min_ver :
315
- self .plugin .stopPlugin (
316
- f"This plugin requires Indigo version { min_ver } or above." , isError = True
317
- )
307
+ self .plugin .stopPlugin (f"This plugin requires Indigo version { min_ver } or above." , isError = True )
318
308
319
309
self .plugin .logger .debug ("Indigo server version OK." )
320
310
@@ -323,8 +313,8 @@ def audit_os_version(self, min_ver):
323
313
"""
324
314
Audit Operating System Version
325
315
326
- Compare current OS version to the minimum version required to successfully run the plugin.
327
- Thanks to FlyingDiver for improved audit code.
316
+ Compare current OS version to the minimum version required to successfully run the plugin. Thanks to
317
+ FlyingDiver for improved audit code.
328
318
329
319
:param float min_ver:
330
320
:return:
@@ -335,9 +325,7 @@ def audit_os_version(self, min_ver):
335
325
current_ver = tuple (map (int , (str (mac_os ).split ("." )))) # current version. i.e., (11, 4)
336
326
337
327
if current_ver < min_ver :
338
- self .plugin .stopPlugin (
339
- f"The plugin requires macOS version { min_ver } or above." , isError = True
340
- )
328
+ self .plugin .stopPlugin (f"The plugin requires macOS version { min_ver } or above." , isError = True )
341
329
else :
342
330
self .plugin .logger .debug ("macOS version OK." )
343
331
@@ -362,8 +350,8 @@ def __init__(self, plugin):
362
350
# =============================================================================
363
351
def dateFormat (self ): # noqa
364
352
"""
365
- The dateFormat method takes the user configuration preference for date and time display and
366
- converts them to a valid datetime() format specifier.
353
+ The dateFormat method takes the user configuration preference for date and time display and converts them to a
354
+ valid datetime() format specifier.
367
355
368
356
:return:
369
357
"""
@@ -378,8 +366,8 @@ def dateFormat(self): # noqa
378
366
# =============================================================================
379
367
def timeFormat (self ): # noqa
380
368
"""
381
- The timeFormat method takes the user configuration preference for date and time display and
382
- converts them to a valid datetime() format specifier.
369
+ The timeFormat method takes the user configuration preference for date and time display and converts them to a
370
+ valid datetime() format specifier.
383
371
384
372
:return:
385
373
"""
@@ -391,8 +379,7 @@ def timeFormat(self): # noqa
391
379
# =============================================================================
392
380
class evalExpr : # noqa
393
381
"""
394
- The evalExpr method evaluates mathematical expressions that are passed as strings and returns a
395
- numerical result.
382
+ The evalExpr method evaluates mathematical expressions that are passed as strings and returns a numerical result.
396
383
397
384
This code is licensed under an MIT-compatible license.
398
385
credit: jfs @ https://stackoverflow.com/a/9558001/2827397
@@ -434,8 +421,8 @@ def __eval(self, node):
434
421
:return:
435
422
"""
436
423
437
- # See https://stackoverflow.com/q/71353183/2827397 (and the accompanying answer) for an
438
- # explanation of the code inspection warnings thrown by this method.
424
+ # See https://stackoverflow.com/q/71353183/2827397 (and the accompanying answer) for an explanation of the code
425
+ # inspection warnings thrown by this method.
439
426
try :
440
427
if isinstance (node , ast .Num ): # <number>
441
428
value = node .n
@@ -452,11 +439,13 @@ def __eval(self, node):
452
439
453
440
454
441
class DummyClass :
455
-
456
- def Dave (self , at1 = "foo" , at2 = 0 ):
442
+ """
443
+ Dummy class used for testing.
444
+ """
445
+ @staticmethod
446
+ def dave (at1 = "foo" , at2 = 0 ):
457
447
"""
458
- This docstring is loosely formatted to `PEP 287` with a nod towards PyCharm reStructured
459
- Text rendering.
448
+ This docstring is loosely formatted to `PEP 287` with a nod towards PyCharm reStructured Text rendering.
460
449
461
450
:param str at1: This is a string attribute.
462
451
:param int at2: This is an integer attribute.
0 commit comments