semvec/pypi-packages huggingface dataset:
wasp-spotify-bindings 0.0.1
Python wrapper to control your Spotify client on MacOS
Keywords: spotify api

# WASP
Wrapper around AppleScript of Spotify in Python.

This library provides a simple wrapper around the AppleScript API
of the Spotify application on MacOS.


Developed and tested with Python 3.7

## Install
```bash
pip install wasp-spotify-bindings
```

## Test
```bash
python wasp/tests/test_wasp.py
python wasp/tests/test_applescript.py
```

## Import
```python
from wasp_spotify_bindings.core import Wasp
wasp = Wasp()
```

## API

_Get track metadata._
```python
wasp.get_track()
```

returns

```python
{
    'artist': 'Rick Astley',
    'album': 'Whenever You Need Somebody',
    'disc_number': 1,
    'duration': 213573,
    'played_count': 0,
    'track_number': 1,
    'popularity': 75,
    'id': 'spotify:track:4uLU6hMCjMI75M1A2tKUQC',
    'name': 'Never Gonna Give You Up',
    'album_artist':
    'Rick Astley',
    'artwork_url':
    'http://i.scdn.co/image/15ac2c9091d9b74e841b281ceb23ca8208321444',
    'spotify_url': 'spotify:track:4uLU6hMCjMI75M1A2tKUQC'
}
```

_Get player state._
```python
wasp.get_state()
```
returns
```python
{
    "track_id": "spotify:track:4uLU6hMCjMI75M1A2tKUQC",
    "volume": 49,
    "position": 3,  # seconds
    "state": "playing"
}
```

_Start Spotify application._
```python
wasp.start_spotify()
```

_Quit Spotify application._
```python
wasp.quit_spotify()
```

_Play next track._
```python
wasp.next_track()
```

_Play previous track._
```python
wasp.previous_track()
```

_Play current track._
```python
wasp.play()
```

_Toggle play/pause on current track._
```python
wasp.play_pause()
```

_Pause current track._
```python
wasp.pause()
```

_Set volume to [0-100]_
```python
wasp.set_volume(volume=10)
```

_Play track referred to by spotify id._
```python
wasp.play_track(spotify_uri='spotify:track:4uLU6hMCjMI75M1A2tKUQC')
```

_Play track in context of an album/playlist._
```python
wasp.play_track_in_context(
    spotify_uri='spotify:track:4uLU6hMCjMI75M1A2tKUQC',
    context='spotify:track:4uLU6hMCjMI75M1A2tKUQC'
)
```

_Increase volume by 10._
```python
wasp.volume_up()
```

_Decrease volume by 10._
```python
wasp.volume_down()
```

_Jump to position in song (seconds)._
```python
wasp.jump_to(jump_to_second=5)
```

_Check if repeat is enabled._
```python
wasp.is_repeating()
```

_Check if shuffle is enabled._
```python
wasp.is_shuffling()
```

_Set repeating to `True` or `False`._
```python
wasp.set_repeating(set_repeating=True)
```

_Set shuffling to `True` or `False`._
```python
wasp.set_shuffling(set_shuffling=True)
```

_Toggle repeat on/off._
```python
wasp.toggle_repeating()
```

_Toggle shuffle on/off._
```python
wasp.toggle_shuffling()
```

_Mute player._
```python
wasp.mute()
```

_Unmute player._
```python
wasp.unmute()
```
django-metro 0.4.5
Basic metro models for Django 1.7+,     plus the parser that fills models with actual data     (lines numbers, lines titles, lines colors, the names     of the lines, the station names) from various data     sources (primary - Wikipedia). 

django-metro
============

Metro models for Django (for 2+, for django 1.x support use 0.4.2
version), plus the parser that fills models with actual data from
various data providers (primary - Wikipedia). This is renamed
django-russian-metro package (!).

All russian and cis parsers (like kiev or minsk) respects locale, that’s
why for en locale they returns transliterated version of names. Parsers
for other cities takes only english names.

Parser downloads the following data:

-  MetroLine: number, color and title
-  Metro: line binding, title

Also you can run django command sometimes to get always actual data, or
use celery task load_metro.

Installing
==========

1. For install django-metro, run on terminal:

   ::

       $ pip install django-metro

2. Then add this app to ``INSTALLED_APPS``:

   ::

       INSTALLED_APPS = (
           ...
           'metro',
           ...
       )

