2424__copyright__ = "Copyright 2017-2022 DaveL17"
2525__license__ = "MIT"
2626__title__ = "DLFramework"
27- __version__ = "0.1.04 "
27+ __version__ = "0.1.05 "
2828
2929# supported operators for eval expressions
3030OPERATORS = {
@@ -63,17 +63,14 @@ def __init__(self, plugin):
6363 self .pluginPrefs = plugin .pluginPrefs
6464
6565 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' ))
6967
7068 # =============================================================================
7169 def pluginEnvironment (self ): # noqa
7270 """
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.
7774
7875 :return:
7976 """
@@ -98,10 +95,10 @@ def pluginEnvironment(self): # noqa
9895 # =============================================================================
9996 def pluginEnvironmentLogger (self ): # noqa
10097 """
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.
105102
106103 :return:
107104 """
@@ -128,13 +125,11 @@ def pluginErrorHandler(self, sub_error): # noqa
128125 """
129126 Centralized handling of traceback messages
130127
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:
134130
135131 self.pluginErrorHandler(traceback.format_exc())
136132
137-
138133 :param traceback object sub_error:
139134 :return:
140135 """
@@ -150,10 +145,9 @@ def pluginErrorHandler(self, sub_error): # noqa
150145 # =============================================================================
151146 def convertDebugLevel (self , debug_val ): # noqa
152147 """
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.
157151
158152 :param str debug_val:
159153 :return:
@@ -188,8 +182,8 @@ def deviceList(dev_filter=None): # noqa
188182 @staticmethod
189183 def deviceListEnabled (dev_filter = None ): # noqa
190184 """
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.
193187
194188 :param str dev_filter:
195189 :return: [(ID, "Name"), (ID, "Name")]
@@ -237,8 +231,7 @@ def deviceAndVariableList(): # noqa
237231 @staticmethod
238232 def deviceAndVariableListClean (): # noqa
239233 """
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.)
242235
243236 :return: [(ID, "(D) Name"), (ID, "(V) Name")]
244237 """
@@ -255,8 +248,8 @@ def deviceAndVariableListClean(): # noqa
255248 @staticmethod
256249 def launchWebPage (launch_url ): # noqa
257250 """
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'.
260253
261254 :param str launch_url:
262255 :return:
@@ -267,8 +260,8 @@ def launchWebPage(launch_url): # noqa
267260 @staticmethod
268261 def generatorStateOrValue (dev_id ): # noqa
269262 """
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.
272265
273266 :param int dev_id:
274267 :return:
@@ -302,8 +295,7 @@ def audit_server_version(self, min_ver):
302295 """
303296 Audit Indigo Version
304297
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.
307299
308300
309301 :param int min_ver:
@@ -312,9 +304,7 @@ def audit_server_version(self, min_ver):
312304
313305 ver = self .plugin .versStrToTuple (indigo .server .version )
314306 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 )
318308
319309 self .plugin .logger .debug ("Indigo server version OK." )
320310
@@ -323,8 +313,8 @@ def audit_os_version(self, min_ver):
323313 """
324314 Audit Operating System Version
325315
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.
328318
329319 :param float min_ver:
330320 :return:
@@ -335,9 +325,7 @@ def audit_os_version(self, min_ver):
335325 current_ver = tuple (map (int , (str (mac_os ).split ("." )))) # current version. i.e., (11, 4)
336326
337327 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 )
341329 else :
342330 self .plugin .logger .debug ("macOS version OK." )
343331
@@ -362,8 +350,8 @@ def __init__(self, plugin):
362350 # =============================================================================
363351 def dateFormat (self ): # noqa
364352 """
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.
367355
368356 :return:
369357 """
@@ -378,8 +366,8 @@ def dateFormat(self): # noqa
378366 # =============================================================================
379367 def timeFormat (self ): # noqa
380368 """
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.
383371
384372 :return:
385373 """
@@ -391,8 +379,7 @@ def timeFormat(self): # noqa
391379# =============================================================================
392380class evalExpr : # noqa
393381 """
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.
396383
397384 This code is licensed under an MIT-compatible license.
398385 credit: jfs @ https://stackoverflow.com/a/9558001/2827397
@@ -434,8 +421,8 @@ def __eval(self, node):
434421 :return:
435422 """
436423
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.
439426 try :
440427 if isinstance (node , ast .Num ): # <number>
441428 value = node .n
@@ -452,11 +439,13 @@ def __eval(self, node):
452439
453440
454441class 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 ):
457447 """
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.
460449
461450 :param str at1: This is a string attribute.
462451 :param int at2: This is an integer attribute.
0 commit comments