@@ -477,10 +477,10 @@ def _fill_text_labels(self, values):
477
477
478
478
def get_local_time (self , location = None ):
479
479
"""Accessor function for get_local_time()"""
480
- if self .network is not None :
481
- return self . network . get_local_time (location = location )
480
+ if self .network is None :
481
+ raise RuntimeError ( " network must not be None to use get_local_time()" )
482
482
483
- raise RuntimeError ( " network must not be None to use get_local_time()" )
483
+ return self . network . get_local_time (location = location )
484
484
485
485
def push_to_io (self , feed_key , data , metadata = None , precision = None ):
486
486
"""Push data to an adafruit.io feed
@@ -491,23 +491,23 @@ def push_to_io(self, feed_key, data, metadata=None, precision=None):
491
491
:param int precision: Optional amount of precision points to send with floating point data
492
492
493
493
"""
494
- if self .network is not None :
495
- self .network .push_to_io (
496
- feed_key , data , metadata = metadata , precision = precision
497
- )
498
- else :
494
+ if self .network is None :
499
495
raise RuntimeError ("network must not be None to use push_to_io()" )
500
496
497
+ self .network .push_to_io (
498
+ feed_key , data , metadata = metadata , precision = precision
499
+ )
500
+
501
501
def get_io_data (self , feed_key ):
502
502
"""Return all values from the Adafruit IO Feed Data that matches the feed key
503
503
504
504
:param str feed_key: Name of feed key to receive data from.
505
505
506
506
"""
507
- if self .network is not None :
508
- return self . network . get_io_data (feed_key )
507
+ if self .network is None :
508
+ raise RuntimeError ( " network must not be None to use get_io_data()" )
509
509
510
- raise RuntimeError ( " network must not be None to use get_io_data()" )
510
+ return self . network . get_io_data (feed_key )
511
511
512
512
def get_io_feed (self , feed_key , detailed = False ):
513
513
"""Return the Adafruit IO Feed that matches the feed key
@@ -516,21 +516,20 @@ def get_io_feed(self, feed_key, detailed=False):
516
516
:param bool detailed: Whether to return additional detailed information
517
517
518
518
"""
519
- if self .network is not None :
520
- return self . network . get_io_feed (feed_key , detailed )
519
+ if self .network is None :
520
+ raise RuntimeError ( " network must not be None to use get_io_feed()" )
521
521
522
- raise RuntimeError ( " network must not be None to use get_io_feed()" )
522
+ return self . network . get_io_feed (feed_key , detailed )
523
523
524
524
def get_io_group (self , group_key ):
525
525
"""Return the Adafruit IO Group that matches the group key
526
526
527
527
:param str group_key: Name of group key to match.
528
528
529
529
"""
530
- if self .network is not None :
531
- return self .network .get_io_group (group_key )
532
-
533
- raise RuntimeError ("network must not be None to use get_io_group()" )
530
+ if self .network is None :
531
+ raise RuntimeError ("network must not be None to use get_io_group()" )
532
+ return self .network .get_io_group (group_key )
534
533
535
534
@property
536
535
def json_path (self ):
0 commit comments