Skip to main content

Some utilities for modifying or creating save files from mapchart.net

Project description

mapchartpy

A super simple library to manage and create Mapchart save files.

Getting started

  1. Please make sure your code editor has support for intellisense in Python. This library has typing for basically everything, so it'll make your life a lot easier.
Opening a map
```python
import mapchartpy as mc
from pathlib import Path

map = mc.Map(save_file=Path("map.txt"))
```
Creating a new map
```python
import mapchartpy as mc

map = mc.Map()
```
Highlighting a country
```python
import mapchartpy as mc

map = mc.Map()
map.fill_country("Finland", "#002F6C")
```

You can find a list of countries available by running

```python
import mapchartpy as mc

countries = mc.Map.get_countries_and_territories()
print(countries)

# >> ['Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czechia', 'Denmark'...
```
Highlighting US states
```python
import mapchartpy as mc

map = mc.Map()
map.fill_country("USA_Kentucky", "#A3080B")
```

States are generally formatted as "US_(State)"

You can find a list of states available by running

```python
import mapchartpy as mc

territories = mc.Map.get_countries_and_territories()

for territory in territories:
    if territory.startswith("US"):
        print(territory)

```
Creating a map of a specific region
For example, here's europe:

```python
import mapchartpy as mc

map = mc.Map()
map.set_map_type("europe")
```
Saving the map file
```python
import mapchartpy as mc
import json

map = mc.Map()
map.fill_country("Finland", "#002F6C")

with open("output.txt", "w") as f:
    json.dump(map.get_file(), f)
```

Features

  1. Super simple editing It's literally three lines of code
import mapchartpy as mc

map = mc.Map()
map.fill_country("Finland", "#002F6C")
  1. Ability to load existing maps
import mapchartpy as mc
from pathlib import Path

map = mc.Map(save_file=Path("map.txt"))
  1. Full type hinting The library supports full* type hinting of the Mapchart save file, in addition to some other nice-to-haves.

Image of autocomplete working in countries Image of autocomplete working on the raw data file Image of autocomplete working on a function

*: Type hinting may not be available for special properties. If you encounter a situation where you don't have full type hinting, please make an issue on our GitHub

  1. Exporting to Mapchart's file format
import mapchartpy as mc
import json

map = mc.Map()
map.fill_country("Finland", "#002F6C")

with open("output.txt", "w") as f:
    json.dump(map.get_file(), f)
  1. Dead simple installation It's literally just pip install mapchartpy

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

mapchartpy-0.0.3.tar.gz (98.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mapchartpy-0.0.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file mapchartpy-0.0.3.tar.gz.

File metadata

  • Download URL: mapchartpy-0.0.3.tar.gz
  • Upload date:
  • Size: 98.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for mapchartpy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 2f9cc327d61e67a1c3d7b07f8522e20634137f3284d32527b3eaa71b396ee561
MD5 4e105918b098651d22143ac6f6c885dd
BLAKE2b-256 7ac6b76c8bf6d572f53a803019d8788a5060f341f8c6cf16f1168618c7f39714

See more details on using hashes here.

File details

Details for the file mapchartpy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: mapchartpy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for mapchartpy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cfe06833803fac0fa67fdb21e295800f6b4f147865b4a324299248d2b557e99e
MD5 a514501396747ecf5ff451a0b7546947
BLAKE2b-256 79e126134519e1b5c86a6edc1c6fffa01cdd837d5150331cf2c030550cf03b38

See more details on using hashes here.

Supported by

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