Skip to content

Commit

Permalink
Initial commit of ndeftool version 0.1.0
Browse files Browse the repository at this point in the history
This is a Python 2 and Python 3 compatible rewrite of the ndeftool.py
example from https://github.com/nfcpy/nfcpy. It uses the ndeflib
module for decoding and encoding and the click module for implementing
the command line interface.

This version is regarded complete for core functionality (the load,
save, print, typename, identifier, and payload commands) and comes
with three commands for creating specific records (text, uri,
smartposter).
  • Loading branch information
nehpetsde committed Jan 20, 2017
0 parents commit 1bfaef1
Show file tree
Hide file tree
Showing 50 changed files with 3,252 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
@@ -0,0 +1,12 @@
[run]
branch = True
source = ndeftool

[paths]
source =
src/ndeftool
.tox/*/lib/python*/site-packages/ndeftool
.tox/pypy/site-packages/ndeftool

[report]
show_missing = True
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
*~
*.pyc
*.egg-info
.tox
.cache
.coverage*
__pycache__/
docs/_build/
htmlcov
dist
python-2
python-3
42 changes: 42 additions & 0 deletions .travis.yml
@@ -0,0 +1,42 @@
sudo: false
cache:
directories:
- $HOME/.cache/pip

language: python


matrix:
include:
- python: "2.7"
env: TOXENV=py27
- python: "3.5"
env: TOXENV=py35

# Meta
- python: "3.5"
env: TOXENV=flake8
- python: "3.5"
env: TOXENV=manifest
- python: "3.5"
env: TOXENV=docs
- python: "3.5"
env: TOXENV=readme


install:
- pip install tox


script:
- tox


before_install:
- pip install codecov


after_success:
- tox -e coverage-report
- codecov

83 changes: 83 additions & 0 deletions CONTRIBUTING.rst
@@ -0,0 +1,83 @@
.. -*- mode: rst; fill-column: 80 -*-
============
Contributing
============

Thank you for considering contributing to **ndeftool**. There are many
ways to help and any help is welcome.


Reporting issues
================

- Under which versions of Python does this happen? This is especially
important if your issue is encoding related.

- Under which versions of **ndeftool** does this happen? Check if this
issue is fixed in the repository.


Submitting patches
==================

- Include tests if your patch is supposed to solve a bug, and explain
clearly under which circumstances the bug happens. Make sure the
test fails without your patch.

- Include or update tests and documentation if your patch is supposed
to add a new feature. Note that documentation is in two places, the
code itself for rendering help pages and in the docs folder for the
online documentation.

- Follow `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_ and
`PEP 257 <https://www.python.org/dev/peps/pep-0257/>`_.


Development tips
================

- `Fork <http://guides.github.com/activities/forking/>`_ the
repository and clone it locally::

git clone git@github.com:your-username/ndeftool.git
cd ndeftool

- Create virtual environments for Python 2 an Python 3, setup the
ndeftool package in develop mode, and install required development
packages::

virtualenv python-2
python3 -m venv python-3
source python-2/bin/activate
python setup.py develop
pip install -r requirements-dev.txt
source python-3/bin/activate
python setup.py develop
pip install -r requirements-dev.txt

- Verify that all tests pass and the documentation is build::

tox

- Preferably develop in the Python 3 virtual environment. Running
``tox`` ensures tests are run with both the Python 2 and Python 3
interpreter but it takes some time to complete. Alternatively switch
back and forth between versions and just run the tests::

source python-2/bin/activate
py.test
source python-3/bin/activate
py.test

- Test coverage should be close to 100 percent. A great help is the
HTML output produced by coverage.py::

py.test --cov ndeftool --cov-report html
firefox htmlcov/index.html

- The documentation can be created and viewed loacally::

(cd docs && make html)
firefox docs/_build/html/index.html

15 changes: 15 additions & 0 deletions LICENSE
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2017 by Stephen Tiedemann.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8 changes: 8 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,8 @@
include *.txt *.rst LICENSE tox.ini .coveragerc docs/Makefile
recursive-include src *.py
recursive-include tests *.py
recursive-include docs *.ico
recursive-include docs *.png
recursive-include docs *.py
recursive-include docs *.rst
prune docs/_build
7 changes: 7 additions & 0 deletions README.rst
@@ -0,0 +1,7 @@
===============================
Parse or generate NDEF messages
===============================

The ``ndeftool`` is a command line utility to create or inspect NFC Data Exchange Format (NDEF) records and messages, released under the `ISC <http://choosealicense.com/licenses/isc/>`_ license.

The ``ndeftool`` documentation can be found on `Read the Docs <https://ndeftool.readthedocs.io/>`_ and the code on `GitHub <https://github.com/nfcpy/ndeftool>`_. It is `continously tested <https://travis-ci.org/nfcpy/ndeftool>`_ for Python 2.7 and 3.5 with pretty complete `test coverage <https://codecov.io/gh/nfcpy/ndeftool>`_.
130 changes: 130 additions & 0 deletions docs/Makefile
@@ -0,0 +1,130 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS = -v
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"

clean:
-rm -rf $(BUILDDIR)/*

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/nfcpy.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/nfcpy.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/nfcpy"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/nfcpy"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
42 changes: 42 additions & 0 deletions docs/commands/identifier.rst
@@ -0,0 +1,42 @@
.. -*- mode: rst; fill-column: 80 -*-
.. _identifier:

identifier
==========

Change the identifier of the last record.

Synopsis
--------

.. code::
ndeftool identifier [OPTIONS] NAME
ndeftool id [OPTIONS] NAME
Description
-----------

The **identifier** command either changes the current last record's name (NDEF
Record ID) or, if the current message does not have any records, creates a
record with unknown record type and the given record name.

Options
-------

.. option:: --help

Show this message and exit.

Examples
--------

Create a record with `unknown` type and set the identifier.

.. command-output:: ndeftool identifier 'record identifier' print

Create two text records with specific identifiers.

.. command-output:: ndeftool text 'first' id 'r1' text 'second' id 'r2' print

0 comments on commit 1bfaef1

Please sign in to comment.