diff options
| author | Ben Finney <bignose@debian.org> | 2019-10-26 12:25:12 +1100 |
|---|---|---|
| committer | git-ubuntu importer <ubuntu-devel-discuss@lists.ubuntu.com> | 2019-10-26 04:37:57 +0000 |
| commit | cd6877df588272d023be44cd86a93ddd0f6ca703 (patch) | |
| tree | 1f264061cf02d483cf6aae798def73e403394afa | |
| parent | 72d23c5f3cdc11cfd5ae12478750a093cf9a06da (diff) | |
| parent | aee633e07fcca54e5466036b667a4137d75bb509 (diff) | |
0.4.2-1 (patches applied)applied/0.4.2-1applied/ubuntu/focal-proposedapplied/ubuntu/focal-develapplied/ubuntu/focal
Imported using git-ubuntu import.
| -rw-r--r-- | LICENSE | 19 | ||||
| -rw-r--r-- | MANIFEST.in | 4 | ||||
| -rw-r--r-- | PKG-INFO | 2 | ||||
| -rw-r--r-- | debian/.editorconfig | 46 | ||||
| -rw-r--r-- | debian/README.source | 4 | ||||
| -rw-r--r-- | debian/changelog | 31 | ||||
| -rw-r--r-- | debian/compat | 1 | ||||
| -rw-r--r-- | debian/control | 26 | ||||
| -rw-r--r-- | debian/copyright | 10 | ||||
| -rw-r--r-- | debian/gbp.conf | 10 | ||||
| -rw-r--r-- | debian/patches/migrate-from-times-to-arrow.patch | 52 | ||||
| -rw-r--r-- | debian/patches/series | 1 | ||||
| -rwxr-xr-x | debian/rules | 45 | ||||
| -rw-r--r-- | debian/tests/control | 5 | ||||
| -rwxr-xr-x | debian/tests/smoke-python2 | 39 | ||||
| -rwxr-xr-x | debian/tests/smoke-python3 | 15 | ||||
| -rw-r--r-- | debian/tests/smoke_test.py | 15 | ||||
| -rw-r--r-- | debian/upstream/metadata | 32 | ||||
| -rw-r--r-- | debian/watch | 2 | ||||
| -rw-r--r-- | docs/Makefile | 177 | ||||
| -rw-r--r-- | docs/conf.py | 258 | ||||
| -rw-r--r-- | docs/index.rst | 81 | ||||
| -rw-r--r-- | jsonext.egg-info/PKG-INFO | 2 | ||||
| -rw-r--r-- | jsonext.egg-info/SOURCES.txt | 6 | ||||
| -rw-r--r-- | jsonext.egg-info/requires.txt | 3 | ||||
| -rw-r--r-- | jsonext/__init__.py | 9 | ||||
| -rw-r--r-- | jsonext/mixins.py | 3 | ||||
| -rw-r--r-- | jsonext/wrappers.py | 73 | ||||
| -rw-r--r-- | setup.py | 8 |
29 files changed, 798 insertions, 181 deletions
@@ -0,0 +1,19 @@ +Copyright (c) 2014 Marc Brinkmann + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..af44daa --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include LICENSE +include README.rst + +recursive-include docs/ * @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: jsonext -Version: 0.4.1 +Version: 0.4.2 Summary: Well-structured helpers to help serializing commonly encountered structures to JSON (like datetime, to_dict(), etc. Home-page: http://github.com/mbr/jsonext Author: Marc Brinkmann diff --git a/debian/.editorconfig b/debian/.editorconfig new file mode 100644 index 0000000..61c0ee1 --- /dev/null +++ b/debian/.editorconfig @@ -0,0 +1,46 @@ +# debian/.editorconfig +# EditorConfig configuration for Debian packaging files. +# Homepage: <URL:http://editorconfig.org/> + +# Is this the project-root configuration file? +root = false + + +[*] + +# Character encoding to use. +charset = utf-8 + +# Indentation style (“tab”, “space”). +indent_style = space + +# How many columns (integer) for each indentation level. +indent_size = 4 + +# How many columns (integer) to represent a U+0008 TAB. +tab_width = 8 + +# How many characters (integer) before enforcing line wrap. +max_line_length = 79 + +# Remove trailing whitespace on each line? +trim_trailing_whitespace = true + +# Line break style (“lf”, “cr”, “crlf”). +end_of_line = lf + +# Ensure file ends with a line break? +insert_final_newline = true + + +[{*.mk,Makefile,rules}] + +indent_style = tab + + + +# Local variables: +# coding: utf-8 +# mode: conf +# End: +# vim: fileencoding=utf-8 filetype=conf : diff --git a/debian/README.source b/debian/README.source index 7bf3e5e..77405a3 100644 --- a/debian/README.source +++ b/debian/README.source @@ -12,7 +12,7 @@ To build the source package from the Git VCS: * Get the upstream source:: - $ debian/rules get-packaged-orig-source + $ uscan --download-debversion Ensure the upstream source is placed where Git-BuildPackage will find it for building the Debian source package. @@ -42,4 +42,4 @@ To build the source package from the Git VCS: onto the upstream source. - -- Ben Finney <bignose@debian.org>, Sat, 26 Aug 2017 13:45:03 +1000 + -- Ben Finney <bignose@debian.org>, Wed, 9 May 2018 10:03:49 +1000 diff --git a/debian/changelog b/debian/changelog index b4f4507..4704bcc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,34 @@ +python-jsonext (0.4.2-1) unstable; urgency=medium + + [ Ben Finney ] + * New upstream version. + Now includes user documentation. + * Declare conformance to “Standards-Version: 4.4.1”. + * Specify HTTPS URL for upstream source repository. + * Improve consistency of copyright grant in Debian packaging. + * Use a null command for ‘clean’ during ‘Git-BuildPackage’. + * Declare Debhelper compatibility level 12. + * debian/compat: + * Remove obsolescent configuration file. + * Remove ‘get-orig-source’ and ‘get-packaged-orig-source’ targets. + These are no longer mentioned in Debian Policy 4.1.4 and later. + * Update copyright years for Debian packaging. + * Specify current VCS for Debian packaging work. + * Remove ‘debian/patches/migrate-from-times-to-arrow.patch’, now applied + upstream. + * Remove obsolete control field for Python 2 version. + * Remove declaration for minimum Python 3 version. + Python >= 3.4 is now in all supported Debian releases. + * Record upstream metadata in DEP-12 document. + + [ Sandro Tosi ] + * Remove autopkgtest smoke test for Python 2. + * Don't build Python 2 binary packages. + * Remove support for Python 2. + Closes: bug#937855. + + -- Ben Finney <bignose@debian.org> Sat, 26 Oct 2019 12:25:12 +1100 + python-jsonext (0.4.1-1) unstable; urgency=medium * The “علي محمد باقر النمر (Ali Mohammed Baqir al-Nimr)” release. diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control index 5fec2c8..0aef4a8 100644 --- a/debian/control +++ b/debian/control @@ -2,25 +2,18 @@ Source: python-jsonext Maintainer: Ben Finney <bignose@debian.org> Section: python Priority: optional -Standards-Version: 4.0.1 Build-Depends: python3-pytest-runner, python3-arrow, python3-six, python3-setuptools, python3-all, - python-pytest-runner, - python-arrow, - python-six, - python-setuptools, - python-all (>= 2.7~), dh-python, - debhelper (>= 10~) + debhelper-compat (= 12) +Standards-Version: 4.4.1 Homepage: https://pypi.org/project/jsonext/ -VCS-Git: https://anonscm.debian.org/git/users/bignose/debian/pkg-python-jsonext.git -VCS-Browser: https://anonscm.debian.org/git/users/bignose/debian/pkg-python-jsonext.git -X-Python-Version: >= 2.7 -X-Python3-Version: >= 3.3 +VCS-Git: https://salsa.debian.org/bignose/pkg-python-jsonext.git +VCS-Browser: https://salsa.debian.org/bignose/pkg-python-jsonext/ Package: python3-jsonext Architecture: all @@ -32,14 +25,3 @@ Description: serialisation to/from JSON for extra types — Python 3 the standard Python built-in-types. . This package installs the library for Python 3. - -Package: python-jsonext -Architecture: all -Depends: - ${python:Depends}, - ${misc:Depends} -Description: serialisation to/from JSON for extra types — Python 2 - ‘jsonext’ makes easy JSON serialisation of Python objects outside of - the standard Python built-in-types. - . - This package installs the library for Python 2. diff --git a/debian/copyright b/debian/copyright index d40b7eb..58d68fc 100644 --- a/debian/copyright +++ b/debian/copyright @@ -5,17 +5,17 @@ Source: https://pypi.org/project/jsonext/ Files: * Copyright: - © 2014–2015 Marc Brinkmann <git@marcbrinkmann.de> + © 2014–2017 Marc Brinkmann <git@marcbrinkmann.de> License: Expat Files: debian/* Copyright: - © 2009–2017 Ben Finney <bignose@debian.org> + © 2009–2019 Ben Finney <bignose@debian.org> License: GPL-3+ License-Grant: - This is free software; you may copy, modify and/or distribute this work - under the terms of the GNU General Public License, version 3 or later. - No warranty expressed or implied. + This is free software: you may copy, modify, and/or distribute this work + under the terms of the GNU General Public License as published by the + Free Software Foundation; version 3 of that license or any later version. License: Expat diff --git a/debian/gbp.conf b/debian/gbp.conf index c96c7ac..d34c7bd 100644 --- a/debian/gbp.conf +++ b/debian/gbp.conf @@ -1,6 +1,6 @@ # debian/gbp.conf -# Git-buildpackage configuration for this Debian source package. -# Manpage: ‘gbp.conf(5)’. +# Git-Buildpackage configuration for this Debian source package. +# Manual page: ‘gbp.conf(5)’. [DEFAULT] @@ -13,9 +13,13 @@ pristine-tar = false # Create the upstream source from this VCS repository? create-orig = false +# Command to run for invoking package clean. +# This null command works around bug#802284 in Git-BuildPackage. +cleaner = /bin/true + # Local variables: # coding: utf-8 # mode: conf # End: -# vim: fileencoding=utf-8 filetype=conf noexpandtabs : +# vim: fileencoding=utf-8 filetype=conf noexpandtab : diff --git a/debian/patches/migrate-from-times-to-arrow.patch b/debian/patches/migrate-from-times-to-arrow.patch deleted file mode 100644 index 39641f7..0000000 --- a/debian/patches/migrate-from-times-to-arrow.patch +++ /dev/null @@ -1,52 +0,0 @@ -Description: Use arrow instead of times module. -Author: Marc Brinkmann <git@marcbrinkmann.de> -Last-Update: 2015-10-26 22:16:53 +1100 -Comment: - Git commit hash 043a9004902479729220e164c75e0512e371f992. - . - The ‘times’ library is not packaged for Debian; the ‘arrow’ - library is. This change is already incorporated upstream. - ---- old/jsonext/mixins.py -+++ new/jsonext/mixins.py -@@ -1,5 +1,5 @@ - import datetime --import times -+import arrow - - - class JSONDateTimeMixin(object): -@@ -22,9 +22,10 @@ class JSONDateTimeMixin(object): - >>> jsonext.dumps(d) - '"2013-11-17"' - """ -+ - def default(self, o): - if isinstance(o, datetime.datetime): -- return times.format(o, 'Zulu') -+ return arrow.get(o).to('utc').isoformat() - if isinstance(o, datetime.date): - return o.isoformat() - return super(JSONDateTimeMixin, self).default(o) ---- old/setup.py -+++ new/setup.py -@@ -22,5 +22,4 @@ setup( - url='http://github.com/mbr/jsonext', - license='MIT', - packages=find_packages(exclude=['tests']), -- install_requires=['times'], --) -+ install_requires=['arrow'], ) - - - - -Local variables: -coding: utf-8 -mode: diff -time-stamp-format: "%:y-%02m-%02d" -time-stamp-start: "^Last-Update:[ ]+" -time-stamp-end: "$" -time-stamp-line-limit: 20 -End: -vim: fileencoding=utf-8 filetype=diff : diff --git a/debian/patches/series b/debian/patches/series deleted file mode 100644 index 55e4ec5..0000000 --- a/debian/patches/series +++ /dev/null @@ -1 +0,0 @@ -migrate-from-times-to-arrow.patch diff --git a/debian/rules b/debian/rules index a3378ae..263011b 100755 --- a/debian/rules +++ b/debian/rules @@ -3,10 +3,9 @@ # debian/rules # Part of Debian ‘python-jsonext’ package. # -# Copyright © 2009–2017 Ben Finney <bignose@debian.org> -# This is free software; you may copy, modify and/or distribute this work -# under the terms of the GNU General Public License, version 3 or later. -# No warranty expressed or implied. +# This is free software, and you are welcome to redistribute it under +# certain conditions; see the end of this file for copyright +# information, grant of license, and disclaimer of warranty. # Send HTTP traffic to the “discard” service during packaging actions. export http_proxy = http://127.0.1.1:9/ @@ -16,35 +15,7 @@ export PYBUILD_NAME = jsonext %: - dh $@ --with python3,python2 --buildsystem=pybuild - - -.PHONY: get-packaged-orig-source -get-packaged-orig-source: - $(uscan-download-source) --download-current-version - -# Policy §4.9 strongly recommends the ‘get-orig-source’ target: -# “This target is optional, but providing it if possible is a good idea.” -# -# This target is an anomaly: per Policy §4.9, it fetches the *latest* -# upstream source, regardless of this package's version. To fetch the -# upstream source corresponding to this package's *declared* version -# in ‘debian/changelog’, use ‘get-packaged-orig-source’ instead. -.PHONY: get-orig-source -get-orig-source: - $(uscan-download-source) - -get-orig-source get-packaged-orig-source: http_proxy = -get-orig-source get-packaged-orig-source: makefile_dir = $(abspath $(dir $(firstword ${MAKEFILE_LIST}))) -get-orig-source get-packaged-orig-source: package_dir = $(abspath $(dir ${makefile_dir})) - -define uscan-download-source - uscan --noconf --verbose \ - --force-download \ - --rename \ - --destdir=$(CURDIR) \ - --check-dirname-level=0 ${package_dir} -endef # uscan-download-source + dh $@ --with python3 --buildsystem=pybuild override_dh_auto_clean: @@ -52,6 +23,14 @@ override_dh_auto_clean: $(RM) -r ${GENERATED_FILES} +# Copyright © 2009–2019 Ben Finney <bignose@debian.org> +# +# This is free software: you may copy, modify, and/or distribute this work +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 3 of that license or any later version. +# No warranty expressed or implied. + + # Local variables: # mode: makefile # coding: utf-8 diff --git a/debian/tests/control b/debian/tests/control index 7cdae03..ee1fa43 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -2,11 +2,6 @@ # Control file for Debian ‘autopkgtests’. # Documentation: ‘/usr/share/doc/autopkgtest/README.package-tests.rst.gz’. -Tests: smoke-python2 -Depends: - python-pkg-resources, - python-jsonext - Tests: smoke-python3 Depends: python3-pkg-resources, diff --git a/debian/tests/smoke-python2 b/debian/tests/smoke-python2 deleted file mode 100755 index 72493bc..0000000 --- a/debian/tests/smoke-python2 +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/bash -# -# debian/tests/smoke-python2 -# Part of Debian ‘python-jsonext’ package. -# -# Copyright © 2016–2017 Ben Finney <bignose@debian.org> -# This is free software; you may copy, modify and/or distribute this work -# under the terms of the GNU General Public License, version 3 or later. -# No warranty expressed or implied. -# -# Smoke test for package in Python 2 environments. - -set -o errexit -set -o errtrace -set -o nounset - -DISTRIBUTION_NAME=jsonext -MODULE_NAMES=( - jsonext - ) - -test_opts="--distribution=$DISTRIBUTION_NAME" -for mod in ${MODULE_NAMES[@]} ; do - # Accumulate the module names. - test_opts="$test_opts --module=$mod" -done - -for py in $(pyversions -i) ; do - printf "Python command: %s\n" $py - $py debian/tests/smoke_test.py $test_opts - printf "\n" -done - - -# Local variables: -# coding: utf-8 -# mode: shell-script -# End: -# vim: fileencoding=utf-8 filetype=sh : diff --git a/debian/tests/smoke-python3 b/debian/tests/smoke-python3 index 28929cc..578dbd1 100755 --- a/debian/tests/smoke-python3 +++ b/debian/tests/smoke-python3 @@ -3,10 +3,9 @@ # debian/tests/smoke-python3 # Part of Debian ‘python-jsonext’ package. # -# Copyright © 2016–2017 Ben Finney <bignose@debian.org> -# This is free software; you may copy, modify and/or distribute this work -# under the terms of the GNU General Public License, version 3 or later. -# No warranty expressed or implied. +# This is free software, and you are welcome to redistribute it under +# certain conditions; see the end of this file for copyright +# information, grant of license, and disclaimer of warranty. # # Smoke test for package in Python 3 environments. @@ -32,6 +31,14 @@ for py in $(py3versions -i) ; do done +# Copyright © 2016–2019 Ben Finney <bignose@debian.org> +# +# This is free software: you may copy, modify, and/or distribute this work +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 3 of that license or any later version. +# No warranty expressed or implied. + + # Local variables: # coding: utf-8 # mode: shell-script diff --git a/debian/tests/smoke_test.py b/debian/tests/smoke_test.py index a3e1e82..dc221dd 100644 --- a/debian/tests/smoke_test.py +++ b/debian/tests/smoke_test.py @@ -2,10 +2,9 @@ # # debian/tests/smoke_test.py # -# Copyright © 2016–2017 Ben Finney <bignose@debian.org> -# This is free software; you may copy, modify and/or distribute this work -# under the terms of the GNU General Public License, version 3 or later. -# No warranty expressed or implied. +# This is free software, and you are welcome to redistribute it under +# certain conditions; see the end of this file for copyright +# information, grant of license, and disclaimer of warranty. """ Post-install Python smoke test for use in Debian autopkgtest. @@ -122,6 +121,14 @@ if __name__ == "__main__": sys.exit(exit_status) +# Copyright © 2016–2019 Ben Finney <bignose@debian.org> +# +# This is free software: you may copy, modify, and/or distribute this work +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 3 of that license or any later version. +# No warranty expressed or implied. + + # Local variables: # coding: utf-8 # mode: python diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..702b4e6 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,32 @@ +# debian/upstream/metadata +# Part of Debian ‘python-jsonext’ package. +# +# This is free software, and you are welcome to redistribute it under +# certain conditions; see the end of this file for copyright +# information, grant of license, and disclaimer of warranty. + +%YAML 1.1 +--- +# <URL:https://wiki.debian.org/UpstreamMetadata> +Name: jsonext +Homepage: https://github.com/mbr/jsonext +Contact: Marc Brinkmann <git@marcbrinkmann.de> +Archive: PyPI +Bug-Database: https://github.com/mbr/jsonext/issues/ +Bug-Submit: https://github.com/mbr/jsonext/issues/new +Repository: https://github.com/mbr/jsonext.git +Repository-Browse: https://github.com/mbr/jsonext/ + + +# Copyright © 2018–2019 Ben Finney <bignose@debian.org> +# +# This is free software; you may copy, modify, and/or distribute this work +# under the terms of the GNU General Public License, version 3 or later. +# No warranty expressed or implied. +# See the file '/usr/share/common-licenses/GPL-3' for details. + +# Local variables: +# coding: utf-8 +# mode: yaml +# End: +# vim: fileencoding=utf-8 filetype=yaml : diff --git a/debian/watch b/debian/watch index 7ee3ac8..3548368 100644 --- a/debian/watch +++ b/debian/watch @@ -7,7 +7,7 @@ version = 4 # Source tarball from Python Package Index. opts = "uversionmangle=s/(\d)((?:a|b|c|rc)\d*)$/$1~$2/" \ - http://pypi.debian.net/jsonext/ \ + https://pypi.debian.net/jsonext/ \ /jsonext/jsonext-@ANY_VERSION@@ARCHIVE_EXT@ \ debian uupdate diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..5f5cdf2 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +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 " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @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/jsonext.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/jsonext.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/jsonext" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/jsonext" + @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." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @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." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +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." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..a2a044b --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,258 @@ +# -*- coding: utf-8 -*- +# +# jsonext documentation build configuration file, created by +# sphinx-quickstart on Sat Mar 22 21:29:12 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import sphinx_readable_theme + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'jsonext' +copyright = u'2014, Marc Brinkmann' + +# 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 = '0.4.2' +# The full version, including alpha/beta/rc tags. +release = '0.4.2' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'readable' + +# 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 +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +html_theme_path = [sphinx_readable_theme.get_html_theme_path()] + +# The name for this set of Sphinx documents. If None, it defaults to +# "<project> v<release> documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a <link> tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'jsonextdoc' + +# -- 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': '', +} + +# 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 = [ + ('index', 'jsonext.tex', u'jsonext Documentation', u'Marc Brinkmann', + 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [('index', 'jsonext', u'jsonext Documentation', + [u'Marc Brinkmann'], 1)] + +# If true, show URL addresses after external links. +#man_show_urls = False + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'jsonext', u'jsonext Documentation', u'Marc Brinkmann', + 'jsonext', 'One line description of project.', 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..fa4e501 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,81 @@ +jsonext +======= + +jsonext is a small library that collects commonly used implementations of +JSON-serializers for various objects. A good example are +:class:`~datetime.datetime` objects, which are commonly found in web +applications. Since JSON does not know these types, they need to be +serialized to strings - certainly not an impossible task, +but tricky enough to get right when timezones are involved that it's a turn +off to reimplement them every time. + +There are many other libraries on PyPI that somehow deal with this problem +or a related one, though many of those are either dead or do a horrible job +of wrapping the standard JSON library in funky ways. + + +Encoders and Mixins +------------------- + +jsonext works with the standard libraries facilities as closely as possible; +new encoding methods are added as mixins:: + + from json import JSONEncoder + from jsonenc.mixins import JSONDateTimeMixin, JSONIterableMixin + + class MyJSONEncoder(JSONDateTimeMixin, JSONIterableMixin, JSONEncoder): + pass + + # ... + + enc = MyJSONEncoder() + enc.encode(data) + +The example above will encode ``data`` as JSON, +using :class:`~jsonext.mixins.JSONDateTimeMixin` to encode any +:class:`~datetime.datetime` objects found and any iterables using +:class:`~jsonext.mixins.JSONIterableMixin`. All these are just mixins for +the stdlib's :class:`~json.JSONEncoder`. + +Behind the scene these mixins provide a :meth:`~json.JSONEncoder.default` +method that will check for types it can encode and either return the result +or call the superclasses default method. An example implementation for a +custom class ``Foo`` is simple:: + + class JSONFooMixin(object): + def default(self, o): + if isinstance(o, Foo): + # return anything composed of objects the encoder can handle + return ('This is a Foo object as a tuple', Foo.value) + return super(JSONFooMixin, self).default(o) + + +Shortcuts +--------- + +Some shortcuts are provided if less customization is needed. The +`jsonext.JSONEncoder` is a :class:`~jsonext.mixins.JSONEncoder` with some +commonly useful classes mixed in: :class:`~jsonext.mixins.JSONDateTimeMixin`, +:class:`~jsonext.mixins.JSONIterableMixin`, +:class:`~jsonext.mixins.JSONToDictMixin`, +:class:`~jsonext.mixins.JSONStringifyMixin` and +:class:`~jsonext.mixins.json.JSONEncoder`. + +In addition, the :func:`jsonext.dumps` function is the same as +:func:`json.dumps`, except is uses :class:`jsonext.JSONEncoder` as the +encoder per default. This means that:: + + import jsonext + + jsonext.dumps(some_data) + +will just work. + + +API Reference +------------- + +The following mixins are provided: + +.. automodule:: jsonext.mixins + :members: diff --git a/jsonext.egg-info/PKG-INFO b/jsonext.egg-info/PKG-INFO index 9fc7f68..5ce88da 100644 --- a/jsonext.egg-info/PKG-INFO +++ b/jsonext.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: jsonext -Version: 0.4.1 +Version: 0.4.2 Summary: Well-structured helpers to help serializing commonly encountered structures to JSON (like datetime, to_dict(), etc. Home-page: http://github.com/mbr/jsonext Author: Marc Brinkmann diff --git a/jsonext.egg-info/SOURCES.txt b/jsonext.egg-info/SOURCES.txt index 1476aa2..cc5ba70 100644 --- a/jsonext.egg-info/SOURCES.txt +++ b/jsonext.egg-info/SOURCES.txt @@ -1,7 +1,13 @@ +LICENSE +MANIFEST.in README.rst setup.py +docs/Makefile +docs/conf.py +docs/index.rst jsonext/__init__.py jsonext/mixins.py +jsonext/wrappers.py jsonext.egg-info/PKG-INFO jsonext.egg-info/SOURCES.txt jsonext.egg-info/dependency_links.txt diff --git a/jsonext.egg-info/requires.txt b/jsonext.egg-info/requires.txt index f89da44..b1703f4 100644 --- a/jsonext.egg-info/requires.txt +++ b/jsonext.egg-info/requires.txt @@ -1 +1,2 @@ -times
\ No newline at end of file +six +arrow diff --git a/jsonext/__init__.py b/jsonext/__init__.py index ac23cd3..7e7c502 100644 --- a/jsonext/__init__.py +++ b/jsonext/__init__.py @@ -10,8 +10,10 @@ All these are ready to use by using :data:`~jsonext.dumps`. import functools import json -from .mixins import JSONDateTimeMixin, JSONIterableMixin, JSONToDictMixin, \ - JSONStringifyMixin +from .mixins import ( + JSONDateTimeMixin, JSONIterableMixin, JSONToDictMixin, JSONStringifyMixin, +) +from .wrappers import ISO88601Wrapper class JSONEncoder(JSONDateTimeMixin, JSONIterableMixin, JSONToDictMixin, @@ -19,4 +21,7 @@ class JSONEncoder(JSONDateTimeMixin, JSONIterableMixin, JSONToDictMixin, pass +JSONDecoder = ISO88601Wrapper(json.JSONDecoder()) + dumps = functools.partial(json.dumps, cls=JSONEncoder) +loads = JSONDecoder.decode diff --git a/jsonext/mixins.py b/jsonext/mixins.py index ad6c2ac..db414bf 100644 --- a/jsonext/mixins.py +++ b/jsonext/mixins.py @@ -44,6 +44,7 @@ class JSONIterableMixin(object): >>> jsonext.dumps(gen) '[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]' """ + def default(self, o): try: iterable = iter(o) @@ -70,6 +71,7 @@ class JSONToDictMixin(object): >>> jsonext.dumps(items) '[{"A": 1, "B": 2}, {"A": 3, "B": 4}]' """ + def default(self, o): if hasattr(o, 'to_dict'): return o.to_dict() @@ -90,6 +92,7 @@ class JSONStringifyMixin(object): >>> jsonext.dumps(t) '"5 days, 3:25:45"' """ + def default(self, o): if hasattr(o, '__str__'): return str(o) diff --git a/jsonext/wrappers.py b/jsonext/wrappers.py new file mode 100644 index 0000000..8db1920 --- /dev/null +++ b/jsonext/wrappers.py @@ -0,0 +1,73 @@ +import arrow +import datetime +import re + +import six + + +class DecoderWrapper(object): + def __init__(self, decoder): + self._decoder = decoder + + def _convert_dict(self, v): + return {k: self._convert(v) for k, v in six.iteritems(v)} + + def _convert_list(self, v): + return [self._convert(v) for v in iter(v)] + + def _convert_text(self, v): + return v + + def _convert_integer(self, v): + return v + + def _convert_float(self, v): + return v + + def _convert_bool(self, v): + return v + + def _convert_none(self, v): + return v + + def _convert(self, value): + if isinstance(value, dict): + return self._convert_dict(value) + if isinstance(value, list): + return self._convert_list(value) + if isinstance(value, six.text_type): + return self._convert_text(value) + if isinstance(value, six.integer_types): + return self._convert_integer(value) + if isinstance(value, float): + return self._convert_float(value) + if isinstance(value, bool): + return self._convert_bool(value) + if value is None: + return self.convert_none(value) + assert False, 'unreachable' + + def decode(self, *args, **kwargs): + val = self._decoder.decode(*args, **kwargs) + return self._convert(val) + + def raw_recode(self, *args, **kwargs): + val = self._decoder.raw_decode(*args, **kwargs) + return self._convert(val) + + +class ISO88601Wrapper(DecoderWrapper): + DATE_RE = re.compile(r'^\d{4}-\d{2}-\d{2}$') + TIME_RE = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[^\s]*$') + + def _convert_text(self, v): + try: + if self.DATE_RE and self.DATE_RE.match(v): + return arrow.get(v).date() + + if self.TIME_RE and self.TIME_RE.match(v): + return arrow.get(v).to('utc').naive + except arrow.ParserError: + return v + + return v @@ -12,14 +12,14 @@ def read(fname): setup( name='jsonext', - version='0.4.1', + version='0.4.2', description='Well-structured helpers to help serializing commonly ' - 'encountered structures to JSON (like datetime, to_dict(), ' - ' etc.', + 'encountered structures to JSON (like datetime, to_dict(), ' + ' etc.', long_description=read('README.rst'), author='Marc Brinkmann', author_email='git@marcbrinkmann.de', url='http://github.com/mbr/jsonext', license='MIT', packages=find_packages(exclude=['tests']), - install_requires=['arrow'], ) + install_requires=['six', 'arrow'], ) |
