From 1c7e73148f7d64049503be23e1f2bb4a853be8ab Mon Sep 17 00:00:00 2001 From: William Stewart Date: Mon, 19 May 2014 15:18:09 +0200 Subject: [PATCH 1/4] Change the README from Markdown to rst. --- README.md | 56 ---------------------------------------- README.rst | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 56 deletions(-) delete mode 100644 README.md create mode 100644 README.rst diff --git a/README.md b/README.md deleted file mode 100644 index b3e5e96..0000000 --- a/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Property caching - -[![Build Status](https://travis-ci.org/yola/property-caching.png)](https://travis-ci.org/yola/property-caching) - -Cached version of property - -Written and used by the folks at Yola to support our [free website builder][1]. - -## Overview - -- `cached_property` - stores results of decorated methods in decorated object -(in `_cached_properties` attribute) -- `class_cached_property` - stores results of decorated methods in the class of decorated object -(in `_class_cached_properties` attribute). All instances will share cached value. -- `clear_property_cache` - deletes cached value (works for object cached properties only) -- `set_property_cache` - explicitly sets property cache (works for object cached properties only) -- `is_property_cached` - allows to check whether property was cached or not (works for object cached properties only) - -## Usage -```python -from property_caching import (cached_property, - class_cached_property, - clear_property_cache, - set_property_cache) - -class Dummy: - @cached_property - def foo(self): - return self.service.expensive_operation() - - @class_cached_property - def service(self): - return expensive_service_initialization() - -d = Dummy() -d.foo # calculates result and stores it in d._cached_properties -d.foo # uses cached value - -clear_property_cache(d, 'foo') # clears cache for property `foo` -set_property_cache(d, 'foo', 42) # explicitly set cache for property `foo` - -d2 = Dummy() -d2.foo # re-calculates value of `foo` but uses cached service -``` - -## Testing - -Install development requirements: - - pip install -r requirements.txt - -Run the tests with: - - nosetests - -[1]:https://www.yola.com/ diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fa43305 --- /dev/null +++ b/README.rst @@ -0,0 +1,76 @@ +Property caching +================ +.. |Build Status| image:: https://travis-ci.org/yola/property-caching.png + :target: https://travis-ci.org/yola/property-caching + + +Cached version of property + +Written and used by the folks at Yola to support our `free website +builder`_. + +Overview +-------- + +- ``cached_property`` - stores results of decorated methods in + decorated object + (in ``_cached_properties`` attribute) +- ``class_cached_property`` - stores results of decorated methods in + the class of decorated object + (in ``_class_cached_properties`` attribute). All instances will share + cached value. +- ``clear_property_cache`` - deletes cached value (works for object + cached properties only) +- ``set_property_cache`` - explicitly sets property cache (works for + object cached properties only) +- ``is_property_cached`` - allows to check whether property was cached + or not (works for object cached properties only) + +Usage +----- + +.. code:: python + + from property_caching import (cached_property, + class_cached_property, + clear_property_cache, + set_property_cache) + + class Dummy: + @cached_property + def foo(self): + return self.service.expensive_operation() + + @class_cached_property + def service(self): + return expensive_service_initialization() + + d = Dummy() + d.foo # calculates result and stores it in d._cached_properties + d.foo # uses cached value + + clear_property_cache(d, 'foo') # clears cache for property `foo` + set_property_cache(d, 'foo', 42) # explicitly set cache for property `foo` + + d2 = Dummy() + d2.foo # re-calculates value of `foo` but uses cached service + +Testing +------- + +Install development requirements: + +:: + + pip install -r requirements.txt + +Run the tests with: + +:: + + nosetests + +.. _free website builder: https://www.yola.com/ + +.. |Build Status| image:: https://travis-ci.org/yola/property-caching.png + :target: https://travis-ci.org/yola/property-caching From 26edc28a25e1fe1ed4f2ec450c186dc38dfc54f6 Mon Sep 17 00:00:00 2001 From: William Stewart Date: Mon, 19 May 2014 15:18:35 +0200 Subject: [PATCH 2/4] Fix the README, since we don't use nose for running tests anymore --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fa43305..a51b500 100644 --- a/README.rst +++ b/README.rst @@ -68,7 +68,7 @@ Run the tests with: :: - nosetests + python setup.py test .. _free website builder: https://www.yola.com/ From 447e35c873707938d94420c6fe181d2ad373245f Mon Sep 17 00:00:00 2001 From: William Stewart Date: Mon, 19 May 2014 15:21:18 +0200 Subject: [PATCH 3/4] Fix build status images --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index a51b500..fb01ce7 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Property caching ================ -.. |Build Status| image:: https://travis-ci.org/yola/property-caching.png - :target: https://travis-ci.org/yola/property-caching +.. image:: https://travis-ci.org/yola/property-caching.svg?branch=fix/md-to-rst + :target: https://travis-ci.org/yola/property-caching Cached version of property @@ -72,5 +72,5 @@ Run the tests with: .. _free website builder: https://www.yola.com/ -.. |Build Status| image:: https://travis-ci.org/yola/property-caching.png - :target: https://travis-ci.org/yola/property-caching +.. image:: https://travis-ci.org/yola/property-caching.svg?branch=fix/md-to-rst + :target: https://travis-ci.org/yola/property-caching From af59ca174c00a209865c6914c32ce9138b2d147c Mon Sep 17 00:00:00 2001 From: William Stewart Date: Mon, 19 May 2014 15:24:39 +0200 Subject: [PATCH 4/4] Bumps version --- CHANGELOG.md | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f4b127..4b21e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.0.3 +* Converted README from markdown to reStructuredText so it works on PyPi. + ## 1.0.2 * Adds Python 3 support diff --git a/setup.py b/setup.py index 29a5f4d..8ee34ee 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='property-caching', - version='1.0.2', + version='1.0.3', description='Property caching', author='Yola', author_email='engineers@yola.com',