semvec/pypi-packages huggingface dataset:
oec 0.3.0
API Wrapper for The Observatory for Economic Complexity
License: MIT
Requires Python: >=3

# Python Wrapper for The Observatory for Economic Complexity API

**Language:** Python 3  
**Data Source:** [Observatory for Economic Complexity (OEC)](https://legacy.oec.world/en/resources/data/)

## Status

As of June 2021, the OEC has migrated to a new website at [oec.world](https://oec.world/), and this new site no longer hosts a free API. There is a legacy version of the site hosted at [legacy.oec.world](https://legacy.oec.world/en/), and this library has been updated to refer to that legacy version.

## Installation

```bash
pip install oec
```

## Usage

### Get data from OEC

```python
import oec

# Set parameters in accordance with API documentation
params = {'classification': 'hs92',
          'trade_flow': 'export',
          'year': 2015,
          'origin': 'egy',
          'destination': 'all',
          'product': 'show'}

list_of_countries = oec.get_countries()
list_of_products = oec.get_products(params['classification'])
list_of_exports = oec.get_trade(**params)
```

These functions each return lists of dictionaries. Each of these dictionaries represents a "row" of data (e.g. one country or product). The fields of these dictionaries represent "columns" of data. This is easier to visualize if you output your data to a CSV file.

### Export to CSV

```python
oec.data_to_csv(list_of_dictionaries, 'results.csv')
```

These CSV files can then be opened up in the spreadsheet editor of your choice for further analysis.

### Generate links to visualizations

```python
>>> oec.url_visual(**params)
'https://legacy.oec.world/en/visualize/tree_map/hs92/export/egy/all/show/2015/'
>>> oec.embed_visual(**params)
'<iframe src="https://legacy.oec.world/en/visualize/embed/tree_map/hs92/export/egy/all/show/2015/" width=930 height=400></iframe>'
>>> oec.url_visual(**params, language='fr')
'https://legacy.oec.world/fr/visualize/tree_map/hs92/export/egy/all/show/2015/'
```

## Documentation

**Function-level documentation and language list:** see [`help.txt`](https://github.com/yahiaali/oec/blob/master/help.txt) or run `python -m pydoc oec`  
**[OEC API documentation](https://legacy.oec.world/api/)**  
**[Data attributes and field names](https://github.com/alexandersimoes/oec/wiki/Attributes)**

## Acknowledgements

Credits to [Alex Simoes](https://github.com/alexandersimoes) for the development of [The Observatory for Economic Complexity](https://legacy.oec.world/en/). This module was developed by [Yahia Ali](https://github.com/yahiaali), who is not affiliated in any way with the OEC team.
pet-pet-gif 1.0.2
Generate a petting gif from a static image (known as "petpet", "Pet the X", or "PETTHE").
License: MIT
Keywords: petpet,petthe,gif

# pet-pet-gif
Python adaptation of https://github.com/aDu/pet-pet-gif  

![](https://raw.githubusercontent.com/camprevail/pet-pet-gif/main/example/froge-petpet.gif)
![](https://raw.githubusercontent.com/camprevail/pet-pet-gif/main/example/oshaberi-petpet.gif)
![](https://raw.githubusercontent.com/camprevail/pet-pet-gif/main/example/sadcat-petpet.gif)


### Usage:
```py
from petpetgif import petpet  
petpet.make(source, dest)
```
- source:  A filename (string), pathlib.Path object or a file object. (This parameter corresponds
           and is passed to the PIL.Image.open() method.)
   

- dest: A filename (string), pathlib.Path object or a file object. (This parameter corresponds
           and is passed to the PIL.Image.save() method.)
  
Basic example:
```py
from petpetgif import petpet
petpet.make('test.png', 'out.gif')
```

Discord.py example:
```py
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from io import BytesIO
from typing import Union, Optional
from petpetgif import petpet as petpetgif

load_dotenv()
token = os.getenv('DISCORD_BOT_TOKEN')

client = commands.Bot(command_prefix='!')

@client.event
async def on_ready():
    print('Bot is ready.')

@client.command()
async def pet(ctx, image: Optional[Union[discord.PartialEmoji, discord.member.Member]]):
    if type(image) == discord.PartialEmoji:
        image = await image.url_as(format='png').read() # retrieve the image bytes
    elif type(image) == discord.member.Member:
        image = await image.avatar_url_as(format='png').read() # retrieve the image bytes
    else:
        await ctx.reply('Please use a custom emoji or tag a member to petpet their avatar.')
        return

    source = BytesIO(image) # file-like container to hold the emoji in memory
    dest = BytesIO() # container to store the petpet gif in memory
    petpetgif.make(source, dest)
    dest.seek(0) # set the file pointer back to the beginning so it doesn't upload a blank file.
    await ctx.send(file=discord.File(dest, filename=f"{image[0]}-petpet.gif"))


client.run(token)
```