Skip to content

Commit 1bfaef1

Browse files
committed
Initial commit of ndeftool version 0.1.0
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).
0 parents  commit 1bfaef1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3252
-0
lines changed

.coveragerc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[run]
2+
branch = True
3+
source = ndeftool
4+
5+
[paths]
6+
source =
7+
src/ndeftool
8+
.tox/*/lib/python*/site-packages/ndeftool
9+
.tox/pypy/site-packages/ndeftool
10+
11+
[report]
12+
show_missing = True

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*~
2+
*.pyc
3+
*.egg-info
4+
.tox
5+
.cache
6+
.coverage*
7+
__pycache__/
8+
docs/_build/
9+
htmlcov
10+
dist
11+
python-2
12+
python-3

.travis.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
sudo: false
2+
cache:
3+
directories:
4+
- $HOME/.cache/pip
5+
6+
language: python
7+
8+
9+
matrix:
10+
include:
11+
- python: "2.7"
12+
env: TOXENV=py27
13+
- python: "3.5"
14+
env: TOXENV=py35
15+
16+
# Meta
17+
- python: "3.5"
18+
env: TOXENV=flake8
19+
- python: "3.5"
20+
env: TOXENV=manifest
21+
- python: "3.5"
22+
env: TOXENV=docs
23+
- python: "3.5"
24+
env: TOXENV=readme
25+
26+
27+
install:
28+
- pip install tox
29+
30+
31+
script:
32+
- tox
33+
34+
35+
before_install:
36+
- pip install codecov
37+
38+
39+
after_success:
40+
- tox -e coverage-report
41+
- codecov
42+

CONTRIBUTING.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
.. -*- mode: rst; fill-column: 80 -*-
2+
3+
============
4+
Contributing
5+
============
6+
7+
Thank you for considering contributing to **ndeftool**. There are many
8+
ways to help and any help is welcome.
9+
10+
11+
Reporting issues
12+
================
13+
14+
- Under which versions of Python does this happen? This is especially
15+
important if your issue is encoding related.
16+
17+
- Under which versions of **ndeftool** does this happen? Check if this
18+
issue is fixed in the repository.
19+
20+
21+
Submitting patches
22+
==================
23+
24+
- Include tests if your patch is supposed to solve a bug, and explain
25+
clearly under which circumstances the bug happens. Make sure the
26+
test fails without your patch.
27+
28+
- Include or update tests and documentation if your patch is supposed
29+
to add a new feature. Note that documentation is in two places, the
30+
code itself for rendering help pages and in the docs folder for the
31+
online documentation.
32+
33+
- Follow `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_ and
34+
`PEP 257 <https://www.python.org/dev/peps/pep-0257/>`_.
35+
36+
37+
Development tips
38+
================
39+
40+
- `Fork <http://guides.github.com/activities/forking/>`_ the
41+
repository and clone it locally::
42+
43+
git clone [email protected]:your-username/ndeftool.git
44+
cd ndeftool
45+
46+
- Create virtual environments for Python 2 an Python 3, setup the
47+
ndeftool package in develop mode, and install required development
48+
packages::
49+
50+
virtualenv python-2
51+
python3 -m venv python-3
52+
source python-2/bin/activate
53+
python setup.py develop
54+
pip install -r requirements-dev.txt
55+
source python-3/bin/activate
56+
python setup.py develop
57+
pip install -r requirements-dev.txt
58+
59+
- Verify that all tests pass and the documentation is build::
60+
61+
tox
62+
63+
- Preferably develop in the Python 3 virtual environment. Running
64+
``tox`` ensures tests are run with both the Python 2 and Python 3
65+
interpreter but it takes some time to complete. Alternatively switch
66+
back and forth between versions and just run the tests::
67+
68+
source python-2/bin/activate
69+
py.test
70+
source python-3/bin/activate
71+
py.test
72+
73+
- Test coverage should be close to 100 percent. A great help is the
74+
HTML output produced by coverage.py::
75+
76+
py.test --cov ndeftool --cov-report html
77+
firefox htmlcov/index.html
78+
79+
- The documentation can be created and viewed loacally::
80+
81+
(cd docs && make html)
82+
firefox docs/_build/html/index.html
83+

LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) 2017 by Stephen Tiedemann.
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

MANIFEST.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include *.txt *.rst LICENSE tox.ini .coveragerc docs/Makefile
2+
recursive-include src *.py
3+
recursive-include tests *.py
4+
recursive-include docs *.ico
5+
recursive-include docs *.png
6+
recursive-include docs *.py
7+
recursive-include docs *.rst
8+
prune docs/_build

