From 928b86ea1c351ef61492857876ba090bf04363cc Mon Sep 17 00:00:00 2001 From: Grazfather Date: Tue, 15 Sep 2015 11:16:22 -0700 Subject: [PATCH 1/2] setup.py: Decode README.rst as utf-8 If LANG was not set on python3, opening this file (which happens when installing) would fail because the README.rst contains non-ascii characters. Using `codecs` we can explicitly decode it as utf-8. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a539f6e..1bfb248 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from setuptools import setup +import codecs import schema @@ -13,7 +14,7 @@ keywords="schema json validation", url="http://github.com/halst/schema", py_modules=['schema'], - long_description=open('README.rst').read(), + long_description=codecs.open('README.rst', 'r', 'utf-8').read(), classifiers=[ "Development Status :: 3 - Alpha", "Topic :: Utilities", From 8f1e3559ea4986724bba072b5fe5ae74a13ca003 Mon Sep 17 00:00:00 2001 From: Grazfather Date: Tue, 15 Sep 2015 11:17:19 -0700 Subject: [PATCH 2/2] Remove non-ascii bytes from README.rst --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index b5a9ffd..11668b7 100644 --- a/README.rst +++ b/README.rst @@ -59,7 +59,7 @@ Use `pip `_ or easy_install:: pip install schema==0.3.1 -Alternatively, you can just drop ``schema.py`` file into your project—it is +Alternatively, you can just drop ``schema.py`` file into your project--it is self-contained. - **schema** is tested with Python 2.6, 2.7, 3.2, 3.3 and PyPy. @@ -95,7 +95,7 @@ Callables If ``Schema(...)`` encounters a callable (function, class, or object with ``__call__`` method) it will call it, and if its return value evaluates to -``True`` it will continue validating, else—it will raise ``SchemaError``. +``True`` it will continue validating, else--it will raise ``SchemaError``. .. code:: python @@ -123,7 +123,7 @@ If ``Schema(...)`` encounters a callable (function, class, or object with If ``Schema(...)`` encounters an object with method ``validate`` it will run this method on corresponding data as ``data = obj.validate(data)``. This method may raise ``SchemaError`` exception, which will tell ``Schema`` that that piece -of data is invalid, otherwise—it will continue validating. +of data is invalid, otherwise--it will continue validating. As example, you can use ``Use`` for creating such objects. ``Use`` helps to use a function or type to convert a value while validating it: