semvec/pypi-packages huggingface dataset:
csession 0.1.4
Create a custom Session wrapped around the requests.Session
Requires Python: >=3.6

# CSession

The `csession` package implements a simple wrapper class around the 
[Session](https://github.com/psf/requests/blob/master/requests/sessions.py) class of the 
[requests](https://github.com/psf/requests) module called `CustomSession` that give more freedom to the 
programmer to customize his session by for example setting a default timeout or headers.

## Installation

`pip install csession`

## Usage
 
The core of the package is the `CustomSession` class which mostly acts just like a normal `Session`

```python
from csession import CustomSession

csess = CustomSession()

_ = csess.get("http://myurl.com")
_ = csess.post("http://myurl.com")
```

additionally, the `CustomSesion` accepts all the parameters for a request in the constructor to be set as default

```python
from csession import CustomSession

csess = CustomSession(timeout=30, headers={'Content-type': 'application/json'})

# all upcoming requests will timeout after 30 seconds and have a Content-type json header

...
```

the `CustomSession` can also set a default prepare methode to  manipulate the request
before they are sent. This is for example useful for authentication purposes or url prefixing.
Here is a example for a session that is prefixing every request and also adding a default password an appId
to the json body of a request

```python
from csession import CustomSession

config = {...}

# prepare function accepts methode url and params and also returns those again
# params are formatted as a dict
def prepare_microlog_request(methode, url, params):
    url = "https://my-default-url_prefix"+ url
    params["json"] = dict(params["json"], **{
        'appId': config['APP_ID'],
        'password': config['PASSWORD'],
    })
    return methode, url, params


# Use this Session to make requests to microlog
csess = CustomSession(
    timeout=100,
    headers={'Content-type': 'application/json'},
    prepare=prepare_microlog_request
)

csess.get("/path/to/endpoint")
```

if for a single call the prepare methode should be suppressed you can do:
```python
from csession import CustomSession
csess = CustomSession(prepare=...)

csess.use_prepare = False
csess.get("http://www.url_without_prepare.com")
csess.use_prepare = True
```
or equivalently use the provided context manager:
```python
from csession import CustomSession, without_preparation
csess = CustomSession(prepare=...)

with without_preparation(csess) as sess:
    sess.get("http://www.url_without_prepare.com")
```

The `CustomSession` also provides a simple history function in for of a deque.
History is deactivated by default but can be activated in the constructor by setting 
`save_last_requests=`

```python
from csession import CustomSession, without_preparation

csess = CustomSession(save_last_requests=3) # the last 3 requests are stored

csess.get("http://www.myurl.com")

print(csess.history)

```
allen-py-client 1.2.101
Unofficial python wrapper for Allen's web API.
Keywords: python,allen

=============
AllenPyClient
=============

AllenPyClient is an unofficial Python wrapper to develop applications integrating Allen's official web API.

|Code Quality| |PyPi| |Docs| |License| |Followers|

.. |License| image:: https://img.shields.io/github/license/lamergameryt/allen-py-client
.. |Followers| image:: https://img.shields.io/github/followers/lamergameryt?style=social
.. |PyPi| image:: https://badge.fury.io/py/allen-py-client.svg
    :target: https://badge.fury.io/py/allen-py-client
.. |Docs| image:: https://readthedocs.org/projects/allenpyclient/badge/?version=latest
    :target: https://allenpyclient.readthedocs.io/en/latest/?badge=latest
.. |Code Quality| image:: https://img.shields.io/lgtm/grade/python/github/lamergameryt/allen-py-client
    :target: https://lgtm.com/projects/g/lamergameryt/allen-py-client/alerts/

⏩ Quick Example
----------------

In this example, we will fetch the links of the videos available to us.

``main.py``

.. code-block:: python

    from allen import AllenClient
    import os

    env = os.environ
    user = env['user']
    passwd = env['passwd']

    client = AllenClient(username=user, password=passwd)
    videos = client.get_recorded_videos()
    for video in videos:
        link = video.get_link()

        # Print the video link with the subject name and recording date
        print(f'{video.subject_name} ({video.get_recording_date()}) - {link}')

You can also use the library from a command line.

::

    $ allen help
    $ allen videos

👩‍🏫 Installation
------------------

::

    pip install allen-py-client

📈 Required Python Modules
--------------------------

The list of required python modules can be found in the ``requirements.txt`` file.

📜 Documentation
----------------

To view the documentation for this project, visit the `documentation page <https://allenpyclient.readthedocs.io/en/latest/>`_.