Skip to content

Commit d8c43de

Browse files
committed
black
1 parent 51207f5 commit d8c43de

File tree

5 files changed

+120
-107
lines changed

5 files changed

+120
-107
lines changed

adafruit_ble_eddystone/__init__.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@
3838
__version__ = "0.0.0-auto.0"
3939
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Eddystone.git"
4040

41+
4142
class _EddystoneService:
4243
"""Placeholder service. Not implemented."""
44+
4345
# pylint: disable=too-few-public-methods
44-
uuid = StandardUUID(0xfeaa)
46+
uuid = StandardUUID(0xFEAA)
47+
4548

4649
class _EddystoneFrame(ServiceData):
4750
"""Top level advertising data field that adds the field type to bytearrays set."""
51+
4852
def __init__(self):
4953
super().__init__(_EddystoneService)
5054

@@ -56,11 +60,13 @@ def __get__(self, obj, cls):
5660
def __set__(self, obj, value):
5761
return super().__set__(obj, obj.frame_type + value)
5862

63+
5964
class EddystoneFrameBytes:
6065
"""Extracts and manipulates a byte range from an EddystoneAdvertisement. For library use only.
6166
6267
If length is None, then the byte range must be at the end of the frame.
6368
"""
69+
6470
def __init__(self, *, length=None, offset=0):
6571
self._length = length
6672
self._offset = offset
@@ -69,19 +75,21 @@ def __get__(self, obj, cls):
6975
if obj is None:
7076
return self
7177
if self._length is not None:
72-
return obj.eddystone_frame[self._offset:self._offset+self._length]
73-
return obj.eddystone_frame[self._offset:]
78+
return obj.eddystone_frame[self._offset : self._offset + self._length]
79+
return obj.eddystone_frame[self._offset :]
7480

7581
def __set__(self, obj, value):
7682
if self._length is not None:
7783
if self._length != len(value):
7884
raise ValueError("Value length does not match")
79-
obj.eddystone_frame[self._offset:self._offset+self._length] = value
85+
obj.eddystone_frame[self._offset : self._offset + self._length] = value
8086
else:
81-
obj.eddystone_frame = obj.eddystone_frame[:self._offset] + value
87+
obj.eddystone_frame = obj.eddystone_frame[: self._offset] + value
88+
8289

8390
class EddystoneFrameStruct(EddystoneFrameBytes):
8491
"""Packs and unpacks a single value from a byte range. For library use only."""
92+
8593
def __init__(self, fmt, *, offset=0):
8694
self._format = fmt
8795
super().__init__(offset=offset, length=struct.calcsize(self._format))
@@ -94,6 +102,7 @@ def __get__(self, obj, cls):
94102
def __set__(self, obj, value):
95103
super().__set__(obj, struct.pack(self._format, value))
96104

105+
97106
class EddystoneAdvertisement(Advertisement):
98107
"""Top level Eddystone advertisement that manages frame type. For library use only."""
99108

adafruit_ble_eddystone/uid.py

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class EddystoneUID(EddystoneAdvertisement):
4141
:param bytes namespace_id: namespace component of the id. 6 bytes long
4242
:param int tx_power: TX power at the beacon
4343
"""
44+
4445
prefix = b"\x03\x03\xaa\xfe\x04\x16\xaa\xfe\x00"
4546

4647
tx_power = EddystoneFrameStruct("<B", offset=0)

adafruit_ble_eddystone/url.py

+19-23
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,21 @@
3434
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_Eddystone.git"
3535

3636
# These prefixes are replaced with a single one-byte scheme number.
37-
_URL_SCHEMES = (
38-
b'http://www.',
39-
b'https://www.',
40-
b'http://',
41-
b'https://'
42-
)
37+
_URL_SCHEMES = (b"http://www.", b"https://www.", b"http://", b"https://")
4338

4439
# These common domains are replaced with a single non-printing byte.
4540
# Byte value is 0-6 for these with a '/' suffix.
4641
# Byte value is 7-13 for these without the '/' suffix.
4742
_SUBSTITUTIONS = (
48-
b'.com',
49-
b'.org',
50-
b'.edu'
51-
b'.net',
52-
b'.info',
53-
b'.biz',
54-
b'.gov',
43+
b".com",
44+
b".org",
45+
b".edu" b".net",
46+
b".info",
47+
b".biz",
48+
b".gov",
5549
)
5650

51+
5752
class _EncodedEddystoneUrl(EddystoneFrameBytes):
5853
"""Packs and unpacks an encoded url"""
5954

@@ -66,29 +61,29 @@ def __get__(self, obj, cls):
6661
short_url = _URL_SCHEMES[short_url[0]] + short_url[1:]
6762

6863
for code, subst in enumerate(_SUBSTITUTIONS):
69-
code = bytes(chr(code), 'ascii')
70-
short_url = short_url.replace(code, subst + b'/')
64+
code = bytes(chr(code), "ascii")
65+
short_url = short_url.replace(code, subst + b"/")
7166
for code, subst in enumerate(_SUBSTITUTIONS, 7):
72-
code = bytes(chr(code), 'ascii')
67+
code = bytes(chr(code), "ascii")
7368
short_url = short_url.replace(code, subst)
7469

75-
return str(short_url, 'ascii')
70+
return str(short_url, "ascii")
7671

7772
def __set__(self, obj, url):
7873
short_url = None
79-
url = bytes(url, 'ascii')
74+
url = bytes(url, "ascii")
8075
for idx, prefix in enumerate(_URL_SCHEMES):
8176
if url.startswith(prefix):
82-
short_url = url[len(prefix):]
83-
short_url = bytes(chr(idx), 'ascii') + short_url
77+
short_url = url[len(prefix) :]
78+
short_url = bytes(chr(idx), "ascii") + short_url
8479
break
8580
if not short_url:
8681
raise ValueError("url does not start with one of: ", _URL_SCHEMES)
8782
for code, subst in enumerate(_SUBSTITUTIONS):
88-
code = bytes(chr(code), 'ascii')
89-
short_url = short_url.replace(subst + b'/', code)
83+
code = bytes(chr(code), "ascii")
84+
short_url = short_url.replace(subst + b"/", code)
9085
for code, subst in enumerate(_SUBSTITUTIONS, 7):
91-
code = bytes(chr(code), 'ascii')
86+
code = bytes(chr(code), "ascii")
9287
short_url = short_url.replace(subst, code)
9388

9489
super().__set__(obj, short_url)
@@ -99,6 +94,7 @@ class EddystoneURL(EddystoneAdvertisement):
9994
10095
:param str url: Target url
10196
:param int tx_power: TX power in dBm"""
97+
10298
prefix = b"\x03\x03\xaa\xfe\x04\x16\xaa\xfe\x10"
10399
tx_power = EddystoneFrameStruct("<B", offset=0)
104100
"""TX power in dBm"""

docs/conf.py

+65-47
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
import os
44
import sys
5-
sys.path.insert(0, os.path.abspath('..'))
5+
6+
sys.path.insert(0, os.path.abspath(".."))
67

78
# -- General configuration ------------------------------------------------
89

910
# Add any Sphinx extension module names here, as strings. They can be
1011
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
1112
# ones.
1213
extensions = [
13-
'sphinx.ext.autodoc',
14-
'sphinx.ext.intersphinx',
15-
'sphinx.ext.napoleon',
16-
'sphinx.ext.todo',
14+
"sphinx.ext.autodoc",
15+
"sphinx.ext.intersphinx",
16+
"sphinx.ext.napoleon",
17+
"sphinx.ext.todo",
1718
]
1819

1920
# TODO: Please Read!
@@ -23,29 +24,32 @@
2324
# autodoc_mock_imports = ["digitalio", "busio"]
2425

2526

26-
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
27+
intersphinx_mapping = {
28+
"python": ("https://docs.python.org/3.4", None),
29+
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
30+
}
2731

2832
# Add any paths that contain templates here, relative to this directory.
29-
templates_path = ['_templates']
33+
templates_path = ["_templates"]
3034

31-
source_suffix = '.rst'
35+
source_suffix = ".rst"
3236

3337
# The master toctree document.
34-
master_doc = 'index'
38+
master_doc = "index"
3539

3640
# General information about the project.
37-
project = u'Adafruit BLE_Eddystone Library'
38-
copyright = u'2020 Scott Shawcroft'
39-
author = u'Scott Shawcroft'
41+
project = "Adafruit BLE_Eddystone Library"
42+
copyright = "2020 Scott Shawcroft"
43+
author = "Scott Shawcroft"
4044

4145
# The version info for the project you're documenting, acts as replacement for
4246
# |version| and |release|, also used in various other places throughout the
4347
# built documents.
4448
#
4549
# The short X.Y version.
46-
version = u'1.0'
50+
version = "1.0"
4751
# The full version, including alpha/beta/rc tags.
48-
release = u'1.0'
52+
release = "1.0"
4953

5054
# The language for content autogenerated by Sphinx. Refer to documentation
5155
# for a list of supported languages.
@@ -57,7 +61,7 @@
5761
# List of patterns, relative to source directory, that match files and
5862
# directories to ignore when looking for source files.
5963
# This patterns also effect to html_static_path and html_extra_path
60-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
64+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
6165

6266
# The reST default role (used for this markup: `text`) to use for all
6367
# documents.
@@ -69,7 +73,7 @@
6973
add_function_parentheses = True
7074

