From ec778fee154d82f24bc0fc111cecb937ea5391d0 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Tue, 14 Jan 2014 23:35:53 -0500 Subject: Improve syntaxt to more closely match pep8 standard, in particular docstrings --- pies/__init__.py | 45 +++++++++++++++++++-------------------- pies/_utils.py | 57 +++++++++++++++++++++++++------------------------- pies/functools.py | 23 ++++++++++---------- pies/overrides.py | 30 +++++++++++++------------- pies/urllib/request.py | 2 -- 5 files changed, 78 insertions(+), 79 deletions(-) (limited to 'pies') diff --git a/pies/__init__.py b/pies/__init__.py index d768f63..80aa9c3 100644 --- a/pies/__init__.py +++ b/pies/__init__.py @@ -1,32 +1,31 @@ -""" - pies/__init__.py +"""pies/__init__.py. - Adds necessary hooks to allow Python code to run on multiple major versions of Python at once - (currently 2.6 - 3.x) +Adds necessary hooks to allow Python code to run on multiple major versions of Python at once +(currently 2.6 - 3.x) - Usage: - Anywhere you want to gain support for multiple versions of Python simply add the following two lines - from __future__ import absolute_import, division, print_function, unicode_literals - from pies.overrides import * +Usage: + Anywhere you want to gain support for multiple versions of Python simply add the following two lines + from __future__ import absolute_import, division, print_function, unicode_literals + from pies.overrides import * - And for changed stdlibs: - from pies import [libname] + And for changed stdlibs: + from pies import [libname] - Copyright (C) 2013 Timothy Edmund Crosley +Copyright (C) 2013 Timothy Edmund Crosley - 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: +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 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. -""" +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. +""" __version__ = "2.5.5" diff --git a/pies/_utils.py b/pies/_utils.py index 2098ccb..5010eea 100644 --- a/pies/_utils.py +++ b/pies/_utils.py @@ -1,43 +1,42 @@ -""" - pies/_utils.py +"""pies/_utils.py. + +Utils internal to the pies library and not meant for direct external usage. - Utils internal to the pies library and not meant for direct external usage. +Copyright (C) 2013 Timothy Edmund Crosley - Copyright (C) 2013 Timothy Edmund Crosley +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: - 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 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. - 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. """ import abc import sys def with_metaclass(meta, *bases): - """ - Enables use of meta classes across Python Versions. - taken from jinja2/_compat.py + """Enables use of meta classes across Python Versions. taken from jinja2/_compat.py. + + Use it like this:: - Use it like this:: + class BaseForm(object): + pass - class BaseForm(object): - pass + class FormType(type): + pass - class FormType(type): - pass + class Form(with_metaclass(FormType, BaseForm)): + pass - class Form(with_metaclass(FormType, BaseForm)): - pass """ class metaclass(meta): __call__ = type.__call__ @@ -50,10 +49,12 @@ def with_metaclass(meta, *bases): def unmodified_isinstance(*bases): - """ - When called in the form MyOverrideClass(unmodified_isinstance(BuiltInClass)) + """When called in the form + + MyOverrideClass(unmodified_isinstance(BuiltInClass)) + + it allows calls against passed in built in instances to pass even if there not a subclass - it allows calls against passed in built in instances to pass even if there not a subclass """ class UnmodifiedIsInstance(type): if sys.version_info[0] == 2 and sys.version_info[1] <= 6: diff --git a/pies/functools.py b/pies/functools.py index 2f2c157..2e79a45 100644 --- a/pies/functools.py +++ b/pies/functools.py @@ -19,19 +19,20 @@ if sys.version_info < (3, 2): def lru_cache(maxsize=100): """Least-recently-used cache decorator. - Taking from: https://github.com/MiCHiLU/python-functools32/blob/master/functools32/functools32.py - with slight modifications. + Taking from: https://github.com/MiCHiLU/python-functools32/blob/master/functools32/functools32.py + with slight modifications. - If *maxsize* is set to None, the LRU features are disabled and the cache - can grow without bound. + If *maxsize* is set to None, the LRU features are disabled and the cache + can grow without bound. - Arguments to the cached function must be hashable. + Arguments to the cached function must be hashable. - View the cache statistics named tuple (hits, misses, maxsize, currsize) with - f.cache_info(). Clear the cache and statistics with f.cache_clear(). - Access the underlying function with f.__wrapped__. + View the cache statistics named tuple (hits, misses, maxsize, currsize) with + f.cache_info(). Clear the cache and statistics with f.cache_clear(). + Access the underlying function with f.__wrapped__. - See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used + See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used + """ def decorating_function(user_function, tuple=tuple, sorted=sorted, len=len, KeyError=KeyError): hits, misses = [0], [0] @@ -80,12 +81,12 @@ if sys.version_info < (3, 2): return result def cache_info(): - """Report CACHE statistics""" + """Report CACHE statistics.""" with lock: return _CacheInfo(hits[0], misses[0], maxsize, len(CACHE)) def cache_clear(): - """Clear the CACHE and CACHE statistics""" + """Clear the CACHE and CACHE statistics.""" with lock: CACHE.clear() hits[0] = misses[0] = 0 diff --git a/pies/overrides.py b/pies/overrides.py index c826897..751013a 100644 --- a/pies/overrides.py +++ b/pies/overrides.py @@ -1,23 +1,23 @@ -""" - pies/overrides.py +"""pies/overrides.py. + +Overrides Python syntax to conform to the Python3 version as much as possible using a '*' import - Overrides Python syntax to conform to the Python3 version as much as possible using a '*' import +Copyright (C) 2013 Timothy Edmund Crosley - Copyright (C) 2013 Timothy Edmund Crosley +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: - 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 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. - 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. """ from __future__ import absolute_import diff --git a/pies/urllib/request.py b/pies/urllib/request.py index a1470f1..f2ebb61 100644 --- a/pies/urllib/request.py +++ b/pies/urllib/request.py @@ -1,5 +1,3 @@ - - from __future__ import absolute_import from ..version_info import PY3 -- cgit v1.2.1