Skip to content

Ran black, updated to pylint 2.x #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
Expand Down
206 changes: 111 additions & 95 deletions adafruit_avrprog.py

Large diffs are not rendered by default.

110 changes: 64 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,51 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- General configuration ------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
]

# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["digitalio"]

intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'Adafruit AVRprog Library'
copyright = u'2017 ladyada'
author = u'ladyada'
project = u"Adafruit AVRprog Library"
copyright = u"2017 ladyada"
author = u"ladyada"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'1.0'
version = u"1.0"
# The full version, including alpha/beta/rc tags.
release = u'1.0'
release = u"1.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -54,7 +58,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -66,7 +70,7 @@
add_function_parentheses = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

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

if not on_rtd: # only import and set the theme if we're building docs locally
try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.']

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except:
html_theme = 'default'
html_theme_path = ['.']
html_theme = "default"
html_theme_path = ["."]
else:
html_theme_path = ['.']
html_theme_path = ["."]

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

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

# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitAvrprogLibrarydoc'
htmlhelp_basename = "AdafruitAvrprogLibrarydoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'AdafruitAVRprogLibrary.tex', u'AdafruitAVRprog Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitAVRprogLibrary.tex",
u"AdafruitAVRprog Library Documentation",
author,
"manual",
),
]

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'AdafruitAVRproglibrary', u'Adafruit AVRprog Library Documentation',
[author], 1)
(
master_doc,
"AdafruitAVRproglibrary",
u"Adafruit AVRprog Library Documentation",
[author],
1,
)
]

# -- Options for Texinfo output -------------------------------------------
Expand All @@ -150,7 +162,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitAVRprogLibrary', u'Adafruit AVRprog Library Documentation',
author, 'AdafruitAVRprogLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitAVRprogLibrary",
u"Adafruit AVRprog Library Documentation",
author,
"AdafruitAVRprogLibrary",
"One line description of project.",
"Miscellaneous",
),
]
27 changes: 17 additions & 10 deletions examples/avrprog_program_mega2560.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,43 @@
# http://svn.savannah.nongnu.org/viewvc/*checkout*/avrdude/trunk/avrdude/avrdude.conf.in
# You can also use the predefined values in AVRprog.Boards
atmega2560 = {
'name': "ATmega2560",
'sig': [0x1E, 0x98, 0x01],
'flash_size': 262144,
'page_size': 256,
'fuse_mask': (0xFF, 0xFF, 0x07, 0x3F)
"name": "ATmega2560",
"sig": [0x1E, 0x98, 0x01],
"flash_size": 262144,
"page_size": 256,
"fuse_mask": (0xFF, 0xFF, 0x07, 0x3F),
}


def error(err):
""" Helper to print out errors for us and then halt """
print("ERROR: "+err)
print("ERROR: " + err)
avrprog.end()
while True:
pass

while input("Ready to GO, type 'G' here to start> ") != 'G':

while input("Ready to GO, type 'G' here to start> ") != "G":
pass

if not avrprog.verify_sig(atmega2560, verbose=True):
error("Signature read failure")
print("Found", atmega2560['name'])
print("Found", atmega2560["name"])

# Since we are unsetting the lock fuse, an erase is required!
avrprog.erase_chip()

avrprog.write_fuses(atmega2560, low=0xFF, high=0xD8, ext=0x05, lock=0x3F)
if not avrprog.verify_fuses(atmega2560, low=0xFF, high=0xD8, ext=0x05, lock=0x3F):
error("Failure programming fuses: "+str([hex(i) for i in avrprog.read_fuses(atmega2560)]))
error(
"Failure programming fuses: "
+ str([hex(i) for i in avrprog.read_fuses(atmega2560)])
)

print("Programming flash from file")
avrprog.program_file(atmega2560, "stk500boot_v2_mega2560.hex", verbose=True, verify=True)
avrprog.program_file(
atmega2560, "stk500boot_v2_mega2560.hex", verbose=True, verify=True
)

avrprog.write_fuses(atmega2560, lock=0x0F)
if not avrprog.verify_fuses(atmega2560, lock=0x0F):
Expand Down
8 changes: 5 additions & 3 deletions examples/avrprog_program_tiny13a.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@
# Each chip has to have a definition so the script knows how to find it
attiny13 = avrprog.Boards.ATtiny13a


