diff --git a/.gitignore b/.gitignore index 6337ada..55f127b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,12 @@ +*.mpy +.idea __pycache__ _build *.pyc -*.mpy .env build* bundles +*.DS_Store +.eggs +dist +**/*.egg-info \ No newline at end of file diff --git a/.pylintrc b/.pylintrc index 946d694..cb8d23d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -155,7 +155,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local # (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= +ignored-modules=board # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. diff --git a/.travis.yml b/.travis.yml index 203ff6e..c87d99a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,32 @@ -# This is a common .travis.yml for generating library release zip files for -# CircuitPython library releases using circuitpython-build-tools. -# See https://github.com/adafruit/circuitpython-build-tools for detailed setup -# instructions. - dist: trusty sudo: false language: python python: - - "3.6" - +- '3.6' cache: - pip: true - + pip: true deploy: - provider: releases - api_key: $GITHUB_TOKEN +- provider: releases + api_key: "$GITHUB_TOKEN" file_glob: true - file: $TRAVIS_BUILD_DIR/bundles/* + file: "$TRAVIS_BUILD_DIR/bundles/*" skip_cleanup: true overwrite: true on: tags: true - +- provider: pypi + user: adafruit-travis + on: + tags: true + password: + secure: f3THVFaLhKUStaYcrl2KQxXf/60ucgQ/UmK5jmKtRqjduWc1hHBi3hepyOAwqvcSW1TLD0rBxW6Y+Ny1dgv0XMv3kVzfa6u/7YCvRC1jaHiJrLqNu//HiX3ExM3phiptnH9yYD4dp3QvaVviB6Fxal3iLs4NwHhpHis/7Ky3QpywX7CPxOka9U4pSjsNLtSZbPDdZKJnHzAyk9crG+NxHWeuWQB/3tUFKOT5AfYY4aJ+uzmFxK7ykleAZsOG1Kmt770Pua8zqN5O2DcbVOScQ32eviLJJSPzEHSOmtQkqE5BjImPXmWEMzcHgSmOuwL5rTfWAVAiIbJY5eYtT6CJAV2ttRMuDJnTaZ/mnOCWHDJqDVNgWihxyYvaN/Sra/nkURziW8+ROOR9pSfL0CZOdEFWUoHMuKiJ/RFF4W0pXji9y4tqYm5xUUSkEfb6MTPtYu16mm+nPSsX2jJOryVdGhWZo3JYgj4AK61G91ilHtfhbLveWWZvg8S+oKrf2xddHBfE8XxyGhM1108AGximwXMM8lEqEKYE7gV7hIP5hLTE4iwW4Ckbib7ERS9X0Z1o7uenHb54Q+gb3kTcSPtEdSyeJgMqTI+Hq0rz5VO8dd0QQX6ybCQxcHOF9yPPVca4ekaTwiY+vxV+s31E8sKJVhETD91TVqvT7PGq2oKEHyI= install: - - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme - +- pip install -r requirements.txt +- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme +- pip install --force-reinstall pylint==1.9.2 script: - - pylint adafruit_sdcard.py - - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-sd --library_location . - - cd docs && sphinx-build -E -W -b html . _build/html +- pylint adafruit_sdcard.py +- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) +- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-sd --library_location + . +- cd docs && sphinx-build -E -W -b html . _build/html && cd .. diff --git a/adafruit_sdcard.py b/adafruit_sdcard.py index 1863bc1..0bc71ee 100644 --- a/adafruit_sdcard.py +++ b/adafruit_sdcard.py @@ -214,7 +214,9 @@ def _wait_for_ready(self, spi, timeout=0.3): while time.monotonic() - start_time < timeout and self._single_byte[0] != 0xff: spi.readinto(self._single_byte, write_value=0xff) - #pylint: disable-msg=too-many-arguments + # pylint: disable-msg=too-many-arguments + # pylint: disable=no-member + # no-member disable should be reconsidered when it can be tested def _cmd(self, cmd, arg=0, crc=0, response_buf=None, data_block=True, wait=True): """ Issue a command to the card and read an optional data response. @@ -294,6 +296,8 @@ def _block_cmd(self, cmd, block, crc, response_buf=None): result = buf[0] break + # pylint: disable=singleton-comparison + # Disable should be removed when refactor can be tested. if response_buf != None and result == 0: self._readinto(response_buf) @@ -362,6 +366,8 @@ def _write(self, token, buf, start=0, end=None): spi.write(cmd, end=2) # check the response + # pylint: disable=no-else-return + # Disable should be removed when refactor can be tested for _ in range(_CMD_TIMEOUT): spi.readinto(cmd, end=1, write_value=0xff) if not (cmd[0] & 0x80): diff --git a/docs/conf.py b/docs/conf.py index e1e6630..b3df00b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,7 +16,7 @@ ] -autodoc_mock_imports = ["adafruit_bus_device", "micropython"] +# autodoc_mock_imports = ["adafruit_bus_device", "micropython"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None), 'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None), diff --git a/requirements.txt b/requirements.txt index c47d35a..3031961 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -adafruit-circuitpython-bus-device +Adafruit-Blinka +adafruit-circuitpython-busdevice diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..60202bb --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +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 + +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: + long_description = f.read() + +setup( + name='adafruit-circuitpython-sd', + + use_scm_version=True, + setup_requires=['setuptools_scm'], + + description='CircuitPython library for SD cards.', + long_description=long_description, + long_description_content_type='text/x-rst', + + # The project's main homepage. + url='https://github.com/adafruit/Adafruit_CircuitPython_SD', + + # Author details + author='Adafruit Industries', + author_email='circuitpython@adafruit.com', + + install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'], + + # Choose your license + 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', + ], + + # What does your project relate to? + keywords='adafruit sdcard sd card mount storage featherwing adalogger' + '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_sdcard'], +)