PY-STRAWPOLL
Python wrapper for Strawpoll’s API. Provides methods for reading from and writing to strawpoll via its JSON api.
About
py-strawpoll provides the following:
StrawpollAPIReader class containing methods:
from_json(string): Read a strawpoll into memory from its JSON representation
from_url(url): Read a strawpoll into memory from it’s URL (uses API endpoint to fetch)
from_apiv2(poll_id): Read a strawpoll into memory via it’s poll id (uses API endpoint to fetch)
total_votes()
normalize(): Normalize a poll to the [0, 1] range
votes_for(option_string): Get the raw count of votes for a specific option string
normalized_votes_for(option_string): Get the normalized votes for a specific option string
winner(): Who won the poll?
loser(): Least favoured option
to_clean_dict(): Returns a python dictionary representation of the poll. Ignores any atributes that are null
Usage
Installation
TODO: Create a PyPI package
Fetching a strawpoll
from strawpoll import StrawpollAPIReader
json_string = '{
"title":"What movie should we watch again?",
"options": [
"Sucker punch ",
"Pirates of carribian ",
"Prison logic","Witchhunter"
],
"multi":false,
"permissive": false,
"captcha": true
}'
# Fetch a poll through its API id
poll_a = StrawpollAPIReader.from_apiv2(1)
# Fetch a poll through its URL
poll_b = StrawpollAPIReader.from_url("https://strawpoll.me/1")
# Fetch a poll from its JSON dump
poll_c = StrawpollAPIReader.from_json(json_string)
# These should be the same
if (poll_a == poll_b) and (poll_b == poll_c):
print "Mirror images!"
# Yada yada normalize your data
print poll_a.normalize()
Posting a strawpoll
TODO: APIWriter still in the pipes
Changelog
Metadata
Release files for PyStrawpoll 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PyStrawpoll-0.1.4.zip | 6.6 kB | Without provenance | Details for PyStrawpoll-0.1.4.zip |
Release files / PyStrawpoll-0.1.4.zip
| Download URL | PyStrawpoll-0.1.4.zip |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95b4efb83aa6bef788f03deda84ca77ac89dd7791c26a66dd8f9993883a39748
|
|
BLAKE2b-256 checksum How to use checksums |
87294d756deedb95227963317ac4252398c40016936efb804d66ee69751d850a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for PyStrawpoll 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.