def error(err):
""" Helper to print out errors for us and then halt """
print("ERROR: "+err)
print("ERROR: " + err)
avrprog.end()
while True:
pass

while input("Ready to GO, type 'G' here to start> ") != 'G':

while input("Ready to GO, type 'G' here to start> ") != "G":
pass

if not avrprog.verify_sig(attiny13, verbose=True):
error("Signature read failure")
print("Found", attiny13['name'])
print("Found", attiny13["name"])

avrprog.write_fuses(attiny13, low=0x7A, high=0xFF)
if not avrprog.verify_fuses(attiny13, low=0x7A, high=0xFF):
Expand Down
8 changes: 5 additions & 3 deletions examples/avrprog_program_trinket85.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@
# Each chip has to have a definition so the script knows how to find it
attiny85 = avrprog.Boards.ATtiny85


def error(err):
""" Helper to print out errors for us and then halt """
print("ERROR: "+err)
print("ERROR: " + err)
avrprog.end()
while True:
pass

while input("Ready to GO, type 'G' here to start> ") != 'G':

while input("Ready to GO, type 'G' here to start> ") != "G":
pass

if not avrprog.verify_sig(attiny85, verbose=True):
error("Signature read failure")
print("Found", attiny85['name'])
print("Found", attiny85["name"])

avrprog.write_fuses(attiny85, low=0xF1, high=0xD5, ext=0x06, lock=0x3F)
if not avrprog.verify_fuses(attiny85, low=0xF1, high=0xD5, ext=0x06, lock=0x3F):
Expand Down
19 changes: 12 additions & 7 deletions examples/avrprog_program_uno328.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,39 @@
avrprog = adafruit_avrprog.AVRprog()
avrprog.init(spi, board.D5)

#pylint: disable-msg=no-member
# pylint: disable-msg=no-member
# we can generate an 6 MHz clock for driving bare chips too!
clock_pwm = pulseio.PWMOut(board.D9, frequency=6000000, duty_cycle=65536//2)
#pylint: enable-msg=no-member
clock_pwm = pulseio.PWMOut(board.D9, frequency=6000000, duty_cycle=65536 // 2)
# pylint: enable-msg=no-member

# Each chip has to have a definition so the script knows how to find it
atmega328p = avrprog.Boards.ATmega328p


def error(err):
""" Helper to print out errors for us and then halt """
print("ERROR: "+err)
print("ERROR: " + err)
avrprog.end()
while True:
pass

while input("Ready to GO, type 'G' here to start> ") != 'G':

while input("Ready to GO, type 'G' here to start> ") != "G":
pass

if not avrprog.verify_sig(atmega328p, verbose=True):
error("Signature read failure")
print("Found", atmega328p['name'])
print("Found", atmega328p["name"])

# Since we are unsetting the lock fuse, an erase is required!
avrprog.erase_chip()

avrprog.write_fuses(atmega328p, low=0xFF, high=0xDE, ext=0x05, lock=0x3F)
if not avrprog.verify_fuses(atmega328p, low=0xFF, high=0xDE, ext=0x05, lock=0x3F):
error("Failure programming fuses: "+str([hex(i) for i in avrprog.read_fuses(atmega328p)]))
error(
"Failure programming fuses: "
+ str([hex(i) for i in avrprog.read_fuses(atmega328p)])
)

print("Programming flash from file")
avrprog.program_file(atmega328p, "optiboot_atmega328.hex", verbose=True, verify=True)
Expand Down
6 changes: 3 additions & 3 deletions examples/avrprog_read_signature_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
avrprog = adafruit_avrprog.AVRprog()
avrprog.init(spi, board.D5)

#pylint: disable-msg=no-member
# pylint: disable-msg=no-member
# we can generate an 6 MHz clock for driving bare chips too!
clock_pwm = pulseio.PWMOut(board.D9, frequency=6000000, duty_cycle=65536//2)
#pylint: enable-msg=no-member
clock_pwm = pulseio.PWMOut(board.D9, frequency=6000000, duty_cycle=65536 // 2)
# pylint: enable-msg=no-member

avrprog.begin()
print("Signature bytes: ", [hex(i) for i in avrprog.read_signature()])
Expand Down
Loading