README.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
===============================
2+
Parse or generate NDEF messages
3+
===============================
4+
5+
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.
6+
7+
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>`_.

docs/Makefile

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS = -v
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
10+
# Internal variables.
11+
PAPEROPT_a4 = -D latex_paper_size=a4
12+
PAPEROPT_letter = -D latex_paper_size=letter
13+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
14+
15+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
16+
17+
help:
18+
@echo "Please use \`make <target>' where <target> is one of"
19+
@echo " html to make standalone HTML files"
20+
@echo " dirhtml to make HTML files named index.html in directories"
21+
@echo " singlehtml to make a single large HTML file"
22+
@echo " pickle to make pickle files"
23+
@echo " json to make JSON files"
24+
@echo " htmlhelp to make HTML files and a HTML help project"
25+
@echo " qthelp to make HTML files and a qthelp project"
26+
@echo " devhelp to make HTML files and a Devhelp project"
27+
@echo " epub to make an epub"
28+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
29+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
30+
@echo " text to make text files"
31+
@echo " man to make manual pages"
32+
@echo " changes to make an overview of all changed/added/deprecated items"
33+
@echo " linkcheck to check all external links for integrity"
34+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
35+
36+
clean:
37+
-rm -rf $(BUILDDIR)/*
38+
39+
html:
40+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
41+
@echo
42+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
43+
44+
dirhtml:
45+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
46+
@echo
47+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
48+
49+
singlehtml:
50+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
51+
@echo
52+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
53+
54+
pickle:
55+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
56+
@echo
57+
@echo "Build finished; now you can process the pickle files."
58+
59+
json:
60+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
61+
@echo
62+
@echo "Build finished; now you can process the JSON files."
63+
64+
htmlhelp:
65+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
66+
@echo
67+
@echo "Build finished; now you can run HTML Help Workshop with the" \
68+
".hhp project file in $(BUILDDIR)/htmlhelp."
69+
70+
qthelp:
71+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
72+
@echo
73+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
74+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
75+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/nfcpy.qhcp"
76+
@echo "To view the help file:"
77+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/nfcpy.qhc"
78+
79+
devhelp:
80+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
81+
@echo
82+
@echo "Build finished."
83+
@echo "To view the help file:"
84+
@echo "# mkdir -p $$HOME/.local/share/devhelp/nfcpy"
85+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/nfcpy"
86+
@echo "# devhelp"
87+
88+
epub:
89+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
90+
@echo
91+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
92+
93+
latex:
94+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
95+
@echo
96+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
97+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
98+
"(use \`make latexpdf' here to do that automatically)."
99+
100+
latexpdf:
101+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
102+
@echo "Running LaTeX files through pdflatex..."
103+
make -C $(BUILDDIR)/latex all-pdf
104+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
105+
106+
text:
107+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
108+
@echo
109+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
110+
111+
man:
112+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
113+
@echo
114+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
115+
116+
changes:
117+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
118+
@echo
119+
@echo "The overview file is in $(BUILDDIR)/changes."
120+
121+
linkcheck:
122+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
123+
@echo
124+
@echo "Link check complete; look for any errors in the above output " \
125+
"or in $(BUILDDIR)/linkcheck/output.txt."
126+
127+
doctest:
128+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
129+
@echo "Testing of doctests in the sources finished, look at the " \
130+
"results in $(BUILDDIR)/doctest/output.txt."

docs/commands/identifier.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.. -*- mode: rst; fill-column: 80 -*-
2+
3+
.. _identifier:
4+
5+
identifier
6+
==========
7+
8+
Change the identifier of the last record.
9+
10+
Synopsis
11+
--------
12+
13+
.. code::
14+
15+
ndeftool identifier [OPTIONS] NAME
16+
ndeftool id [OPTIONS] NAME
17+
18+
Description
19+
-----------
20+
21+
The **identifier** command either changes the current last record's name (NDEF
22+
Record ID) or, if the current message does not have any records, creates a
23+
record with unknown record type and the given record name.
24+
25+
Options
26+
-------
27+
28+
.. option:: --help
29+
30+
Show this message and exit.
31+
32+
Examples
33+
--------
34+
35+
Create a record with `unknown` type and set the identifier.
36+
37+
.. command-output:: ndeftool identifier 'record identifier' print
38+
39+
Create two text records with specific identifiers.
40+
41+
.. command-output:: ndeftool text 'first' id 'r1' text 'second' id 'r2' print
42+

0 commit comments

Comments
 (0)