Ran black, updated to pylint 2.x
This commit is contained in:
parent
d1376b1901
commit
5b86bae2cd
6 changed files with 141 additions and 110 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -119,7 +119,8 @@ spelling-store-unknown-words=no
|
|||
[MISCELLANEOUS]
|
||||
|
||||
# List of note tags to take in consideration, separated by a comma.
|
||||
notes=FIXME,XXX,TODO
|
||||
# notes=FIXME,XXX,TODO
|
||||
notes=FIXME,XXX
|
||||
|
||||
|
||||
[TYPECHECK]
|
||||
|
|
|
|||
|
|
@ -73,13 +73,15 @@ DRIVE_MODE_250MS = const(0x04)
|
|||
_HW_ID_CODE = const(0x81)
|
||||
_REF_RESISTOR = const(100000)
|
||||
|
||||
|
||||
class CCS811:
|
||||
"""CCS811 gas sensor driver.
|
||||
|
||||
:param ~busio.I2C i2c: The I2C bus.
|
||||
:param int addr: The I2C address of the CCS811.
|
||||
"""
|
||||
#set up the registers
|
||||
|
||||
# set up the registers
|
||||
error = i2c_bit.ROBit(0x00, 0)
|
||||
"""True when an error has occured."""
|
||||
data_ready = i2c_bit.ROBit(0x00, 3)
|
||||
|
|
@ -99,32 +101,38 @@ class CCS811:
|
|||
def __init__(self, i2c_bus, address=0x5A):
|
||||
self.i2c_device = I2CDevice(i2c_bus, address)
|
||||
|
||||
#check that the HW id is correct
|
||||
# check that the HW id is correct
|
||||
if self.hw_id != _HW_ID_CODE:
|
||||
raise RuntimeError("Device ID returned is not correct! Please check your wiring.")
|
||||
raise RuntimeError(
|
||||
"Device ID returned is not correct! Please check your wiring."
|
||||
)
|
||||
|
||||
#try to start the app
|
||||
# try to start the app
|
||||
buf = bytearray(1)
|
||||
buf[0] = 0xF4
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(buf, end=1)
|
||||
time.sleep(.1)
|
||||
time.sleep(0.1)
|
||||
|
||||
#make sure there are no errors and we have entered application mode
|
||||
# make sure there are no errors and we have entered application mode
|
||||
if self.error:
|
||||
raise RuntimeError("Device returned a error! Try removing and reapplying power to "
|
||||
"the device and running the code again.")
|
||||
raise RuntimeError(
|
||||
"Device returned a error! Try removing and reapplying power to "
|
||||
"the device and running the code again."
|
||||
)
|
||||
if not self.fw_mode:
|
||||
raise RuntimeError("Device did not enter application mode! If you got here, there may "
|
||||
"be a problem with the firmware on your sensor.")
|
||||
raise RuntimeError(
|
||||
"Device did not enter application mode! If you got here, there may "
|
||||
"be a problem with the firmware on your sensor."
|
||||
)
|
||||
|
||||
self.interrupt_enabled = False
|
||||
|
||||
#default to read every second
|
||||
# default to read every second
|
||||
self.drive_mode = DRIVE_MODE_1SEC
|
||||
|
||||
self._eco2 = None # pylint: disable=invalid-name
|
||||
self._tvoc = None # pylint: disable=invalid-name
|
||||
self._eco2 = None # pylint: disable=invalid-name
|
||||
self._tvoc = None # pylint: disable=invalid-name
|
||||
|
||||
@property
|
||||
def error_code(self):
|
||||
|
|
@ -149,13 +157,13 @@ class CCS811:
|
|||
raise RuntimeError("Error:" + str(self.error_code))
|
||||
|
||||
@property
|
||||
def tvoc(self): # pylint: disable=invalid-name
|
||||
def tvoc(self): # pylint: disable=invalid-name
|
||||
"""Total Volatile Organic Compound in parts per billion."""
|
||||
self._update_data()
|
||||
return self._tvoc
|
||||
|
||||
@property
|
||||
def eco2(self): # pylint: disable=invalid-name
|
||||
def eco2(self): # pylint: disable=invalid-name
|
||||
"""Equivalent Carbon Dioxide in parts per million. Clipped to 400 to 8192ppm."""
|
||||
self._update_data()
|
||||
return self._eco2
|
||||
|
|
@ -216,18 +224,22 @@ class CCS811:
|
|||
:param int low_med: Boundary between low and medium ranges
|
||||
:param int med_high: Boundary between medium and high ranges
|
||||
:param int hysteresis: Minimum difference between reads"""
|
||||
buf = bytearray([_THRESHOLDS,
|
||||
((low_med >> 8) & 0xF),
|
||||
(low_med & 0xF),
|
||||
((med_high >> 8) & 0xF),
|
||||
(med_high & 0xF),
|
||||
hysteresis])
|
||||
buf = bytearray(
|
||||
[
|
||||
_THRESHOLDS,
|
||||
((low_med >> 8) & 0xF),
|
||||
(low_med & 0xF),
|
||||
((med_high >> 8) & 0xF),
|
||||
(med_high & 0xF),
|
||||
hysteresis,
|
||||
]
|
||||
)
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(buf)
|
||||
|
||||
def reset(self):
|
||||
"""Initiate a software reset."""
|
||||
#reset sequence from the datasheet
|
||||
# reset sequence from the datasheet
|
||||
seq = bytearray([_SW_RESET, 0x11, 0xE5, 0x72, 0x8A])
|
||||
with self.i2c_device as i2c:
|
||||
i2c.write(seq)
|
||||
|
|
|
|||
130
docs/conf.py
130
docs/conf.py
|
|
@ -18,7 +18,8 @@
|
|||
#
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
|
|
@ -30,10 +31,10 @@ sys.path.insert(0, os.path.abspath('..'))
|
|||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.intersphinx'
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.viewcode",
|
||||
"sphinx.ext.intersphinx",
|
||||
]
|
||||
|
||||
# Uncomment the below if you use native CircuitPython modules such as
|
||||
|
|
@ -41,43 +42,50 @@ extensions = [
|
|||
# autodoc module docs will fail to generate with a warning.
|
||||
# autodoc_mock_imports = ["micropython", "adafruit_bus_device", "adafruit_register"]
|
||||
|
||||
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}
|
||||
intersphinx_mapping = {
|
||||
"python": ("https://docs.python.org/3.4", None),
|
||||
"BusDevice": (
|
||||
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
|
||||
None,
|
||||
),
|
||||
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
|
||||
}
|
||||
|
||||
# Mock out micropython ourselves.
|
||||
#import imp
|
||||
#m = imp.new_module("micropython")
|
||||
#m.const = lambda x: x
|
||||
#sys.modules["micropython"] = m
|
||||
# import imp
|
||||
# m = imp.new_module("micropython")
|
||||
# m.const = lambda x: x
|
||||
# sys.modules["micropython"] = m
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
#source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
#
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Adafruit\'s CCS811 Library'
|
||||
copyright = u'2016, Dean Miller, Scott Shawcroft'
|
||||
author = u'Dean Miller, Scott Shawcroft'
|
||||
project = u"Adafruit's CCS811 Library"
|
||||
copyright = u"2016, Dean Miller, Scott Shawcroft"
|
||||
author = u"Dean Miller, Scott Shawcroft"
|
||||
|
||||
# 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.
|
||||
|
|
@ -98,7 +106,7 @@ language = None
|
|||
# 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.
|
||||
|
|
@ -120,7 +128,7 @@ default_role = "any"
|
|||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
|
@ -140,18 +148,19 @@ todo_emit_warnings = True
|
|||
# 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 = ["."]
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
|
@ -185,13 +194,13 @@ else:
|
|||
# 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"
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
|
|
@ -276,29 +285,31 @@ html_favicon = '_static/favicon.ico'
|
|||
# -- 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, 'AdafruitsCCS811Library.tex', u'Adafruit\'s CCS811 Library Documentation',
|
||||
u'Dean Miller, Scott Shawcroft', 'manual'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitsCCS811Library.tex",
|
||||
u"Adafruit's CCS811 Library Documentation",
|
||||
u"Dean Miller, Scott Shawcroft",
|
||||
"manual",
|
||||
),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
|
@ -339,8 +350,13 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'AdafruitsCCS811Library23library', u'Adafruit\'s CCS811 Library Documentation',
|
||||
[author], 1)
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitsCCS811Library23library",
|
||||
u"Adafruit's CCS811 Library Documentation",
|
||||
[author],
|
||||
1,
|
||||
)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
|
@ -354,9 +370,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'AdafruitsCCS811Library', u'Adafruit\'s CCS811 Library Documentation',
|
||||
author, 'AdafruitsCCS811Library', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"AdafruitsCCS811Library",
|
||||
u"Adafruit's CCS811 Library Documentation",
|
||||
author,
|
||||
"AdafruitsCCS811Library",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
|
@ -375,5 +397,7 @@ texinfo_documents = [
|
|||
#
|
||||
# texinfo_no_detailmenu = False
|
||||
|
||||
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),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,5 @@ while not ccs811.data_ready:
|
|||
pass
|
||||
|
||||
while True:
|
||||
print("CO2: {} PPM, TVOC: {} PPB"
|
||||
.format(ccs811.eco2, ccs811.tvoc))
|
||||
print("CO2: {} PPM, TVOC: {} PPB".format(ccs811.eco2, ccs811.tvoc))
|
||||
time.sleep(0.5)
|
||||
|
|
|
|||
57
setup.py
57
setup.py
|
|
@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
|
|||
|
||||
# Always prefer setuptools over distutils
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
# To use a consistent encoding
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
|
@ -14,48 +15,42 @@ from os import path
|
|||
here = path.abspath(path.dirname(__file__))
|
||||
|
||||
# Get the long description from the README file
|
||||
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
|
||||
with open(path.join(here, "README.rst"), encoding="utf-8") as f:
|
||||
long_description = f.read()
|
||||
|
||||
setup(
|
||||
name='adafruit-circuitpython-ccs811',
|
||||
|
||||
name="adafruit-circuitpython-ccs811",
|
||||
use_scm_version=True,
|
||||
setup_requires=['setuptools_scm'],
|
||||
|
||||
description='CircuitPython library for CCS811 air quality sensor.',
|
||||
setup_requires=["setuptools_scm"],
|
||||
description="CircuitPython library for CCS811 air quality sensor.",
|
||||
long_description=long_description,
|
||||
long_description_content_type='text/x-rst',
|
||||
|
||||
long_description_content_type="text/x-rst",
|
||||
# The project's main homepage.
|
||||
url='https://github.com/adafruit/Adafruit_CircuitPython_CCS811',
|
||||
|
||||
url="https://github.com/adafruit/Adafruit_CircuitPython_CCS811",
|
||||
# Author details
|
||||
author='Adafruit Industries',
|
||||
author_email='circuitpython@adafruit.com',
|
||||
|
||||
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-register',
|
||||
'adafruit-circuitpython-busdevice'],
|
||||
|
||||
author="Adafruit Industries",
|
||||
author_email="circuitpython@adafruit.com",
|
||||
install_requires=[
|
||||
"Adafruit-Blinka",
|
||||
"adafruit-circuitpython-register",
|
||||
"adafruit-circuitpython-busdevice",
|
||||
],
|
||||
# Choose your license
|
||||
license='MIT',
|
||||
|
||||
license="MIT",
|
||||
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: System :: Hardware',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
"Development Status :: 3 - Alpha",
|
||||
"Intended Audience :: Developers",
|
||||
"Topic :: Software Development :: Libraries",
|
||||
"Topic :: System :: Hardware",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
],
|
||||
|
||||
# What does your project relate to?
|
||||
keywords='adafruit air quality voc eco2 breakout hardware micropython circuitpython',
|
||||
|
||||
keywords="adafruit air quality voc eco2 breakout hardware micropython circuitpython",
|
||||
# You can just specify the packages manually here if your project is
|
||||
# simple. Or you can use find_packages().
|
||||
py_modules=['adafruit_ccs811'],
|
||||
)
|
||||
py_modules=["adafruit_ccs811"],
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue