Skip to content

Commit

Permalink
Apply PEP8
Browse files Browse the repository at this point in the history
"Surround top-level function and class definitions with two blank
lines."

https://www.python.org/dev/peps/pep-0008/#blank-lines
  • Loading branch information
codestruct committed Apr 21, 2018
1 parent 0a81232 commit 32c84aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nxt/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
class BrickNotFoundError(Exception):
pass


class NoBackendError(Exception):
pass


class Method():
"""Used to indicate which comm backends should be tried by find_bricks/
find_one_brick. Any or all can be selected."""
Expand All @@ -31,6 +33,7 @@ def __init__(self, usb=True, bluetooth=True, device=False):
self.bluetooth = bluetooth
self.device = device


def find_bricks(host=None, name=None, silent=False, method=Method()):
"""Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""
methods_available = 0
Expand Down Expand Up @@ -73,6 +76,7 @@ def find_bricks(host=None, name=None, silent=False, method=Method()):
if methods_available == 0:
raise NoBackendError("No selected backends are available! Did you install the comm modules?")


def find_one_brick(host=None, name=None, silent=False, strict=None, debug=False, method=None, confpath=None):
"""Use to find one brick. The host and name args limit the search to
a given MAC or brick name. Set silent to True to stop nxt-python from
Expand Down Expand Up @@ -152,16 +156,19 @@ def find_one_brick(host=None, name=None, silent=False, strict=None, debug=False,
try the 'nxt_test' script located in /bin or ~/.local/bin""")
raise BrickNotFoundError


def server_brick(host, port = 2727):
from . import ipsock
sock = ipsock.IpSock(host, port)
return sock.connect()


def device_brick(filename):
from . import devsock
sock = devsock.find_bricks(filename=filename)
return sock.connect()


def read_config(confpath=None, debug=False):
conf = configparser.RawConfigParser({'host': None, 'name': None, 'strict': True, 'method': ''})
if not confpath: confpath = os.path.expanduser('~/.nxt-python')
Expand All @@ -171,6 +178,7 @@ def read_config(confpath=None, debug=False):
conf.add_section('Brick')
return conf


def make_config(confpath=None):
conf = configparser.RawConfigParser()
if not confpath: confpath = os.path.expanduser('~/.nxt-python')
Expand Down

0 comments on commit 32c84aa

Please sign in to comment.