Skip to main content

Asynchronous NationStates API wrapper for Python

Project description

sans

pypi Code style: black Build Status

Synchronous / Asynchronous NationStates (Python wrapper for the NationStates API)

Installing

python3 -m pip install -U sans

Development version:

python3 -m pip install -U https://github.com/zephyrkul/sans/archive/master.zip#egg=sans

Examples

Asynchronous

import asyncio
import sans
from lxml import etree

async def main():
    request = sans.Api(
        "fullname population flag census",
        nation="darcania",
        mode="score",
        scale="65 66",
    )
    root = await request
    pretty = etree.tostring(root, encoding=str, pretty_print=True)
    print(pretty)


asyncio.run(main())  # Python 3.7+ only

Synchronous

import sans
from lxml import etree

def main():
    sans.run_in_thread()
    request = sans.Api(
        "fullname population flag census",
        nation="darcania",
        mode="score",
        scale="65 66",
    )
    root = request.threadsafe()
    pretty = etree.tostring(root, encoding=str, pretty_print=True)
    print(pretty)


main()

Command Line

python3 -m sans --nation darcania
>>> --nation testlandia
>>> exit

Requirements

  • Python 3.6+
  • aiohttp
  • lxml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sans-0.0.1a0.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

sans-0.0.1a0-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page