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
- 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
- Super simple editing It's literally three lines of code
import mapchartpy as mc
map = mc.Map()
map.fill_country("Finland", "#002F6C")
- Ability to load existing maps
import mapchartpy as mc
from pathlib import Path
map = mc.Map(save_file=Path("map.txt"))
- Full type hinting The library supports full* type hinting of the Mapchart save file, in addition to some other nice-to-haves.
*: 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
- 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)
- Dead simple installation
It's literally just
pip install mapchartpy
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f9cc327d61e67a1c3d7b07f8522e20634137f3284d32527b3eaa71b396ee561
|
|
| MD5 |
4e105918b098651d22143ac6f6c885dd
|
|
| BLAKE2b-256 |
7ac6b76c8bf6d572f53a803019d8788a5060f341f8c6cf16f1168618c7f39714
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe06833803fac0fa67fdb21e295800f6b4f147865b4a324299248d2b557e99e
|
|
| MD5 |
a514501396747ecf5ff451a0b7546947
|
|
| BLAKE2b-256 |
79e126134519e1b5c86a6edc1c6fffa01cdd837d5150331cf2c030550cf03b38
|