import json import csv import xml.etree.ElementTree as ET # 0 def read_file(path: str) -> list: with open(path, "r", encoding="utf-8") as f: return read_string(f.read()) # 1 def read_string(data: str) -> list: data = data.strip() if data.startswith("[") or data.startswith("{"): return _from_json(data) if data.startswith("<?xml") or data.startswith("<"): return _from_xml(data) return _from_csv(data) def _from_json(data: str): raw = json.loads(data) result = [] for item in raw: braille_raw = item.get("braille") if isinstance(braille_raw, str): braille = [b.strip() for b in braille_raw.split(",")] else: braille = braille_raw result.append(( item.get("letter"), braille, int(item.get("pattern")) )) return result def _from_csv(data: str): result = [] reader = csv.reader(data.splitlines()) for row in reader: if len(row) < 3: continue letter, braille_raw, pattern = row braille = [b.strip() for b in braille_raw.split(",")] result.append(( letter, braille, int(pattern) )) return result def _from_xml(data: str): root = ET.fromstring(data) result = [] for item in root.findall("item"): letter = item.findtext("letter") braille_raw = item.findtext("braille") pattern = item.findtext("pattern") braille = [b.strip() for b in braille_raw.split(",")] result.append(( letter, braille, int(pattern) )) return result
LICENSE
braillebaseio — CC0 1.0 Universal
This software is released under the Creative Commons Zero v1.0 Universal (CC0 1.0) license.
To the extent possible under law, the author has waived all copyright and related or neighboring rights to this work.
You may copy, modify, distribute, and use this software for any purpose, including commercial purposes, without asking permission.
Full legal text:
https://creativecommons.org/publicdomain/zero/1.0/
README
This project exists thanks to the support, collaboration, and tools provided by many people and communities.
- For providing an accessible AI assistant that played a fundamental role in the growth and refinement of this system.
- For offering a powerful, free, and accessible development environment.
- For maintaining a free, open, and expressive programming language that makes projects like this possible.
- For building the foundations, tools, and knowledge that allow new accessibility technologies to exist today.
- For creating and maintaining BrailleBase, designing its architecture, and developing its core features with a focus on accessibility and education.