From e457f64281cee4ca1de41cf91d5bb68928aedf60 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Tue, 23 Oct 2012 17:55:07 -0700 Subject: [PATCH 01/14] Add TODO re: the _PartialNode class. --- TODO.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.md b/TODO.md index b8a568a5..94635f59 100644 --- a/TODO.md +++ b/TODO.md @@ -7,6 +7,8 @@ In development branch: * Add Python 3.3 to tox file (after deprecating 2.4). * Turn the benchmarking script at pystache/tests/benchmark.py into a command in pystache/commands, or make it a subcommand of one of the existing commands (i.e. using a command argument). +* Look into bypassing the _PartialNode class so that partials can be loaded + and parsed at parse-time instead of at render-time. * Provide support for logging in at least one of the commands. * Make sure command parsing to pystache-test doesn't break with Python 2.4 and earlier. * Combine pystache-test with the main command. From 45c69218a6baf7a23dce886c629215575587cb42 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 4 Nov 2012 16:46:52 -0800 Subject: [PATCH 02/14] Prep for version 0.6.0. --- HISTORY.md | 5 +++++ pystache/__init__.py | 2 +- setup.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1cca5c85..5aac5f22 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,11 @@ History **Note:** Official support for Python 2.4 will end with Pystache version 0.6.0. +0.6.0 (TBD) +----------- + +- TODO + 0.5.3 (2012-11-03) ------------------ diff --git a/pystache/__init__.py b/pystache/__init__.py index 71708c38..ff3150f2 100644 --- a/pystache/__init__.py +++ b/pystache/__init__.py @@ -10,4 +10,4 @@ __all__ = ['parse', 'render', 'Renderer', 'TemplateSpec'] -__version__ = '0.5.3' # Also change in setup.py. +__version__ = '0.6.0-alpha' # Also change in setup.py. diff --git a/setup.py b/setup.py index 4cb2e78a..6e9aff42 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ setup = dist.setup -VERSION = '0.5.3' # Also change in pystache/__init__.py. +VERSION = '0.6.0-alpha' # Also change in pystache/__init__.py. FILE_ENCODING = 'utf-8' From 5a9bd7e020f80eb248115df7a8027cf3d0ab5f62 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 4 Nov 2012 16:51:11 -0800 Subject: [PATCH 03/14] Add to setup.py info about running the setup.py register command. --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index 6e9aff42..8279bd04 100644 --- a/setup.py +++ b/setup.py @@ -52,6 +52,11 @@ When you have permissions, run the following: + # This uploads the version metadata. + # TODO: update our custom publish command to include register. + python setup.py register + + # This uploads the *.tar.gz file. python setup.py publish If you get an error like the following-- From 367305df9e2a4afe2dd9d31a987ca3b94b476780 Mon Sep 17 00:00:00 2001 From: Kevin Yank Date: Sun, 15 Sep 2013 15:09:31 +1000 Subject: [PATCH 04/14] Fix syntax error in Python 3.3. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “Unicode Raw” strings are no longer supported in Python 3.3, and cause a syntax error. See http://bugs.python.org/issue15096. Without this fix, Pystache gives a syntax error when used in a Python 3.3 environment. --- pystache/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pystache/parser.py b/pystache/parser.py index c6a171f0..c3c5ef09 100644 --- a/pystache/parser.py +++ b/pystache/parser.py @@ -12,7 +12,7 @@ END_OF_LINE_CHARACTERS = [u'\r', u'\n'] -NON_BLANK_RE = re.compile(ur'^(.)', re.M) +NON_BLANK_RE = re.compile(u'^(.)', re.M) # TODO: add some unit tests for this. From 76c509e72bc948d02f5a2a3797e4906864a174ba Mon Sep 17 00:00:00 2001 From: Kevin Yank Date: Sun, 15 Sep 2013 15:21:28 +1000 Subject: [PATCH 05/14] Fix another Python 3.3 syntax error. --- pystache/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pystache/parser.py b/pystache/parser.py index c3c5ef09..ae8fc0e7 100644 --- a/pystache/parser.py +++ b/pystache/parser.py @@ -147,7 +147,7 @@ def __repr__(self): def render(self, engine, context): template = engine.resolve_partial(self.key) # Indent before rendering. - template = re.sub(NON_BLANK_RE, self.indent + ur'\1', template) + template = re.sub(NON_BLANK_RE, self.indent + u'\\1', template) return engine.render(template, context) From 9765f2633db6ee41711a61d48675acc96b9ed010 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 08:58:30 -0700 Subject: [PATCH 06/14] Add PYTHONHASHSEED to the test output. --- HISTORY.md | 2 ++ pystache/tests/main.py | 1 + 2 files changed, 3 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 5aac5f22..1f703352 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,8 @@ History 0.6.0 (TBD) ----------- +- Added [`PYTHONHASHSEED`](http://docs.python.org/using/cmdline.html#envvar-PYTHONHASHSEED) + to the test output. - TODO 0.5.3 (2012-11-03) diff --git a/pystache/tests/main.py b/pystache/tests/main.py index 8af6b2ee..eefeca24 100644 --- a/pystache/tests/main.py +++ b/pystache/tests/main.py @@ -89,6 +89,7 @@ def main(sys_argv): """ # TODO: use logging module print "pystache: running tests: argv: %s" % repr(sys_argv) + print "pystache: PYTHONHASHSEED: %r" % os.getenv('PYTHONHASHSEED') should_source_exist = False spec_test_dir = None From f05776adf699afc6dbb865bfc1b9ce69d346c803 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 09:24:32 -0700 Subject: [PATCH 07/14] Add test_pystache.sh for testing PYTHONHASHSEED values. --- test_pystache.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 test_pystache.sh diff --git a/test_pystache.sh b/test_pystache.sh new file mode 100755 index 00000000..4d4cfcbe --- /dev/null +++ b/test_pystache.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# This wrapper script is useful for running tests with different +# PYTHONHASHSEED values. +# +# Sample usage: +# +# $ ./test_pystache.sh [ARGS] +# +export PYTHONHASHSEED=$RANDOM +python test_pystache.py "$@" From 996d12f384fcde6c7823da1066713e4d83541950 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 09:44:37 -0700 Subject: [PATCH 08/14] Fix a flaky doctest. Make repr() deterministic for the class pystache.tests.common.Attachable added for issue #99. --- HISTORY.md | 5 ++++- pystache/tests/common.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 1f703352..922d9952 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,7 +8,10 @@ History - Added [`PYTHONHASHSEED`](http://docs.python.org/using/cmdline.html#envvar-PYTHONHASHSEED) to the test output. -- TODO +- Added `test_pystache.sh` wrapper script for testing different + PYTHONHASHSEED values. +- Bugfix: fixed a flaky doctest by making `repr()` deterministic for the + `Attachable` class in `pystache.tests.common` 0.5.3 (2012-11-03) ------------------ diff --git a/pystache/tests/common.py b/pystache/tests/common.py index 222e14f2..c87e26ea 100644 --- a/pystache/tests/common.py +++ b/pystache/tests/common.py @@ -232,6 +232,8 @@ def __init__(self, **kwargs): setattr(self, arg, value) def __repr__(self): + # Sort self.__args__.iteritems() so that repr() does not depend on + # Python's hash seed (e.g. PYTHONHASHSEED). return "%s(%s)" % (self.__class__.__name__, - ", ".join("%s=%s" % (k, repr(v)) - for k, v in self.__args__.iteritems())) + ", ".join("%s=%s" % (k, repr(v)) for k, v in + sorted(self.__args__.iteritems()))) From a0857922093af7906ab6fd053e00f44a494e646c Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 09:48:41 -0700 Subject: [PATCH 09/14] Add TODO's re: PYTHONHASHSEED. --- TODO.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.md b/TODO.md index f8778692..cd812e02 100644 --- a/TODO.md +++ b/TODO.md @@ -3,6 +3,8 @@ TODO In development branch: +* Randomize PYTHONHASHSEED when running tests in tox. +* Randomize PYTHONHASHSEED when running tests in Travis CI. * Figure out a way to suppress center alignment of images in reST output. * Add a unit test for the change made in 7ea8e7180c41. This is with regard to not requiring spec tests when running tests from a downloaded sdist. From 42a612f41c2d80d6b0eebef655429e5f876fcd8c Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 10:20:13 -0700 Subject: [PATCH 10/14] Set PYTHONHASHSEED to "random" when running tox. --- HISTORY.md | 1 + tox.ini | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 922d9952..44f52312 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -10,6 +10,7 @@ History to the test output. - Added `test_pystache.sh` wrapper script for testing different PYTHONHASHSEED values. +- Set PYTHONHASHSEED to "random" when running tox. - Bugfix: fixed a flaky doctest by making `repr()` deterministic for the `Attachable` class in `pystache.tests.common` diff --git a/tox.ini b/tox.ini index d1eaebfb..17cb5a2d 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,11 @@ changedir = {envbindir} commands = pystache-test {toxinidir} +setenv = + # TODO: pass in an explicit random value so that we can display the + # value when running tests. We can probably do this by having tox + # call a wrapper shell script. + PYTHONHASHSEED = random # Check that the spec tests work with PyYAML. [testenv:py27-yaml] From eb3fc2df4ff564e684b1aa631b7d2de535bee834 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 10:26:40 -0700 Subject: [PATCH 11/14] Rerun 'python setup.py prep' with pandoc 1.10.1. --- setup_description.rst | 86 ++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/setup_description.rst b/setup_description.rst index e4a09004..04addbad 100644 --- a/setup_description.rst +++ b/setup_description.rst @@ -10,23 +10,23 @@ Pystache .. figure:: https://secure.travis-ci.org/defunkt/pystache.png :alt: Travis CI current build status -`Pystache `_ is a Python -implementation of `Mustache `_. Mustache is -a framework-agnostic, logic-free templating system inspired by -`ctemplate `_ and -`et `_. +`Pystache `__ is a Python +implementation of `Mustache `__. Mustache +is a framework-agnostic, logic-free templating system inspired by +`ctemplate `__ and +`et `__. Like ctemplate, Mustache "emphasizes separating logic from presentation: it is impossible to embed application logic in this template language." -The `mustache(5) `_ man page -provides a good introduction to Mustache's syntax. For a more complete -(and more current) description of Mustache's behavior, see the official -`Mustache spec `_. +The `mustache(5) `__ man +page provides a good introduction to Mustache's syntax. For a more +complete (and more current) description of Mustache's behavior, see the +official `Mustache spec `__. -Pystache is `semantically versioned `_ and can be -found on `PyPI `_. This version of -Pystache passes all tests in `version -1.1.2 `_ of the spec. +Pystache is `semantically versioned `__ and can be +found on `PyPI `__. This version +of Pystache passes all tests in `version +1.1.2 `__ of the spec. Requirements ------------ @@ -34,27 +34,27 @@ Requirements Pystache is tested with-- - Python 2.4 (requires simplejson `version - 2.0.9 `_ or earlier) + 2.0.9 `__ or earlier) - Python 2.5 (requires - `simplejson `_) + `simplejson `__) - Python 2.6 - Python 2.7 - Python 3.1 - Python 3.2 - Python 3.3 -- `PyPy `_ +- `PyPy `__ -`Distribute `_ (the setuptools +`Distribute `__ (the setuptools fork) is recommended over -`setuptools `_, and is required +`setuptools `__, and is required in some cases (e.g. for Python 3 support). If you use -`pip `_, you probably already satisfy +`pip `__, you probably already satisfy this requirement. JSON support is needed only for the command-line interface and to run the spec tests. We require simplejson for earlier versions of Python -since Python's `json `_ module -was added in Python 2.6. +since Python's `json `__ +module was added in Python 2.6. For Python 2.4 we require an earlier version of simplejson since simplejson stopped officially supporting Python 2.4 in simplejson @@ -129,9 +129,9 @@ directory), use the ``Renderer`` class like above. One can pass attributes to the Renderer class constructor or set them on a Renderer instance. To customize template loading on a per-view basis, subclass ``TemplateSpec``. See the docstrings of the -`Renderer `_ +`Renderer `__ class and -`TemplateSpec `_ +`TemplateSpec `__ class for more information. You can also pre-parse a template: @@ -174,7 +174,7 @@ This section describes how Pystache handles unicode, strings, and encodings. Internally, Pystache uses `only unicode -strings `_ +strings `__ (``str`` in Python 3 and ``unicode`` in Python 2). For input, Pystache accepts both unicode strings and byte strings (``bytes`` in Python 3 and ``str`` in Python 2). For output, Pystache's template rendering methods @@ -214,7 +214,7 @@ To test from a source distribution (without installing)-- python test_pystache.py To test Pystache with multiple versions of Python (with a single -command!), you can use `tox `_: +command!), you can use `tox `__: :: @@ -238,15 +238,15 @@ runs: git submodule update The test harness parses the spec's (more human-readable) yaml files if -`PyYAML `_ is present. Otherwise, it -parses the json files. To install PyYAML-- +`PyYAML `__ is present. Otherwise, +it parses the json files. To install PyYAML-- :: pip install pyyaml To run a subset of the tests, you can use -`nose `_: +`nose `__: :: @@ -268,11 +268,11 @@ To convert the code to Python 3 manually (while using Python 3)-- This writes the converted code to a subdirectory called ``build``. By design, Python 3 builds -`cannot `_ +`cannot `__ be created from Python 2. To convert the code without using setup.py, you can use -`2to3 `_ as follows (two +`2to3 `__ as follows (two steps)-- :: @@ -293,7 +293,7 @@ Pystache while using Python 3. Mailing List ------------ -There is a `mailing list `_. +There is a `mailing list `__. Note that there is a bit of a delay between posting a message and seeing it appear in the mailing list archive. @@ -307,9 +307,9 @@ Credits Author: Chris Wanstrath Maintainer: Chris Jerdonek -Pystache logo by `David Phillips `_ is +Pystache logo by `David Phillips `__ is licensed under a `Creative Commons Attribution-ShareAlike 3.0 Unported -License `_. +License `__. |image0| History @@ -318,6 +318,18 @@ History **Note:** Official support for Python 2.4 will end with Pystache version 0.6.0. +0.6.0 (TBD) +----------- + +- Added + ```PYTHONHASHSEED`` `__ + to the test output. +- Added ``test_pystache.sh`` wrapper script for testing different + PYTHONHASHSEED values. +- Set PYTHONHASHSEED to "random" when running tox. +- Bugfix: fixed a flaky doctest by making ``repr()`` deterministic for + the ``Attachable`` class in ``pystache.tests.common`` + 0.5.3 (2012-11-03) ------------------ @@ -335,8 +347,8 @@ History parse tree. - Added support for rendering pre-compiled templates. - Added Python 3.3 to the list of supported versions. -- Added support for `PyPy `_ (issue #125). -- Added support for `Travis CI `_ (issue #124). +- Added support for `PyPy `__ (issue #125). +- Added support for `Travis CI `__ (issue #124). [msabramo] - Bugfix: ``defaults.DELIMITERS`` can now be changed at runtime (issue #135). [bennoleslie] @@ -385,7 +397,7 @@ Below is a selection of some of the changes (not exhaustive). Highlights: - Pystache now passes all tests in version 1.0.3 of the `Mustache - spec `_. [pvande] + spec `__. [pvande] - Removed View class: it is no longer necessary to subclass from View or from any other class to create a view. - Replaced Template with Renderer class: template rendering behavior @@ -395,7 +407,7 @@ Highlights: per-view basis by subclassing from TemplateSpec. - Introduced separation of concerns and removed circular dependencies (e.g. between Template and View classes, cf. `issue - #13 `_). + #13 `__). - Unicode now used consistently throughout the rendering process. - Expanded test coverage: nosetests now runs doctests and ~105 test cases from the Mustache spec (increasing the number of tests from 56 From 5d79f3273784008931938d189be8b649c5aea125 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 10:27:10 -0700 Subject: [PATCH 12/14] Close issue #138. --- TODO.md | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO.md b/TODO.md index cd812e02..0d427418 100644 --- a/TODO.md +++ b/TODO.md @@ -5,7 +5,6 @@ In development branch: * Randomize PYTHONHASHSEED when running tests in tox. * Randomize PYTHONHASHSEED when running tests in Travis CI. -* Figure out a way to suppress center alignment of images in reST output. * Add a unit test for the change made in 7ea8e7180c41. This is with regard to not requiring spec tests when running tests from a downloaded sdist. * End support for Python 2.4. From 4b41dd6bec9bdfc4efa5cf8da772e2c0a38c5320 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 10:41:57 -0700 Subject: [PATCH 13/14] Remove py24 from tox.ini and add py33. --- TODO.md | 4 +--- tox.ini | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 0d427418..dd34b8d6 100644 --- a/TODO.md +++ b/TODO.md @@ -7,13 +7,11 @@ In development branch: * Randomize PYTHONHASHSEED when running tests in Travis CI. * Add a unit test for the change made in 7ea8e7180c41. This is with regard to not requiring spec tests when running tests from a downloaded sdist. -* End support for Python 2.4. -* Add Python 3.3 to tox file (after deprecating 2.4). +* Finish removing references to Python 2.4 and noting end of support. * Look into bypassing the _PartialNode class so that partials can be loaded and parsed at parse-time instead of at render-time. * Turn the benchmarking script at pystache/tests/benchmark.py into a command in pystache/commands, or make it a subcommand of one of the existing commands (i.e. using a command argument). * Provide support for logging in at least one of the commands. -* Make sure command parsing to pystache-test doesn't break with Python 2.4 and earlier. * Combine pystache-test with the main command. diff --git a/tox.ini b/tox.ini index 17cb5a2d..a539a374 100644 --- a/tox.ini +++ b/tox.ini @@ -3,9 +3,8 @@ # http://pypi.python.org/pypi/tox # [tox] -# Tox 1.4 drops py24 and adds py33. In the current version, we want to -# support 2.4, so we can't simultaneously support 3.3. -envlist = py24,py25,py26,py27,py27-yaml,py27-noargs,py31,py32,pypy +# Tox stopped supporting py24 as of version 1.4. +envlist = py25,py26,py27,py27-yaml,py27-noargs,py31,py32,py33,pypy [testenv] # Change the working directory so that we don't import the pystache located From 856925f3ca4de6ca5a709aa8f3cd10a4962573a3 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sun, 15 Sep 2013 10:42:56 -0700 Subject: [PATCH 14/14] Add TODO re: tox documentation. --- TODO.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO.md b/TODO.md index dd34b8d6..d0b13c46 100644 --- a/TODO.md +++ b/TODO.md @@ -8,6 +8,7 @@ In development branch: * Add a unit test for the change made in 7ea8e7180c41. This is with regard to not requiring spec tests when running tests from a downloaded sdist. * Finish removing references to Python 2.4 and noting end of support. +* In the README, state which version of tox is expected. * Look into bypassing the _PartialNode class so that partials can be loaded and parsed at parse-time instead of at render-time. * Turn the benchmarking script at pystache/tests/benchmark.py into a command