3. Apply migrations:

   ::

       ./manage.py migrate

4. Choose and specify data provider in ``settings.py``:

   ::

       METRO_PROVIDER = 'moscow'

5. Finally, fill models with data:

   ::

       ./manage.py load_metro

6. Or:

   ::

       from metro.parser import provider
       provider.download_all()

7. Or use celery task ``load_metro`` (shared task in ``tasks.py``)

Current available data providers
================================

(list updated)
''''''''''''''

Assign ``METRO_PROVIDER`` (in settings.py) one of the values below
(source indicated in brackets):

Russia
''''''

-  ``'moscow'`` – Moscow (Wiki)
-  ``'spb'`` – Saint Petersburg (Wiki)
-  ``'novgorod'`` – Nizhny Novgorod (Wiki)
-  ``'novosib'`` – Novosibirsk (Wiki)
-  ``'ekat'`` – Yekaterinburg (Wiki/self)
-  ``'kazan'`` – Kazan (Wiki)
-  ``'samara'`` – Samara (Wiki)
-  ``'omsk'`` – Omsk (self) :)

CIS
'''

-  ``'kiev'`` – Kiev (Wiki)
-  ``'minsk'`` – Minsk (Wiki)

World
'''''

-  ``'tokyo'`` – Tokyo (Wiki)
-  ``'london'`` – London (Wiki), very basic (without zones and branches)

Other stuff
===========

You can rename application title with ``METRO_APP_TITLE`` in your
``settings.py``:

::

   METRO_APP_TITLE = u'Saint Petersrburg Metro'

Adopted for django-suit (SortableStackedInline).

License
=======

MIT probably.
pyramid-keycloak 0.0.13
Keycloak based authentication policy for Pyramid

# Keycloak based authentication policy for Pyramid framework


Authentication policy which uses Keycloak's OpenID API via a client
to authenticate the user. It uses cookies to hold the access token and
the refresh token.

This package is dependant on the package `python-keycloak`.

## Usage

```python
from keycloak import KeycloakOpenID
from pyramid.config import Configurator
from keycloak_auth_policy import KeycloakBasedAuthenticationPolicy

def main():
    openid_client = KeycloakOpenID(...)
    config = Configurator()
    config.set_authentication_policy(
        KeycloakBasedAuthenticationPolicy(openid_client))
```

You have to handle the redirect logic in your forbidden view based on your 
needs:

```python
from pyramid.httpexceptions import HTTPFound, HTTPForbidden
from pyramid.request import Request
from pyramid.view import forbidden_view_config

@forbidden_view_config()
def forbidden_view(request: Request):
    if ...: # user has no privileges
        raise HTTPForbidden("You don't have permissions for this action")

    # Keycloak's URL to redirect to where the user can log in
    url = ...

    # you can either redirect to the URL or return it if you have a client 
    # which consumes your API
    return HTTPFound(url)
``` 

You also need to have a callback endpoint where Keycloak redirects to after a 
successful login

```python
from keycloak.exceptions import KeycloakError
from pyramid.httpexceptions import HTTPFound
from pyramid.request import Request
from pyramid.view import view_defaults, view_config


@view_defaults(renderer='json')
class AuthApi:

    def __init__(self, request: Request) -> None:
        self.request = request
        self._openid_client = ... # get OpenID client

    @view_config(route_name='auth.exchange', request_method='GET',
                 permission='public')
    def exchange(self):
        try:
            token_response = self._openid_client.exchange(
                self.request.GET.get("code"),
                self.request.route_url("auth.exchange")) # the redirect URI
        except KeycloakError as e:
            ... # handle exception

        access_token = token_response.get("access_token")
        refresh_token = token_response.get("refresh_token")

        # set the tokens as cookies to the client and return a response
        # you can either redirect from here or if your application is consumed
        # as an API you can return a successful response
        response = HTTPFound(...)
        response.set_cookie("refresh_token_cookie_name", refresh_token)
        response.set_cookie("access_token_cookie_name", access_token)

        return response
```

You can also implement a logout endpoint if you feel like to

```python
from pyramid.security import forget

    ...

    @view_config(route_name='auth.logout', request_method='GET',
                 permission='private')
    def logout(self):
        headers = forget(self.request)
        response = self.request.response
        response.headerlist.extend(headers)
        return response
```

For more information see the docstrings of each method in the source.