Black formatted, Pylinted, and Github Actionified

This commit is contained in:
Melissa LeBlanc-Williams 2020-04-20 14:52:25 -07:00
parent 3b3ff5a545
commit df66981de3
11 changed files with 801 additions and 332 deletions

33
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: Release Actions
on:
release:
types: [published]
jobs:
upload-pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check For setup.py
id: need-pypi
run: |
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
- name: Set up Python
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
env:
TWINE_USERNAME: ${{ secrets.pypi_username }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python setup.py sdist
twine upload dist/*

433
.pylintrc Normal file
View file

@ -0,0 +1,433 @@
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=hid
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
ignore-patterns=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Use multiple processes to speed up Pylint.
# jobs=1
jobs=2
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=
# Pickle collected data for later comparisons.
persistent=yes
# Specify a configuration file.
#rcfile=
# Allow loading of arbitrary C extensions. Extensions are imported into the
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no
[MESSAGES CONTROL]
# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
confidence=
# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,attribute-defined-outside-init,bad-continuation,invalid-name
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where
# it should appear only once). See also the "--disable" option for examples.
enable=
[REPORTS]
# Python expression which should return a note less than 10 (10 is the highest
# note). You have access to the variables errors warning, statement which
# respectively contain the number of errors / warnings messages and the total
# number of statements analyzed. This is used by the global evaluation report
# (RP0004).
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
# Template used to display messages. This is a python new-style format string
# used to format the message information. See doc for all details
#msg-template=
# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio).You can also give a reporter class, eg
# mypackage.mymodule.MyReporterClass.
output-format=text
# Tells whether to display a full report or only the messages
reports=no
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
[LOGGING]
# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging
[SPELLING]
# Spelling dictionary name. Available dictionaries: none. To make it working
# install python-enchant package.
spelling-dict=
# List of comma separated words that should not be checked.
spelling-ignore-words=
# A path to a file that contains private dictionary; one word per line.
spelling-private-dict-file=
# Tells whether to store unknown words to indicated private dictionary in
# --spelling-private-dict-file option instead of raising a message.
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
[TYPECHECK]
# List of decorators that produce context managers, such as
# contextlib.contextmanager. Add to this list to register other decorators that
# produce valid context managers.
contextmanager-decorators=contextlib.contextmanager
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular
# expressions are accepted.
generated-members=
# Tells whether missing members accessed in mixin class should be ignored. A
# mixin class is detected if its name ends with "mixin" (case insensitive).
ignore-mixin-members=yes
# This flag controls whether pylint should warn about no-member and similar
# checks whenever an opaque object is returned when inferring. The inference
# can return multiple potential results while evaluating a Python object, but
# some branches might not be evaluated, which results in partial inference. In
# that case, it might be useful to still emit no-member and other checks for
# the rest of the inferred objects.
ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
missing-member-hint=yes
# The minimum edit distance a name should have in order to be considered a
# similar match for a missing member name.
missing-member-hint-distance=1
# The total number of similar names that should be taken in consideration when
# showing a hint for a missing member.
missing-member-max-choices=1
[VARIABLES]
# List of additional names supposed to be defined in builtins. Remember that
# you should avoid to define new builtins when possible.
additional-builtins=
# Tells whether unused global variables should be treated as a violation.
allow-global-unused-variables=yes
# List of strings which can identify a callback function by name. A callback
# name must start or end with one of those strings.
callbacks=cb_,_cb
# A regular expression matching the name of dummy variables (i.e. expectedly
# not used).
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*|^ignored_|^unused_
# Tells whether we should check for unused import in __init__ files.
init-import=no
# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,future.builtins
[FORMAT]
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
# expected-line-ending-format=
expected-line-ending-format=LF
# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=100
# Maximum number of lines in a module
max-module-lines=1000
# List of optional constructs for which whitespace checking is disabled. `dict-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
# `empty-line` allows space-only lines.
no-space-check=trailing-comma,dict-separator
# Allow the body of a class to be on the same line as the declaration if body
# contains single statement.
single-line-class-stmt=no
# Allow the body of an if to be on the same line as the test if there is no
# else.
single-line-if-stmt=no
[SIMILARITIES]
# Ignore comments when computing similarities.
ignore-comments=yes
# Ignore docstrings when computing similarities.
ignore-docstrings=yes
# Ignore imports when computing similarities.
ignore-imports=no
# Minimum lines number of a similarity.
min-similarity-lines=4
[BASIC]
# Naming hint for argument names
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct argument names
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Naming hint for attribute names
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct attribute names
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Bad variable names which should always be refused, separated by a comma
bad-names=foo,bar,baz,toto,tutu,tata
# Naming hint for class attribute names
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Regular expression matching correct class attribute names
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
# Naming hint for class names
# class-name-hint=[A-Z_][a-zA-Z0-9]+$
class-name-hint=[A-Z_][a-zA-Z0-9_]+$
# Regular expression matching correct class names
# class-rgx=[A-Z_][a-zA-Z0-9]+$
class-rgx=[A-Z_][a-zA-Z0-9_]+$
# Naming hint for constant names
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Regular expression matching correct constant names
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
# Minimum line length for functions/classes that require docstrings, shorter
# ones are exempt.
docstring-min-length=-1
# Naming hint for function names
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct function names
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Good variable names which should always be accepted, separated by a comma
# good-names=i,j,k,ex,Run,_
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
# Include a hint for the correct naming format with invalid-name
include-naming-hint=no
# Naming hint for inline iteration names
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
# Regular expression matching correct inline iteration names
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
# Naming hint for method names
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct method names
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Naming hint for module names
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Regular expression matching correct module names
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
# Colon-delimited sets of names that determine each other's naming style when
# the name regexes allow several styles.
name-group=
# Regular expression which should only match function or class names that do
# not require a docstring.
no-docstring-rgx=^_
# List of decorators that produce properties, such as abc.abstractproperty. Add
# to this list to register other decorators that produce valid properties.
property-classes=abc.abstractproperty
# Naming hint for variable names
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
# Regular expression matching correct variable names
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
[IMPORTS]
# Allow wildcard imports from modules that define __all__.
allow-wildcard-with-all=no
# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
analyse-fallback-blocks=no
# Deprecated modules which should not be used, separated by a comma
deprecated-modules=optparse,tkinter.tix
# Create a graph of external dependencies in the given file (report RP0402 must
# not be disabled)
ext-import-graph=
# Create a graph of every (i.e. internal and external) dependencies in the
# given file (report RP0402 must not be disabled)
import-graph=
# Create a graph of internal dependencies in the given file (report RP0402 must
# not be disabled)
int-import-graph=
# Force import order to recognize a module as part of the standard
# compatibility libraries.
known-standard-library=
# Force import order to recognize a module as part of a third party library.
known-third-party=enchant
[CLASSES]
# List of method names used to declare (i.e. assign) instance attributes.
defining-attr-methods=__init__,__new__,setUp
# List of member names, which should be excluded from the protected access
# warning.
exclude-protected=_asdict,_fields,_replace,_source,_make
# List of valid names for the first argument in a class method.
valid-classmethod-first-arg=cls
# List of valid names for the first argument in a metaclass class method.
valid-metaclass-classmethod-first-arg=mcs
[DESIGN]
# Maximum number of arguments for function / method
max-args=5
# Maximum number of attributes for a class (see R0902).
# max-attributes=7
max-attributes=11
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
# Maximum number of branch for function / method body
max-branches=12
# Maximum number of locals for function / method body
max-locals=15
# Maximum number of parents for a class (see R0901).
max-parents=7
# Maximum number of public methods for a class (see R0904).
max-public-methods=20
# Maximum number of return / yield for function / method body
max-returns=6
# Maximum number of statements in function / method body
max-statements=50
# Minimum number of public methods for a class (see R0903).
min-public-methods=1
[EXCEPTIONS]
# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception

View file

@ -44,10 +44,10 @@ class Detector:
otherwise None.
"""
# Match a line like 'Hardware : BCM2709':
pattern = r'^' + field + r'\s+:\s+(.*)$'
pattern = r"^" + field + r"\s+:\s+(.*)$"
with open('/proc/cpuinfo', 'r') as infile:
cpuinfo = infile.read().split('\n')
with open("/proc/cpuinfo", "r") as infile:
cpuinfo = infile.read().split("\n")
for line in cpuinfo:
match = re.search(pattern, line, flags=re.IGNORECASE)
if match:
@ -62,7 +62,7 @@ class Detector:
"""
# Match a value like 'qcom,apq8016-sbc':
try:
if value in open('/proc/device-tree/compatible').read():
if value in open("/proc/device-tree/compatible").read():
return True
except FileNotFoundError:
pass
@ -75,10 +75,10 @@ class Detector:
value, if found, otherwise None.
"""
field_value = None
pattern = r'^' + field + r'=(.*)'
pattern = r"^" + field + r"=(.*)"
try:
with open("/etc/armbian-release", 'r') as release_file:
armbian = release_file.read().split('\n')
with open("/etc/armbian-release", "r") as release_file:
armbian = release_file.read().split("\n")
for line in armbian:
match = re.search(pattern, line)
if match:
@ -94,7 +94,7 @@ class Detector:
otherwise None.
"""
try:
with open('/proc/device-tree/model', 'r') as model_file:
with open("/proc/device-tree/model", "r") as model_file:
model = model_file.read()
return model
except FileNotFoundError:
@ -105,7 +105,7 @@ class Detector:
Search /proc/device-tree/compatible for the compatible chip name.
"""
try:
with open('/proc/device-tree/compatible', 'r') as model_file:
with open("/proc/device-tree/compatible", "r") as model_file:
model = model_file.read()
return model
except FileNotFoundError:

View file

@ -20,7 +20,7 @@ class Board:
# There are some times we want to trick the platform detection
# say if a raspberry pi doesn't have the right ID, or for testing
try:
return os.environ['BLINKA_FORCEBOARD']
return os.environ["BLINKA_FORCEBOARD"]
except KeyError: # no forced board, continue with testing!
pass
@ -93,16 +93,13 @@ class Board:
else:
pi_model = self.detector.get_device_model()
if pi_model:
pi_model = pi_model.upper().replace(' ', '_')
pi_model = pi_model.upper().replace(" ", "_")
if "PLUS" in pi_model:
re_model = re.search(r'(RASPBERRY_PI_\d).*([AB]_*)(PLUS)',
pi_model)
re_model = re.search(r"(RASPBERRY_PI_\d).*([AB]_*)(PLUS)", pi_model)
elif "CM" in pi_model: # untested for Compute Module
re_model = re.search(r'(RASPBERRY_PI_CM)(\d)',
pi_model)
re_model = re.search(r"(RASPBERRY_PI_CM)(\d)", pi_model)
else: # untested for non-plus models
re_model = re.search(r'(RASPBERRY_PI_\d).*([AB])',
pi_model)
re_model = re.search(r"(RASPBERRY_PI_\d).*([AB])", pi_model)
if re_model:
pi_model = "".join(re_model.groups())
@ -122,21 +119,21 @@ class Board:
if self.detector.chip.id != chips.BCM2XXX:
# Something else, not a Pi.
return None
rev = self.detector.get_cpuinfo_field('Revision')
rev = self.detector.get_cpuinfo_field("Revision")
if rev is not None:
return rev
else:
try:
with open("/proc/device-tree/system/linux,revision", "rb") as revision:
rev_bytes = revision.read()
if rev_bytes[:1] == b'\x00':
rev_bytes = rev_bytes[1:]
try:
with open("/proc/device-tree/system/linux,revision", "rb") as revision:
rev_bytes = revision.read()
return rev_bytes.hex()
except FileNotFoundError:
return None
if rev_bytes[:1] == b"\x00":
rev_bytes = rev_bytes[1:]
return rev_bytes.hex()
except FileNotFoundError:
return None
# pylint: disable=no-self-use
def _beaglebone_id(self):
@ -147,12 +144,12 @@ class Board:
except FileNotFoundError:
return None
if eeprom_bytes[:4] != b'\xaaU3\xee':
if eeprom_bytes[:4] != b"\xaaU3\xee":
return None
# special condition for BeagleBone Green rev. 1A
# refer to GitHub issue #57 in this repo for more info
if eeprom_bytes == b'\xaaU3\xeeA335BNLT\x1a\x00\x00\x00':
if eeprom_bytes == b"\xaaU3\xeeA335BNLT\x1a\x00\x00\x00":
return boards.BEAGLEBONE_GREEN
id_string = eeprom_bytes[4:].decode("ascii")
@ -168,7 +165,7 @@ class Board:
# pylint: disable=too-many-return-statements
def _armbian_id(self):
"""Check whether the current board is an OrangePi board."""
board_value = self.detector.get_armbian_release_field('BOARD')
board_value = self.detector.get_armbian_release_field("BOARD")
board = None
if board_value == "orangepipc":
@ -213,7 +210,7 @@ class Board:
compatible = self.detector.get_device_compatible()
if not compatible:
return None
compats = compatible.split('\x00')
compats = compatible.split("\x00")
for board_id, board_compats in boards._JETSON_IDS.items():
if any(v in compats for v in board_compats):
return board_id
@ -222,7 +219,7 @@ class Board:
def _sifive_id(self):
"""Try to detect the id for Sifive RISCV64 board."""
board_value = self.detector.get_device_model()
if 'hifive-unleashed-a00' in board_value:
if "hifive-unleashed-a00" in board_value:
return boards.SIFIVE_UNLEASHED
return None
@ -230,11 +227,11 @@ class Board:
"""Try to detect the id for Pine64 board or device."""
board_value = self.detector.get_device_model()
board = None
if 'pine64' in board_value.lower():
if "pine64" in board_value.lower():
board = boards.PINE64
elif 'pinebook' in board_value.lower():
elif "pinebook" in board_value.lower():
board = boards.PINEBOOK
elif 'pinephone' in board_value.lower():
elif "pinephone" in board_value.lower():
board = boards.PINEPHONE
return board
@ -244,7 +241,7 @@ class Board:
try:
with open("/proc/device-tree/chosen/pynq_board", "r") as board_file:
board_model = board_file.read()
match = board_model.upper().replace('-', '_').rstrip('\x00')
match = board_model.upper().replace("-", "_").rstrip("\x00")
for model in boards._PYNQ_IDS:
if model == match:
return model
@ -342,11 +339,19 @@ class Board:
"""Check whether the current board is any embedded Linux device."""
return any(
[
self.any_raspberry_pi, self.any_beaglebone, self.any_orange_pi,
self.any_giant_board, self.any_jetson_board, self.any_coral_board,
self.any_odroid_40_pin, self.any_96boards, self.any_sifive_board,
self.any_onion_omega_board, self.any_pine64_board,
self.any_pynq_board, self.any_clockwork_pi_board
self.any_raspberry_pi,
self.any_beaglebone,
self.any_orange_pi,
self.any_giant_board,
self.any_jetson_board,
self.any_coral_board,
self.any_odroid_40_pin,
self.any_96boards,
self.any_sifive_board,
self.any_onion_omega_board,
self.any_pine64_board,
self.any_pynq_board,
self.any_clockwork_pi_board,
]
)

View file

@ -12,43 +12,51 @@ class Chip:
self.detector = detector
@property
def id(self): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements
def id(
self,
): # pylint: disable=invalid-name,too-many-branches,too-many-return-statements
"""Return a unique id for the detected chip, if any."""
# There are some times we want to trick the platform detection
# say if a raspberry pi doesn't have the right ID, or for testing
try:
return os.environ['BLINKA_FORCECHIP']
return os.environ["BLINKA_FORCECHIP"]
except KeyError: # no forced chip, continue with testing!
pass
# Special cases controlled by environment var
if os.environ.get('BLINKA_FT232H'):
from pyftdi.usbtools import UsbTools # pylint: disable=import-error
if os.environ.get("BLINKA_FT232H"):
from pyftdi.usbtools import UsbTools # pylint: disable=import-error,import-outside-toplevel
# look for it based on PID/VID
count = len(UsbTools.find_all([(0x0403, 0x6014)]))
if count == 0:
raise RuntimeError('BLINKA_FT232H environment variable ' +
'set, but no FT232H device found')
raise RuntimeError(
"BLINKA_FT232H environment variable "
+ "set, but no FT232H device found"
)
return chips.FT232H
if os.environ.get('BLINKA_MCP2221'):
import hid # pylint: disable=import-error
if os.environ.get("BLINKA_MCP2221"):
import hid # pylint: disable=import-error,import-outside-toplevel
# look for it based on PID/VID
for dev in hid.enumerate():
if dev['vendor_id'] == 0x04D8 and dev['product_id'] == 0x00DD:
if dev["vendor_id"] == 0x04D8 and dev["product_id"] == 0x00DD:
return chips.MCP2221
raise RuntimeError('BLINKA_MCP2221 environment variable ' +
'set, but no MCP2221 device found')
if os.environ.get('BLINKA_NOVA'):
raise RuntimeError(
"BLINKA_MCP2221 environment variable "
+ "set, but no MCP2221 device found"
)
if os.environ.get("BLINKA_NOVA"):
return chips.BINHO
platform = sys.platform
if platform in ('linux', 'linux2'):
if platform in ("linux", "linux2"):
return self._linux_id()
if platform == 'esp8266':
if platform == "esp8266":
return chips.ESP8266
if platform == 'samd21':
if platform == "samd21":
return chips.SAMD21
if platform == 'pyboard':
if platform == "pyboard":
return chips.STM32
# nothing found!
return None
@ -60,47 +68,48 @@ class Chip:
# pylint: disable=too-many-return-statements
"""Attempt to detect the CPU on a computer running the Linux kernel."""
if self.detector.check_dt_compatible_value('qcom,apq8016'):
if self.detector.check_dt_compatible_value("qcom,apq8016"):
return chips.APQ8016
if self.detector.check_dt_compatible_value('fu500'):
if self.detector.check_dt_compatible_value("fu500"):
return chips.HFU540
if self.detector.check_dt_compatible_value('sun8i-a33'):
if self.detector.check_dt_compatible_value("sun8i-a33"):
return chips.A33
linux_id = None
hardware = self.detector.get_cpuinfo_field('Hardware')
hardware = self.detector.get_cpuinfo_field("Hardware")
if hardware is None:
vendor_id = self.detector.get_cpuinfo_field('vendor_id')
if vendor_id in ('GenuineIntel', 'AuthenticAMD'):
vendor_id = self.detector.get_cpuinfo_field("vendor_id")
if vendor_id in ("GenuineIntel", "AuthenticAMD"):
linux_id = chips.GENERIC_X86
compatible = self.detector.get_device_compatible()
if compatible and 'tegra' in compatible:
compats = compatible.split('\x00')
if 'nvidia,tegra210' in compats:
if compatible and "tegra" in compatible:
compats = compatible.split("\x00")
if "nvidia,tegra210" in compats:
linux_id = chips.T210
elif 'nvidia,tegra186' in compats:
elif "nvidia,tegra186" in compats:
linux_id = chips.T186
elif 'nvidia,tegra194' in compats:
elif "nvidia,tegra194" in compats:
linux_id = chips.T194
if compatible and 'imx8m' in compatible:
if compatible and "imx8m" in compatible:
linux_id = chips.IMX8MX
if compatible and 'odroid-c2' in compatible:
if compatible and "odroid-c2" in compatible:
linux_id = chips.S905
if compatible and 'amlogic' in compatible:
compatible_list = compatible.replace('\x00', ',') \
.replace(' ', '').split(',')
if 'g12a' in compatible_list:
if compatible and "amlogic" in compatible:
compatible_list = (
compatible.replace("\x00", ",").replace(" ", "").split(",")
)
if "g12a" in compatible_list:
# 'sm1' is correct for S905X3, but some kernels use 'g12a'
return chips.S905X3
if 'g12b' in compatible_list:
if "g12b" in compatible_list:
return chips.S922X
if 'sm1' in compatible_list:
if "sm1" in compatible_list:
return chips.S905X3
if compatible and 'sun50i-a64' in compatible:
if compatible and "sun50i-a64" in compatible:
linux_id = chips.A64
cpu_model = self.detector.get_cpuinfo_field("cpu model")
@ -116,23 +125,23 @@ class Chip:
# conditions attempt.
if not linux_id:
hardware = [
entry.replace('\x00', '') for entry in compatible.split(',')
entry.replace("\x00", "") for entry in compatible.split(",")
]
if not linux_id:
if 'AM33XX' in hardware:
if "AM33XX" in hardware:
linux_id = chips.AM33XX
elif 'sun8i' in hardware:
elif "sun8i" in hardware:
linux_id = chips.SUN8I
elif 'ODROIDC' in hardware:
elif "ODROIDC" in hardware:
linux_id = chips.S805
elif 'ODROID-C2' in hardware:
elif "ODROID-C2" in hardware:
linux_id = chips.S905
elif 'ODROID-N2' in hardware:
elif "ODROID-N2" in hardware:
linux_id = chips.S922X
elif 'ODROID-C4' in hardware:
elif "ODROID-C4" in hardware:
linux_id = chips.S905X3
elif 'SAMA5' in hardware:
elif "SAMA5" in hardware:
linux_id = chips.SAMA5
elif "Pinebook" in hardware:
linux_id = chips.A64
@ -140,14 +149,14 @@ class Chip:
linux_id = chips.A64
elif "Xilinx Zynq" in hardware:
compatible = self.detector.get_device_compatible()
if compatible and 'xlnx,zynq-7000' in compatible:
if compatible and "xlnx,zynq-7000" in compatible:
linux_id = chips.ZYNQ7000
else:
if isinstance(hardware, str):
if hardware.upper() in chips.BCM_RANGE:
linux_id = chips.BCM2XXX
elif isinstance(hardware, list):
if set([model.upper() for model in hardware]) & chips.BCM_RANGE:
if {model.upper() for model in hardware} & chips.BCM_RANGE:
linux_id = chips.BCM2XXX
return linux_id

View file

@ -1 +1 @@
"""Common constants used all over the module."""
"""Common constants used all over the module."""

View file

@ -1,21 +1,21 @@
"""Definition of boards and/or ids"""
# Allow for aligned constant definitions:
# pylint: disable=bad-whitespace
BEAGLEBONE = 'BEAGLEBONE'
BEAGLEBONE_BLACK = 'BEAGLEBONE_BLACK'
BEAGLEBONE_BLUE = 'BEAGLEBONE_BLUE'
BEAGLEBONE_BLACK_WIRELESS = 'BEAGLEBONE_BLACK_WIRELESS'
BEAGLEBONE_POCKETBEAGLE = 'BEAGLEBONE_POCKETBEAGLE'
BEAGLEBONE_GREEN = 'BEAGLEBONE_GREEN'
BEAGLEBONE_GREEN_WIRELESS = 'BEAGLEBONE_GREEN_WIRELESS'
BEAGLEBONE_BLACK_INDUSTRIAL = 'BEAGLEBONE_BLACK_INDUSTRIAL'
BEAGLEBONE_ENHANCED = 'BEAGLEBONE_ENHANCED'
BEAGLEBONE_USOMIQ = 'BEAGLEBONE_USOMIQ'
BEAGLEBONE_AIR = 'BEAGLEBONE_AIR'
BEAGLEBONE_POCKETBONE = 'BEAGLEBONE_POCKETBONE'
BEAGLELOGIC_STANDALONE = 'BEAGLELOGIC_STANDALONE'
OSD3358_DEV_BOARD = 'OSD3358_DEV_BOARD'
OSD3358_SM_RED = 'OSD3358_SM_RED'
BEAGLEBONE = "BEAGLEBONE"
BEAGLEBONE_BLACK = "BEAGLEBONE_BLACK"
BEAGLEBONE_BLUE = "BEAGLEBONE_BLUE"
BEAGLEBONE_BLACK_WIRELESS = "BEAGLEBONE_BLACK_WIRELESS"
BEAGLEBONE_POCKETBEAGLE = "BEAGLEBONE_POCKETBEAGLE"
BEAGLEBONE_GREEN = "BEAGLEBONE_GREEN"
BEAGLEBONE_GREEN_WIRELESS = "BEAGLEBONE_GREEN_WIRELESS"
BEAGLEBONE_BLACK_INDUSTRIAL = "BEAGLEBONE_BLACK_INDUSTRIAL"
BEAGLEBONE_ENHANCED = "BEAGLEBONE_ENHANCED"
BEAGLEBONE_USOMIQ = "BEAGLEBONE_USOMIQ"
BEAGLEBONE_AIR = "BEAGLEBONE_AIR"
BEAGLEBONE_POCKETBONE = "BEAGLEBONE_POCKETBONE"
BEAGLELOGIC_STANDALONE = "BEAGLELOGIC_STANDALONE"
OSD3358_DEV_BOARD = "OSD3358_DEV_BOARD"
OSD3358_SM_RED = "OSD3358_SM_RED"
FEATHER_HUZZAH = "FEATHER_HUZZAH"
FEATHER_M0_EXPRESS = "FEATHER_M0_EXPRESS"
@ -37,11 +37,11 @@ ORANGE_PI_PC_PLUS = "ORANGE_PI_PC_PLUS"
ORANGE_PI_PLUS_2E = "ORANGE_PI_PLUS_2E"
# NVIDIA Jetson boards
JETSON_TX1 = 'JETSON_TX1'
JETSON_TX2 = 'JETSON_TX2'
JETSON_XAVIER = 'JETSON_XAVIER'
JETSON_NANO = 'JETSON_NANO'
JETSON_NX = 'JETSON_NX'
JETSON_TX1 = "JETSON_TX1"
JETSON_TX2 = "JETSON_TX2"
JETSON_XAVIER = "JETSON_XAVIER"
JETSON_NANO = "JETSON_NANO"
JETSON_NX = "JETSON_NX"
# Google Coral dev board
CORAL_EDGE_TPU_DEV = "CORAL_EDGE_TPU_DEV"
@ -102,9 +102,7 @@ _ORANGE_PI_IDS = (
ORANGE_PI_PLUS_2E,
)
_CORAL_IDS = (
CORAL_EDGE_TPU_DEV,
)
_CORAL_IDS = (CORAL_EDGE_TPU_DEV,)
_PYNQ_IDS = (
PYNQ_Z1,
@ -112,33 +110,22 @@ _PYNQ_IDS = (
)
_JETSON_IDS = {
JETSON_TX1: (
'nvidia,p2371-2180',
'nvidia,jetson-cv',
),
JETSON_TX1: ("nvidia,p2371-2180", "nvidia,jetson-cv",),
JETSON_TX2: (
'nvidia,p2771-0000',
'nvidia,p2771-0888',
'nvidia,p3489-0000',
'nvidia,lightning',
'nvidia,quill',
'nvidia,storm',
),
JETSON_XAVIER: (
'nvidia,p2972-0000',
'nvidia,p2972-0006',
'nvidia,jetson-xavier',
),
JETSON_NANO: (
'nvidia,p3450-0000',
'nvidia,p3450-0002',
'nvidia,jetson-nano',
"nvidia,p2771-0000",
"nvidia,p2771-0888",
"nvidia,p3489-0000",
"nvidia,lightning",
"nvidia,quill",
"nvidia,storm",
),
JETSON_XAVIER: ("nvidia,p2972-0000", "nvidia,p2972-0006", "nvidia,jetson-xavier",),
JETSON_NANO: ("nvidia,p3450-0000", "nvidia,p3450-0002", "nvidia,jetson-nano",),
JETSON_NX: (
'nvidia,p3509-0000+p3668-0000',
'nvidia,p3509-0000+p3668-0001',
'nvidia,p3449-0000+p3668-0000',
'nvidia,p3449-0000+p3668-0001',
"nvidia,p3509-0000+p3668-0000",
"nvidia,p3509-0000+p3668-0001",
"nvidia,p3449-0000+p3668-0000",
"nvidia,p3449-0000+p3668-0001",
),
}
@ -151,22 +138,12 @@ _RASPBERRY_PI_40_PIN_IDS = (
RASPBERRY_PI_3B,
RASPBERRY_PI_3B_PLUS,
RASPBERRY_PI_3A_PLUS,
RASPBERRY_PI_4B
RASPBERRY_PI_4B,
)
_RASPBERRY_PI_CM_IDS = (
RASPBERRY_PI_CM1,
RASPBERRY_PI_CM3,
RASPBERRY_PI_CM3_PLUS
)
_RASPBERRY_PI_CM_IDS = (RASPBERRY_PI_CM1, RASPBERRY_PI_CM3, RASPBERRY_PI_CM3_PLUS)
_ODROID_40_PIN_IDS = (
ODROID_C1,
ODROID_C1_PLUS,
ODROID_C2,
ODROID_C4,
ODROID_N2
)
_ODROID_40_PIN_IDS = (ODROID_C1, ODROID_C1_PLUS, ODROID_C2, ODROID_C4, ODROID_N2)
_BEAGLEBONE_IDS = (
BEAGLEBONE,
@ -186,13 +163,9 @@ _BEAGLEBONE_IDS = (
OSD3358_SM_RED,
)
_LINARO_96BOARDS_IDS = (
DRAGONBOARD_410C,
)
_LINARO_96BOARDS_IDS = (DRAGONBOARD_410C,)
_SIFIVE_IDS = (
SIFIVE_UNLEASHED,
)
_SIFIVE_IDS = (SIFIVE_UNLEASHED,)
# BeagleBone eeprom board ids from:
# https://github.com/beagleboard/image-builder
@ -200,63 +173,38 @@ _SIFIVE_IDS = (
_BEAGLEBONE_BOARD_IDS = {
# Original bone/white:
BEAGLEBONE: (
('A4', 'A335BONE00A4'),
('A5', 'A335BONE00A5'),
('A6', 'A335BONE00A6'),
('A6A', 'A335BONE0A6A'),
('A6B', 'A335BONE0A6B'),
('B', 'A335BONE000B'),
("A4", "A335BONE00A4"),
("A5", "A335BONE00A5"),
("A6", "A335BONE00A6"),
("A6A", "A335BONE0A6A"),
("A6B", "A335BONE0A6B"),
("B", "A335BONE000B"),
),
BEAGLEBONE_BLACK: (
('A5', 'A335BNLT00A5'),
('A5A', 'A335BNLT0A5A'),
('A5B', 'A335BNLT0A5B'),
('A5C', 'A335BNLT0A5C'),
('A6', 'A335BNLT00A6'),
('C', 'A335BNLT000C'),
('C', 'A335BNLT00C0'),
),
BEAGLEBONE_BLUE: (
('A2', 'A335BNLTBLA2'),
),
BEAGLEBONE_BLACK_WIRELESS: (
('A5', 'A335BNLTBWA5'),
),
BEAGLEBONE_POCKETBEAGLE: (
('A2', 'A335PBGL00A2'),
),
BEAGLEBONE_GREEN: (
('1A', 'A335BNLT....'),
('UNKNOWN', 'A335BNLTBBG1'),
),
BEAGLEBONE_GREEN_WIRELESS: (
('W1A', 'A335BNLTGW1A'),
("A5", "A335BNLT00A5"),
("A5A", "A335BNLT0A5A"),
("A5B", "A335BNLT0A5B"),
("A5C", "A335BNLT0A5C"),
("A6", "A335BNLT00A6"),
("C", "A335BNLT000C"),
("C", "A335BNLT00C0"),
),
BEAGLEBONE_BLUE: (("A2", "A335BNLTBLA2"),),
BEAGLEBONE_BLACK_WIRELESS: (("A5", "A335BNLTBWA5"),),
BEAGLEBONE_POCKETBEAGLE: (("A2", "A335PBGL00A2"),),
BEAGLEBONE_GREEN: (("1A", "A335BNLT...."), ("UNKNOWN", "A335BNLTBBG1"),),
BEAGLEBONE_GREEN_WIRELESS: (("W1A", "A335BNLTGW1A"),),
BEAGLEBONE_BLACK_INDUSTRIAL: (
('A0', 'A335BNLTAIA0'), # Arrow
('A0', 'A335BNLTEIA0'), # Element14
("A0", "A335BNLTAIA0"), # Arrow
("A0", "A335BNLTEIA0"), # Element14
),
BEAGLEBONE_ENHANCED: (
('A', 'A335BNLTSE0A'),
),
BEAGLEBONE_USOMIQ: (
('6', 'A335BNLTME06'),
),
BEAGLEBONE_AIR: (
('A0', 'A335BNLTNAD0'),
),
BEAGLEBONE_POCKETBONE: (
('0', 'A335BNLTBP00'),
),
OSD3358_DEV_BOARD: (
('0.1', 'A335BNLTGH01'),
),
OSD3358_SM_RED: (
('0', 'A335BNLTOS00'),
),
BEAGLELOGIC_STANDALONE: (
('A', 'A335BLGC000A'),
)
BEAGLEBONE_ENHANCED: (("A", "A335BNLTSE0A"),),
BEAGLEBONE_USOMIQ: (("6", "A335BNLTME06"),),
BEAGLEBONE_AIR: (("A0", "A335BNLTNAD0"),),
BEAGLEBONE_POCKETBONE: (("0", "A335BNLTBP00"),),
OSD3358_DEV_BOARD: (("0.1", "A335BNLTGH01"),),
OSD3358_SM_RED: (("0", "A335BNLTOS00"),),
BEAGLELOGIC_STANDALONE: (("A", "A335BLGC000A"),),
}
# Pi revision codes from:
@ -270,73 +218,101 @@ _BEAGLEBONE_BOARD_IDS = {
_PI_REV_CODES = {
RASPBERRY_PI_B_REV1: (
# Regular codes:
'0002', '0003',
"0002",
"0003",
# Overvolted/clocked versions:
'1000002', '1000003',
"1000002",
"1000003",
),
RASPBERRY_PI_B_REV2: (
'0005', '0006', '000d', '000e', '000f',
'1000005', '1000006', '100000d', '100000e', '100000f',
),
RASPBERRY_PI_B_PLUS: (
'0010', '0013', '900032',
'1000010', '1000013', '1900032',
),
RASPBERRY_PI_A: (
'0007', '0008', '0009',
'1000007', '1000008', '1000009',
),
RASPBERRY_PI_A_PLUS: (
'0012', '0015', '900021',
'1000012', '1000015', '1900021',
),
RASPBERRY_PI_CM1: (
'0011', '0014',
'10000011', '10000014',
"0005",
"0006",
"000d",
"000e",
"000f",
"1000005",
"1000006",
"100000d",
"100000e",
"100000f",
),
RASPBERRY_PI_B_PLUS: ("0010", "0013", "900032", "1000010", "1000013", "1900032",),
RASPBERRY_PI_A: ("0007", "0008", "0009", "1000007", "1000008", "1000009",),
RASPBERRY_PI_A_PLUS: ("0012", "0015", "900021", "1000012", "1000015", "1900021",),
RASPBERRY_PI_CM1: ("0011", "0014", "10000011", "10000014",),
RASPBERRY_PI_ZERO: (
'900092', '920092', '900093', '920093',
'1900092', '1920092', '1900093', '1920093', # warranty bit 24
'2900092', '2920092', '2900093', '2920093', # warranty bit 25
),
RASPBERRY_PI_ZERO_W: (
'9000c1',
'19000c1', '29000c1', # warranty bits
"900092",
"920092",
"900093",
"920093",
"1900092",
"1920092",
"1900093",
"1920093", # warranty bit 24
"2900092",
"2920092",
"2900093",
"2920093", # warranty bit 25
),
RASPBERRY_PI_ZERO_W: ("9000c1", "19000c1", "29000c1",), # warranty bits
RASPBERRY_PI_2B: (
'a01040', 'a01041', 'a21041', 'a22042',
'1a01040', '1a01041', '1a21041', '1a22042', # warranty bit 24
'2a01040', '2a01041', '2a21041', '2a22042', # warranty bit 25
"a01040",
"a01041",
"a21041",
"a22042",
"1a01040",
"1a01041",
"1a21041",
"1a22042", # warranty bit 24
"2a01040",
"2a01041",
"2a21041",
"2a22042", # warranty bit 25
),
RASPBERRY_PI_3B: (
'a02082', 'a22082', 'a32082', 'a52082',
'1a02082', '1a22082', '1a32082', '1a52082', # warranty bit 24
'2a02082', '2a22082', '2a32082', '2a52082', # warranty bit 25
),
RASPBERRY_PI_3B_PLUS: (
'a020d3',
'1a020d3', '2a020d3', # warranty bits
"a02082",
"a22082",
"a32082",
"a52082",
"1a02082",
"1a22082",
"1a32082",
"1a52082", # warranty bit 24
"2a02082",
"2a22082",
"2a32082",
"2a52082", # warranty bit 25
),
RASPBERRY_PI_3B_PLUS: ("a020d3", "1a020d3", "2a020d3",), # warranty bits
RASPBERRY_PI_CM3: (
'a020a0', 'a220a0',
'1a020a0', '2a020a0', # warranty bits
'1a220a0', '2a220a0',
),
RASPBERRY_PI_3A_PLUS: (
'9020e0',
'19020e0', '29020e0', # warranty bits
),
RASPBERRY_PI_CM3_PLUS: (
'a02100',
'1a02100', '2a02100', # warranty bits
"a020a0",
"a220a0",
"1a020a0",
"2a020a0", # warranty bits
"1a220a0",
"2a220a0",
),
RASPBERRY_PI_3A_PLUS: ("9020e0", "19020e0", "29020e0",), # warranty bits
RASPBERRY_PI_CM3_PLUS: ("a02100", "1a02100", "2a02100",), # warranty bits
RASPBERRY_PI_4B: (
'a03111', 'b03111', 'c03111',
'a03112', 'b03112', 'c03112',
'1a03111', '2a03111', '1b03111', '2b03111', # warranty bits
'1c03111', '2c03111', '1a03112', '2a03112',
'1b03112', '2b03112', '1c03112', '2c03112',
"a03111",
"b03111",
"c03111",
"a03112",
"b03112",
"c03112",
"1a03111",
"2a03111",
"1b03111",
"2b03111", # warranty bits
"1c03111",
"2c03111",
"1a03112",
"2a03112",
"1b03112",
"2b03112",
"1c03112",
"2c03112",
),
}
@ -347,8 +323,4 @@ _ONION_OMEGA_BOARD_IDS = (
)
# Pine64 boards and devices
_PINE64_DEV_IDS = (
PINE64,
PINEBOOK,
PINEPHONE
)
_PINE64_DEV_IDS = (PINE64, PINEBOOK, PINEPHONE)

View file

@ -26,4 +26,4 @@ ZYNQ7000 = "ZYNQ7000"
A64 = "A64"
A33 = "A33"
BCM_RANGE = {'BCM2708', 'BCM2709', 'BCM2711', 'BCM2835', 'BCM2837'}
BCM_RANGE = {"BCM2708", "BCM2709", "BCM2711", "BCM2835", "BCM2837"}

View file

@ -22,8 +22,10 @@ print("Is this a PYNQ Board?", detector.board.PYNQ_Z1 | detector.board.PYNQ_Z2)
print("Is this a Clockwork Pi board?", detector.board.any_clockwork_pi_board)
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
print("Is this an OS environment variable special case?", detector.board.FTDI_FT232H |
detector.board.MICROCHIP_MCP2221)
print(
"Is this an OS environment variable special case?",
detector.board.FTDI_FT232H | detector.board.MICROCHIP_MCP2221,
)
if detector.board.any_raspberry_pi:
print("Raspberry Pi detected.")

View file

@ -2,7 +2,8 @@
import os
import sys
sys.path.insert(0, os.path.abspath('../adafruit_platformdetect'))
sys.path.insert(0, os.path.abspath("../adafruit_platformdetect"))
# -- General configuration ------------------------------------------------
@ -10,9 +11,9 @@ sys.path.insert(0, os.path.abspath('../adafruit_platformdetect'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
]
# Uncomment the below if you use native CircuitPython modules such as
@ -20,30 +21,32 @@ extensions = [
# autodoc module docs will fail to generate with a warning.
autodoc_mock_imports = ["machine"]
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 Blinka Library'
copyright = u'2017 Adafruit Industries'
author = u'Brennen Bearnes'
project = "Adafruit Blinka Library"
copyright = "2017 Adafruit Industries"
author = "Brennen Bearnes"
# 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.0'
version = "1.0.0"
# The full version, including alpha/beta/rc tags.
release = u'1.0.0'
release = "1.0.0"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -55,7 +58,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.
@ -67,7 +70,7 @@ default_role = "any"
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
@ -81,53 +84,56 @@ 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 = ["."]
# 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"]
# Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitPlatformDetectLibrarydoc'
htmlhelp_basename = "AdafruitPlatformDetectLibrarydoc"
# -- 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, 'AdafruitPlatformDetectLibrary.tex', u'AdafruitPlatformDetect Library Documentation',
author, 'manual'),
(
master_doc,
"AdafruitPlatformDetectLibrary.tex",
"AdafruitPlatformDetect Library Documentation",
author,
"manual",
),
]
# -- Options for manual page output ---------------------------------------
@ -135,8 +141,13 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'AdafruitPlatformDetectlibrary', u'Adafruit PlatformDetect Library Documentation',
[author], 1)
(
master_doc,
"AdafruitPlatformDetectlibrary",
"Adafruit PlatformDetect Library Documentation",
[author],
1,
)
]
# -- Options for Texinfo output -------------------------------------------
@ -145,7 +156,13 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'AdafruitPlatformDetectLibrary', u'Adafruit PlatformDetect Library Documentation',
author, 'AdafruitPlatformDetectLibrary', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"AdafruitPlatformDetectLibrary",
"Adafruit PlatformDetect Library Documentation",
author,
"AdafruitPlatformDetectLibrary",
"One line description of project.",
"Miscellaneous",
),
]

View file

@ -13,33 +13,31 @@ here = os.path.abspath(os.path.dirname(__file__))
# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = '\n' + f.read()
with io.open(os.path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = "\n" + f.read()
setup(
name='Adafruit-PlatformDetect',
name="Adafruit-PlatformDetect",
use_scm_version=True,
setup_requires=["setuptools_scm"],
description='Platform detection for use by libraries like Adafruit-Blinka.',
description="Platform detection for use by libraries like Adafruit-Blinka.",
long_description=long_description,
long_description_content_type='text/x-rst',
author='Adafruit Industries',
author_email='circuitpython@adafruit.com',
python_requires='>=3.4.0',
url='https://github.com/adafruit/Adafruit_Python_PlatformDetect',
long_description_content_type="text/x-rst",
author="Adafruit Industries",
author_email="circuitpython@adafruit.com",
python_requires=">=3.4.0",
url="https://github.com/adafruit/Adafruit_Python_PlatformDetect",
# If your package is a single module, use this instead of 'packages':
packages=['adafruit_platformdetect', 'adafruit_platformdetect.constants'],
packages=["adafruit_platformdetect", "adafruit_platformdetect.constants"],
install_requires=[],
license='MIT',
license="MIT",
classifiers=[
# Trove classifiers
# Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: MicroPython',
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: Implementation :: MicroPython",
],
)