semvec/pypi-packages huggingface dataset:
generic-decorators 1.0.3
Generic Python Decorators for use in any project
License: MIT
Requires Python: >=3.0

# generic-decorators

Generic Python Decorators for use in any project.

## Install

`generic-decorators` is released to public PyPI - [generic-decorators](https://pypi.org/project/generic-decorators/). It can be installed using this command:
```
pip install generic-decorators
```

## Decorators

### `make_parallel` 

**Summary**: runs function in parallel instead of sequencial for loop.

**Example**

Parallel trigger of functions `sample_function` with 1 param `list_of_post_ids`
using `make_parallel` decorator and equivalent sequential trigger using `for loop`.

```python
def parallel_function_trigger():
    list_of_post_ids = list(range(1, 20))
    return make_parallel(sample_function)(list_of_post_ids)

#equivalent sequencial version
def serial_function_trigger():
    list_of_post_ids = list(range(1, 20))

    # Serial way of calling the function
    results = []
    for post_id in list_of_post_ids:
        res = sample_function(post_id)
        results.append(res)
    return results

```

You can use below [timing](#timing) decorator to compare time of above parallel 
and sequential versions.

### `make_parallel_processes`

**Description**: Similar functionality like [make_parallel](#make_parallel) but 
uses `mulitprocessing` instead of `threading`.

**Example**

```python
def parallel_function_trigger():
    list_of_post_ids = list(range(1, 20))
    return make_parallel_processes(sample_function)(list_of_post_ids)
```

### `timing` 

**Summary**: calculate and print how much time function processing took.

**Example**

```python
@timing
def sleep_n_seconds(n: int):
    time.sleep(n)

sleep_n_seconds(5)
```

It should print something like this (time can differ):
```
func:'sleep_n_seconds' args:[(5,), {}] took: 5.0047 sec
```

### `singleton` 

**Summary**: make class Singleton - class which will have max 1 instance created

**Example**

```python
@singleton
class MyClass(object):
    """docstring for MyClass"""
    def __init__(self):
        pass

for i in range(0, 10):
    obj = MyClass()
    print(obj)
```

It should print something like this (all objects of class are the same):
```
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
<__main__.MyClass object at 0x7fc3bc38fc50>
```
open-close-mixin 1.1.3
Easy plugin for open-close class objects
License: MIT
Keywords: plugin,mixin,decorator

# open-close-mixin

## About
Easy pluggable Mixin (and decorators) for objects that may benefit from open-close dynamics.

## Installing 
You can simply install it using *pip* as follows:
```console
$ pip install open-close-mixin
```

## Usage
You may import an `OpenCloseMixin` along some other decorators from the package root and use them further on to create your own class with open and close dynamics!
```python
>>> from open_close_mixin import OpenCloseMixin, always

>>> class Foo(OpenCloseMixin):
>>>     # only while open, that's default behaviour
>>>     def run_when_open(self):
>>>         print("The instance is open so I was able to run")
>>> 
>>>     @always
>>>     def run_always(self):
>>>         print("I am ALWAYS able to run, whether the instance is open or not")
>>> 
>>> f = Foo()
>>> f.open()
>>> f.run_always()
I am ALWAYS able to run, whether the instance is open or not
>>> 
>>> f.run_when_open()
The instance is open so I was able to run
>>> 
>>> f.close()
>>> f.run_always()
I am ALWAYS able to run, whether the instance is open or not
>>> 
>>> f.run_when_open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alberto/Projects/personal/open-close-mixin/open_close_mixin/decorators.py", line 27, in wrapper
    raise exception from None
ValueError: The instance is not open and the method "Foo.run_when_open" cannot run under such condition.
```
ElasticEmailWebApiClient 1.0.9
Easily send emails with Elastic Email using Web API Python Client https://elasticemail.com/
License: MIT
Keywords: elastic email elasticemail web api transactional

**This library allows you to quickly and easily use the Elastic Email Web API v2 via Python.**

# Prerequisites #
* [An Elastic Email account](https://elasticemail.com/account/)

# About #
ElasticEmail.WebApiClient is guided and supported by the ElasticEmail Dev Team.

ElasticEmail.WebApiClient is maintained and funded by Elastic Email Inc. The names and logos for ElasticEmail.WebApiClient are trademarks of Elastic Email Inc.

![logo](https://elasticemail.com/files/ee_200x200.png)