Skip to content

Commit 659f539

Browse files
authored
format code via yapf (ev3dev#716)
1 parent 3a19ff7 commit 659f539

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+835
-844
lines changed

.yapf.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[style]
2+
based_on_style = pep8
3+
COLUMN_LIMIT = 120

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ install:
1616

1717
micropython-install: ${MPYS}
1818
cp -R $(OUT)/* /usr/lib/micropython/
19+
20+
clean:
21+
find . -name __pycache__ | xargs rm -rf
22+
find . -name *.pyc | xargs rm -rf
23+
24+
format:
25+
yapf --style .yapf.cfg --in-place --exclude tests/fake-sys/ --recursive .

docs/conf.py

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,16 @@
124124
# If true, `todo` and `todoList` produce output, else they produce nothing.
125125
todo_include_todos = False
126126

127-
128127
# -- Options for HTML output ----------------------------------------------
129128

130129
# The theme to use for HTML and HTML Help pages. See the documentation for
131130
# a list of builtin themes.
132131
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
133132
html_theme = 'bootstrap'
134133
html_theme_options = {
135-
'bootswatch_theme': 'yeti',
136-
'navbar_links' : [
137-
("GitHub", "https://github.com/ev3dev/ev3dev-lang-python", True)
138-
]
139-
}
134+
'bootswatch_theme': 'yeti',
135+
'navbar_links': [("GitHub", "https://github.com/ev3dev/ev3dev-lang-python", True)]
136+
}
140137

141138
# Theme options are theme-specific and customize the look and feel of a theme
142139
# further. For a list of options available for each theme, see the
@@ -233,25 +230,24 @@
233230
# -- Options for LaTeX output ---------------------------------------------
234231

235232
latex_elements = {
236-
# The paper size ('letterpaper' or 'a4paper').
237-
#'papersize': 'letterpaper',
233+
# The paper size ('letterpaper' or 'a4paper').
234+
#'papersize': 'letterpaper',
238235

239-
# The font size ('10pt', '11pt' or '12pt').
240-
#'pointsize': '10pt',
236+
# The font size ('10pt', '11pt' or '12pt').
237+
#'pointsize': '10pt',
241238

242-
# Additional stuff for the LaTeX preamble.
243-
#'preamble': '',
239+
# Additional stuff for the LaTeX preamble.
240+
#'preamble': '',
244241

245-
# Latex figure (float) alignment
246-
#'figure_align': 'htbp',
242+
# Latex figure (float) alignment
243+
#'figure_align': 'htbp',
247244
}
248245

249246
# Grouping the document tree into LaTeX files. List of tuples
250247
# (source start file, target name, title,
251248
# author, documentclass [howto, manual, or own class]).
252249
latex_documents = [
253-
(master_doc, 'python-ev3dev.tex', 'python-ev3dev Documentation',
254-
'Ralph Hempel et al', 'manual'),
250+
(master_doc, 'python-ev3dev.tex', 'python-ev3dev Documentation', 'Ralph Hempel et al', 'manual'),
255251
]
256252

257253
# The name of an image file (relative to this directory) to place at the top of
@@ -274,29 +270,23 @@
274270
# If false, no module index is generated.
275271
#latex_domain_indices = True
276272

277-
278273
# -- Options for manual page output ---------------------------------------
279274

280275
# One entry per manual page. List of tuples
281276
# (source start file, name, description, authors, manual section).
282-
man_pages = [
283-
(master_doc, 'python-ev3dev', 'python-ev3dev Documentation',
284-
[author], 1)
285-
]
277+
man_pages = [(master_doc, 'python-ev3dev', 'python-ev3dev Documentation', [author], 1)]
286278

287279
# If true, show URL addresses after external links.
288280
#man_show_urls = False
289281

290-
291282
# -- Options for Texinfo output -------------------------------------------
292283

293284
# Grouping the document tree into Texinfo files. List of tuples
294285
# (source start file, target name, title, author,
295286
# dir menu entry, description, category)
296287
texinfo_documents = [
297-
(master_doc, 'python-ev3dev', 'python-ev3dev Documentation',
298-
author, 'python-ev3dev', 'One line description of project.',
299-
'Miscellaneous'),
288+
(master_doc, 'python-ev3dev', 'python-ev3dev Documentation', author, 'python-ev3dev',
289+
'One line description of project.', 'Miscellaneous'),
300290
]
301291

302292
# Documents to append as an appendix to all manuals.
@@ -315,20 +305,13 @@
315305

316306
suppress_warnings = ['image.nonlocal_uri']
317307

318-
nitpick_ignore = [
319-
('py:class', 'ev3dev2.display.FbMem'),
320-
('py:class', 'ev3dev2.button.ButtonBase'),
321-
('py:class', 'int'),
322-
('py:class', 'float'),
323-
('py:class', 'string'),
324-
('py:class', 'iterable'),
325-
('py:class', 'tuple'),
326-
('py:class', 'list'),
327-
('py:exc', 'ValueError')
328-
]
308+
nitpick_ignore = [('py:class', 'ev3dev2.display.FbMem'), ('py:class', 'ev3dev2.button.ButtonBase'), ('py:class', 'int'),
309+
('py:class', 'float'), ('py:class', 'string'), ('py:class', 'iterable'), ('py:class', 'tuple'),
310+
('py:class', 'list'), ('py:exc', 'ValueError')]
311+
329312

330313
def setup(app):
331314
app.add_config_value('recommonmark_config', {
332-
'enable_eval_rst': True,
333-
}, True)
315+
'enable_eval_rst': True,
316+
}, True)
334317
app.add_transform(AutoStructify)

docs/sphinx3-build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ if __name__ == '__main__':
1515
sys.exit(make_main(sys.argv))
1616
else:
1717
sys.exit(main(sys.argv))
18-

ev3dev2/__init__.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,21 @@
2525

2626
import sys
2727

28-
if sys.version_info < (3,4):
28+
if sys.version_info < (3, 4):
2929
raise SystemError('Must be using Python 3.4 or higher')
3030

31+
3132
def is_micropython():
3233
return sys.implementation.name == "micropython"
3334

35+
3436
def chain_exception(exception, cause):
3537
if is_micropython():
3638
raise exception
3739
else:
3840
raise exception from cause
3941

42+
4043
try:
4144
# if we are in a released build, there will be an auto-generated "version"
4245
# module
@@ -52,6 +55,7 @@ def chain_exception(exception, cause):
5255
import errno
5356
from os.path import abspath
5457

58+
5559
def get_current_platform():
5660
"""
5761
Look in /sys/class/board-info/ to determine the platform type.
@@ -139,12 +143,15 @@ def matches(attribute, pattern):
139143
def library_load_warning_message(library_name, dependent_class):
140144
return 'Import warning: Failed to import "{}". {} will be unusable!'.format(library_name, dependent_class)
141145

146+
142147
class DeviceNotFound(Exception):
143148
pass
144149

150+
145151
# -----------------------------------------------------------------------------
146152
# Define the base class from which all other ev3dev classes are defined.
147153

154+
148155
class Device(object):
149156
"""The ev3dev device base class"""
150157

@@ -214,7 +221,7 @@ def __str__(self):
214221
return "%s(%s)" % (self.__class__.__name__, self.kwargs.get('address'))
215222
else:
216223
return self.__class__.__name__
217-
224+
218225
def __repr__(self):
219226
return self.__str__()
220227

@@ -241,7 +248,7 @@ def _get_attribute(self, attribute, name):
241248
"""Device attribute getter"""
242249
try:
243250
if attribute is None:
244-
attribute = self._attribute_file_open( name )
251+
attribute = self._attribute_file_open(name)
245252
else:
246253
attribute.seek(0)
247254
return attribute, attribute.read().strip().decode()
@@ -252,7 +259,7 @@ def _set_attribute(self, attribute, name, value):
252259
"""Device attribute setter"""
253260
try:
254261
if attribute is None:
255-
attribute = self._attribute_file_open( name )
262+
attribute = self._attribute_file_open(name)
256263
else:
257264
attribute.seek(0)
258265

@@ -275,11 +282,13 @@ def _raise_friendly_access_error(self, driver_error, attribute, value):
275282
try:
276283
max_speed = self.max_speed
277284
except (AttributeError, Exception):
278-
chain_exception(ValueError("The given speed value {} was out of range".format(value)),
279-
driver_error)
285+
chain_exception(ValueError("The given speed value {} was out of range".format(value)), driver_error)
280286
else:
281-
chain_exception(ValueError("The given speed value {} was out of range. Max speed: +/-{}".format(value, max_speed)), driver_error)
282-
chain_exception(ValueError("One or more arguments were out of range or invalid, value {}".format(value)), driver_error)
287+
chain_exception(
288+
ValueError("The given speed value {} was out of range. Max speed: +/-{}".format(
289+
value, max_speed)), driver_error)
290+
chain_exception(ValueError("One or more arguments were out of range or invalid, value {}".format(value)),
291+
driver_error)
283292
elif driver_errorno == errno.ENODEV or driver_errorno == errno.ENOENT:
284293
# We will assume that a file-not-found error is the result of a disconnected device
285294
# rather than a library error. If that isn't the case, at a minimum the underlying
@@ -369,5 +378,4 @@ def list_devices(class_name, name_pattern, **kwargs):
369378
"""
370379
classpath = abspath(Device.DEVICE_ROOT_PATH + '/' + class_name)
371380

372-
return (Device(class_name, name, name_exact=True)
373-
for name in list_device_names(classpath, name_pattern, **kwargs))
381+
return (Device(class_name, name, name_exact=True) for name in list_device_names(classpath, name_pattern, **kwargs))

ev3dev2/_platform/brickpi.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323
# -----------------------------------------------------------------------------
24-
2524
"""
2625
An assortment of classes modeling specific features of the BrickPi.
2726
"""
@@ -46,11 +45,11 @@
4645
LEDS['blue_led2'] = 'led2:blue:brick-status'
4746

4847
LED_GROUPS = OrderedDict()
49-
LED_GROUPS['LED1'] = ('blue_led1',)
50-
LED_GROUPS['LED2'] = ('blue_led2',)
48+
LED_GROUPS['LED1'] = ('blue_led1', )
49+
LED_GROUPS['LED2'] = ('blue_led2', )
5150

5251
LED_COLORS = OrderedDict()
53-
LED_COLORS['BLACK'] = (0,)
54-
LED_COLORS['BLUE'] = (1,)
52+
LED_COLORS['BLACK'] = (0, )
53+
LED_COLORS['BLUE'] = (1, )
5554

5655
LED_DEFAULT_COLOR = 'BLUE'

ev3dev2/_platform/brickpi3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
LEDS['amber_led'] = 'led1:amber:brick-status'
4949

5050
LED_GROUPS = OrderedDict()
51-
LED_GROUPS['LED'] = ('amber_led',)
51+
LED_GROUPS['LED'] = ('amber_led', )
5252

5353
LED_COLORS = OrderedDict()
54-
LED_COLORS['BLACK'] = (0,)
55-
LED_COLORS['AMBER'] = (1,)
54+
LED_COLORS['BLACK'] = (0, )
55+
LED_COLORS['AMBER'] = (1, )
5656

5757
LED_DEFAULT_COLOR = 'AMBER'

ev3dev2/_platform/ev3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2222
# THE SOFTWARE.
2323
# -----------------------------------------------------------------------------
24-
2524
"""
2625
An assortment of classes modeling specific features of the EV3 brick.
2726
"""

ev3dev2/_platform/evb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""
32
An assortment of classes modeling specific features of the EVB.
43
"""

ev3dev2/_platform/fake.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
OUTPUT_A = 'outA'
32
OUTPUT_B = 'outB'
43
OUTPUT_C = 'outC'

0 commit comments

Comments
 (0)