7175
# The name of the Pygments (syntax highlighting) style to use.
72-
pygments_style = 'sphinx'
76+
pygments_style = "sphinx"
7377

7478
# If true, `todo` and `todoList` produce output, else they produce nothing.
7579
todo_include_todos = False
@@ -84,68 +88,76 @@
8488
# The theme to use for HTML and HTML Help pages. See the documentation for
8589
# a list of builtin themes.
8690
#
87-
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
91+
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
8892

8993
if not on_rtd: # only import and set the theme if we're building docs locally
9094
try:
9195
import sphinx_rtd_theme
92-
html_theme = 'sphinx_rtd_theme'
93-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']
96+
97+
html_theme = "sphinx_rtd_theme"
98+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
9499
except:
95-
html_theme = 'default'
96-
html_theme_path = ['.']
100+
html_theme = "default"
101+
html_theme_path = ["."]
97102
else:
98-
html_theme_path = ['.']
103+
html_theme_path = ["."]
99104

100105
# Add any paths that contain custom static files (such as style sheets) here,
101106
# relative to this directory. They are copied after the builtin static files,
102107
# so a file named "default.css" will overwrite the builtin "default.css".
103-
html_static_path = ['_static']
108+
html_static_path = ["_static"]
104109

105110
# The name of an image file (relative to this directory) to use as a favicon of
106111
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
107112
# pixels large.
108113
#
109-
html_favicon = '_static/favicon.ico'
114+
html_favicon = "_static/favicon.ico"
110115

111116
# Output file base name for HTML help builder.
112-
htmlhelp_basename = 'AdafruitBle_eddystoneLibrarydoc'
117+
htmlhelp_basename = "AdafruitBle_eddystoneLibrarydoc"
113118

114119
# -- Options for LaTeX output ---------------------------------------------
115120

116121
latex_elements = {
117-
# The paper size ('letterpaper' or 'a4paper').
118-
#
119-
# 'papersize': 'letterpaper',
120-
121-
# The font size ('10pt', '11pt' or '12pt').
122-
#
123-
# 'pointsize': '10pt',
124-
125-
# Additional stuff for the LaTeX preamble.
126-
#
127-
# 'preamble': '',
128-
129-
# Latex figure (float) alignment
130-
#
131-
# 'figure_align': 'htbp',
122+
# The paper size ('letterpaper' or 'a4paper').
123+
#
124+
# 'papersize': 'letterpaper',
125+
# The font size ('10pt', '11pt' or '12pt').
126+
#
127+
# 'pointsize': '10pt',
128+
# Additional stuff for the LaTeX preamble.
129+
#
130+
# 'preamble': '',
131+
# Latex figure (float) alignment
132+
#
133+
# 'figure_align': 'htbp',
132134
}
133135

134136
# Grouping the document tree into LaTeX files. List of tuples
135137
# (source start file, target name, title,
136138
# author, documentclass [howto, manual, or own class]).
137139
latex_documents = [
138-
(master_doc, 'AdafruitBLE_EddystoneLibrary.tex', u'AdafruitBLE_Eddystone Library Documentation',
139-
author, 'manual'),
140+
(
141+
master_doc,
142+
"AdafruitBLE_EddystoneLibrary.tex",
143+
"AdafruitBLE_Eddystone Library Documentation",
144+
author,
145+
"manual",
146+
),
140147
]
141148

142149
# -- Options for manual page output ---------------------------------------
143150

144151
# One entry per manual page. List of tuples
145152
# (source start file, name, description, authors, manual section).
146153
man_pages = [
147-
(master_doc, 'AdafruitBLE_Eddystonelibrary', u'Adafruit BLE_Eddystone Library Documentation',
148-
[author], 1)
154+
(
155+
master_doc,
156+
"AdafruitBLE_Eddystonelibrary",
157+
"Adafruit BLE_Eddystone Library Documentation",
158+
[author],
159+
1,
160+
)
149161
]
150162

151163
# -- Options for Texinfo output -------------------------------------------
@@ -154,7 +166,13 @@
154166
# (source start file, target name, title, author,
155167
# dir menu entry, description, category)
156168
texinfo_documents = [
157-
(master_doc, 'AdafruitBLE_EddystoneLibrary', u'Adafruit BLE_Eddystone Library Documentation',
158-
author, 'AdafruitBLE_EddystoneLibrary', 'One line description of project.',
159-
'Miscellaneous'),
169+
(
170+
master_doc,
171+
"AdafruitBLE_EddystoneLibrary",
172+
"Adafruit BLE_Eddystone Library Documentation",
173+
author,
174+
"AdafruitBLE_EddystoneLibrary",
175+
"One line description of project.",
176+
"Miscellaneous",
177+
),
160178
]

0 commit comments

Comments
 (0)