Skip to content

Commit c426407

Browse files
committed
swap raise and return
1 parent 98ae744 commit c426407

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

adafruit_portalbase/__init__.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,10 @@ def _fill_text_labels(self, values):
477477

478478
def get_local_time(self, location=None):
479479
"""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()")
482482

483-
raise RuntimeError("network must not be None to use get_local_time()")
483+
return self.network.get_local_time(location=location)
484484

485485
def push_to_io(self, feed_key, data, metadata=None, precision=None):
486486
"""Push data to an adafruit.io feed
@@ -491,23 +491,23 @@ def push_to_io(self, feed_key, data, metadata=None, precision=None):
491491
:param int precision: Optional amount of precision points to send with floating point data
492492
493493
"""
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:
499495
raise RuntimeError("network must not be None to use push_to_io()")
500496

497+
self.network.push_to_io(
498+
feed_key, data, metadata=metadata, precision=precision
499+
)
500+
501501
def get_io_data(self, feed_key):
502502
"""Return all values from the Adafruit IO Feed Data that matches the feed key
503503
504504
:param str feed_key: Name of feed key to receive data from.
505505
506506
"""
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()")
509509

510-
raise RuntimeError("network must not be None to use get_io_data()")
510+
return self.network.get_io_data(feed_key)
511511

512512
def get_io_feed(self, feed_key, detailed=False):
513513
"""Return the Adafruit IO Feed that matches the feed key
@@ -516,21 +516,20 @@ def get_io_feed(self, feed_key, detailed=False):
516516
:param bool detailed: Whether to return additional detailed information
517517
518518
"""
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()")
521521

522-
raise RuntimeError("network must not be None to use get_io_feed()")
522+
return self.network.get_io_feed(feed_key, detailed)
523523

524524
def get_io_group(self, group_key):
525525
"""Return the Adafruit IO Group that matches the group key
526526
527527
:param str group_key: Name of group key to match.
528528
529529
"""
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)
534533

535534
@property
536535
def json_path(self):

0 commit comments

Comments
 (0)