Simplifies the encoding and decoding of Regional Indicator Symbols
Project description
RISify
RISify is a Python library and CLI for working with Regional Indicator Symbols (RIS) — the Unicode characters used to represent country and region flags.
It provides:
- Encoding and decoding between RIS, ASCII, and HTML entities
- Upper- and lowercase ASCII variants
- Safe HTML output using markupsafe
- Concatenation and comparison support
Licensed under the AGPLv3.0
The RISify logo uses the Twemoji project © 2017 Twitter, licensed under CC-BY 4.0.
Installation
RISify is available on PyPI:
pip install RISify
Or install directly from source:
git clone git@forgejo.parcifal.dev:parcifal/ris-py.git
cd ris-py
pip install .
Usage (API)
Basic Conversion
from ris import ris
# decode a country code to RIS
pt = ris("PT")
print(pt) # 🇵🇹
HTML to RIS
de = ris("🇩🇪").encode("unicode")
print(de) # 🇩🇪
RIS to ASCII (upper/lower)
nl = ris("🇳🇱").encode("ascii").upper()
print(nl) # NL
eu = ris("🇪🇺").encode("ascii").lower()
print(eu) # eu
RIS to HTML
fo = ris("🇫🇴").encode("html")
print(fo) # 🇫🇴
Concatenation
print("spam " + pt + " bacon " + de + " sausage " + nl + " eggs " + eu + " ham " + fo)
# spam 🇵🇹 bacon 🇩🇪 sausage 🇳🇱 eggs 🇪🇺 ham 🇫🇴
Usage (CLI)
Installing RISify also provides a ris command-line tool:
ris NL # 🇳🇱
Options
usage: ris [-h] [-a | -A | -u | -H] [-v] [-l OUTPUT_LOG] [-V] value
Convert a country code to a RIS code.
positional arguments:
value input text (ascii, ris or html) to convert
optional arguments:
-h, --help show this help message and exit
-a, --ascii output as a country code in lowercase ascii
-A, --ASCII output as a country code in uppercase ascii
-u, --unicode output as a ris code in unicode (default)
-H, --html output as a ris code in html
-v, --verbose increase verbosity
-l OUTPUT_LOG, --output-log OUTPUT_LOG
output log file (defaults to stdout)
-V, --version show program's version number and exit
Examples
# convert iso country code to ris
ris PT # 🇵🇹
# convert ris to ascii uppercase
ris 🇳🇱 --ASCII # NL
# convert ris to ascii lowercase
ris 🇪🇺 --ascii # eu
# convert iso country code to html entities
ris FO --html # 🇫🇴
# increase verbosity and log to file
ris PT -vvv -l ris.log
Contributing
Found a bug? Have a suggestion? Open an issue or submit a merge request at the Forgejo repository. All contributions are welcome.
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
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 risify-1.2.6.tar.gz.
File metadata
- Download URL: risify-1.2.6.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bfdeb15d46361169892790cdd9d5bd6b8d62384615195736cb8b62b1076e160
|
|
| MD5 |
521391f1b2a5e4b26cbd0c6b2d3e8f08
|
|
| BLAKE2b-256 |
8be680c2c2bbe236ce43b0cad7e9035293b68a3e41993f3ad148c2c43242914c
|
File details
Details for the file risify-1.2.6-py3-none-any.whl.
File metadata
- Download URL: risify-1.2.6-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d32deba1cc4cfa0a47478a5d19badf9bda03d43c8b341756c2a6d36b8ff6ad7
|
|
| MD5 |
647ff6a126b267e6fe09df88f06d238b
|
|
| BLAKE2b-256 |
93892401483ec062df2d0463b325a5eb00d4d674efd3c39fdf77913178349dfd
|