CodeStats

Wrapper around the Code::Stats API


License
Other
Install
pip install CodeStats==1.1.0

Documentation

CodeStats

Build Status Coverage Status

A simple wrapper around the Code::Stats API. Currently this wrapper only supports getting information from the API and presenting it in a 'Pythonic' way. Posting new stats to the API is a feature that might be added in the future.

Sync Usage

from codestats.api import User

user = User('niekkeijzer')

Or if you prefer to call the load method yourself, you can disable auto_load.

from codestats.api import User

user = User('niekkeijzer', auto_load=False)

You can also get a single language or machine instance by using the get method.

from codestats.api import User
from codestats.bases import Language

user = User('niekkeijzer')
python = user.get('Python', Language)

Or by using the shorthands

from codestats.api import User

user = User('niekkeijzer')
python = user.get_language('python')
work_pc = user.get_machine('work')

Async usage

As of version 1.1.0 the library can be used in a non blocking manner as well. For this asyncio and aiohttp should be installed. The User object should be loaded differently, however the other methods work the same as the synchronous object.

from codestats.async_api import User

async def load_user(name):
    async with User(name) as user:
        print(user)

Or without auto loading enabled.

from codestats.async_api import User

async def load_user(name):
    async with User(name, auto_load=False) as user:
        await user.load()

User, Machine and Language instances each have properties to calculate the level based on the current level as well as the progress to the next level. The formula used to calculate these values is the same as is used by the official API.

License

This code is released under the MIT license, see the included LICENSE file for more information.