#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2024-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import re def pyprint(obj, indent=0, sort=None, oneline=True, lmin=0, lmax=16): if isinstance(obj, str): if obj.startswith("lit:"): return f'''{obj[4:]}''' if "\\" in obj or obj.startswith("re:"): prefix = "r" else: prefix = "" quote_beg = quote_end = '"' if "\n" in obj: quote_beg = '"""\\\n' quote_end = '\\\n"""' elif '"' in obj: obj = re.sub(r'(?