Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Download-URL: https://github.com/afriemann/simple_tools/archive/0.2.0.post2.tar.gz
Description: Simple Tools
============
.. image:: https://travis-ci.org/AFriemann/simple_tools.svg?branch=master
:target: https://travis-ci.org/AFriemann/simple_tools
.. image:: https://badge.fury.io/py/simple_tools.svg
:target: https://badge.fury.io/py/simple_tools
A collection of various snippets and tools that come up regularly.
.. code:: python
>>> from mock import Mock
decorators
----------
timeout
~~~~~~~
.. code:: python
>>> import time
>>> from simple_tools.decorators.time import timeout
>>> from simple_tools.exceptions import TimeoutException
>>> @timeout(3)
... def long_running_task():
... time.sleep(5)
>>> long_running_task() # doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TimeoutException: execution of <function long_running_task at ...> timed out after 3s
errors
~~~~~~
.. code:: python
>>> from simple_tools.decorators.errors import not_implemented
>>> @not_implemented
... def some_method():
... pass
>>> some_method() # doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
NotImplementedError
regular expressions
-------------------
.. code:: python
>>> from simple_tools.regex import true
>>> for value in ('y', 'yE', 'tru', 'True', '1'):
... assert true.match(value)
lists
-----
.. code:: python
>>> from simple_tools.lists import find
>>> l = [Mock(a=1, b=1), Mock(a=2), Mock(a=1, b=2)]
>>> find(lambda e: e.a == 1, l).b == 1
True
strings
-------
.. code:: python
>>> from simple_tools.strings import compact
>>> s = "a multiline string\n \n \nwith serveral\nunnecessary\n\n linebreaks"
>>> print(compact(s))
a multiline string
with serveral
unnecessary
linebreaks
www
---
.. code:: python
>>> from simple_tools.www import url
>>> url.join('http://example.org', 'foo', 'bar', baz='bam')
'http://example.org/foo/bar?baz=bam'
files
-----
.. code:: python
>>> from simple_tools.files import walk_up
>>> for root, parent, files in walk_up('/tmp'):
... print('%s -> %s' % (root, parent))
/tmp -> /
/ -> /
Keywords: snippets
Platform: linux
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Download-URL: https://github.com/afriemann/simple_tools/archive/0.2.0.post2.tar.gz
Description: Simple Tools
============
.. image:: https://travis-ci.org/AFriemann/simple_tools.svg?branch=master
:target: https://travis-ci.org/AFriemann/simple_tools
.. image:: https://badge.fury.io/py/simple_tools.svg
:target: https://badge.fury.io/py/simple_tools
A collection of various snippets and tools that come up regularly.
.. code:: python
>>> from mock import Mock
decorators
----------
timeout
~~~~~~~
.. code:: python
>>> import time
>>> from simple_tools.decorators.time import timeout
>>> from simple_tools.exceptions import TimeoutException
>>> @timeout(3)
... def long_running_task():
... time.sleep(5)
>>> long_running_task() # doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
TimeoutException: execution of <function long_running_task at ...> timed out after 3s
errors
~~~~~~
.. code:: python
>>> from simple_tools.decorators.errors import not_implemented
>>> @not_implemented
... def some_method():
... pass
>>> some_method() # doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
NotImplementedError
regular expressions
-------------------
.. code:: python
>>> from simple_tools.regex import true
>>> for value in ('y', 'yE', 'tru', 'True', '1'):
... assert true.match(value)
lists
-----
.. code:: python
>>> from simple_tools.lists import find
>>> l = [Mock(a=1, b=1), Mock(a=2), Mock(a=1, b=2)]
>>> find(lambda e: e.a == 1, l).b == 1
True
strings
-------
.. code:: python
>>> from simple_tools.strings import compact
>>> s = "a multiline string\n \n \nwith serveral\nunnecessary\n\n linebreaks"
>>> print(compact(s))
a multiline string
with serveral
unnecessary
linebreaks
www
---
.. code:: python
>>> from simple_tools.www import url
>>> url.join('http://example.org', 'foo', 'bar', baz='bam')
'http://example.org/foo/bar?baz=bam'
files
-----
.. code:: python
>>> from simple_tools.files import walk_up
>>> for root, parent, files in walk_up('/tmp'):
... print('%s -> %s' % (root, parent))
/tmp -> /
/ -> /
Keywords: snippets
Platform: linux
Release files for simple_tools 0.2.0.post2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| simple_tools-0.2.0.post2.tar.gz | 6.7 kB | Details |
Release files / simple_tools-0.2.0.post2.tar.gz
| Download URL | simple_tools-0.2.0.post2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
699d057c2710495bc2455aea54c8e4e42cb34e25e18428bbfece9cfdacbebd9b
|
|
BLAKE2b-256 checksum How to use checksums |
81031bb6dee60317e6ef733bb6a7aa7215075f855eb72f4a37d1c07cb78a6008
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |