def prettify_stacktrace(): import pretty_errors import stackprinter stackprinter.set_excepthook(style='lightbg2') pretty_errors.configure(separator_character='*', filename_display=pretty_errors.FILENAME_EXTENDED, line_number_first=True, display_link=True, lines_before=5, lines_after=2, line_color=pretty_errors.RED + '> ' + pretty_errors.default_config.line_color, code_color=' ' + pretty_errors.default_config.line_color, truncate_code=True, display_locals=True) pretty_errors.blacklist('c:/python') pretty_errors.replace_stderr() print(f"Enabled: pretty_errors & stackprinter")
axes_order = contextvars.ContextVar("axes_order", default=0) pretty_errors.configure( separator_character="*", filename_display=pretty_errors.FILENAME_EXTENDED, line_number_first=True, display_link=True, lines_before=2, lines_after=1, line_color=pretty_errors.RED + "> " + pretty_errors.default_config.line_color, code_color=" " + pretty_errors.default_config.line_color, truncate_code=True, display_locals=True, ) pretty_errors.blacklist("c:/python") class DuplicateFilter(logging.Filter): def filter(self, record): # add other fields if you need more granular comparison, depends on your app current_log = (record.module, record.levelno, record.msg) if current_log != getattr(self, "last_log", None): self.last_log = current_log return True return False def setup_custom_logger(name): formatter = logging.Formatter(fmt="{message:s}", style="{") handler = RichHandler(show_time=False,
separator_character="₪", filename_display=pretty_errors.FILENAME_EXTENDED, line_number_first=True, display_link=True, lines_before=2, lines_after=2, line_color="═" + pretty_errors.RED + "❯ " + pretty_errors.default_config.line_color + "│ ", code_color=" " + pretty_errors.default_config.code_color + "│ ", truncate_code=True, display_arrow=True, ) pretty_errors.blacklist("C:\\Users\\Rafael\\Anaconda3") pretty_errors.replace_stderr() # current_api = api.sources[list(api.sources.keys())[0]] current_api = api.scansmangas_xyz @eel.expose def search(query="", page=1): logger.info('api: searched "' + query + '"') result, pages = current_api.search(query, page) return result, pages @eel.expose def get_info(id):
import os import sys import pretty_errors pretty_errors.configure( separator_character='*', filename_display=pretty_errors.FILENAME_EXTENDED, line_number_first=True, display_link=True, lines_before=5, lines_after=2, line_color=pretty_errors.RED + '> ' + pretty_errors.default_config.line_color, code_color=' ' + pretty_errors.default_config.line_color, truncate_code=True, display_locals=True ) pretty_errors.blacklist('c:/python') def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'khS.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv)
self.save() if __name__ == "__main__": import pretty_errors pretty_errors.configure( name="my_config", separator_character="₪", filename_display=pretty_errors.FILENAME_EXTENDED, line_number_first=True, display_link=True, lines_before=2, lines_after=2, line_color="═" + pretty_errors.RED + "❯ " + pretty_errors.default_config.line_color, code_color=" " + pretty_errors.default_config.code_color, truncate_code=True, display_arrow=True, ) pretty_errors.blacklist("D:\\r\\Miniconda") save = MagicSave(dev=True) save.data = {} save.save() print(save.get()) save.set({"favorite": [4, 2]}) print(save.get()) save.set({"favorite": [4, 5, 7]}) save.save() print(save.get("favorite"))