{"id":18314403,"url":"https://github.com/gousaiyang/tbtrim","last_synced_at":"2025-04-09T12:41:35.693Z","repository":{"id":57473601,"uuid":"167006952","full_name":"gousaiyang/tbtrim","owner":"gousaiyang","description":"A utility to trim Python traceback information.","archived":false,"fork":false,"pushed_at":"2021-04-07T23:46:44.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T06:45:48.263Z","etag":null,"topics":["excepthook","exception","traceback"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gousaiyang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-22T14:21:00.000Z","updated_at":"2021-04-07T23:46:47.000Z","dependencies_parsed_at":"2022-09-26T17:40:56.328Z","dependency_job_id":null,"html_url":"https://github.com/gousaiyang/tbtrim","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gousaiyang%2Ftbtrim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gousaiyang%2Ftbtrim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gousaiyang%2Ftbtrim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gousaiyang%2Ftbtrim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gousaiyang","download_url":"https://codeload.github.com/gousaiyang/tbtrim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045220,"owners_count":21038552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excepthook","exception","traceback"],"created_at":"2024-11-05T16:33:09.172Z","updated_at":"2025-04-09T12:41:35.672Z","avatar_url":"https://github.com/gousaiyang.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tbtrim\r\n\r\n[![PyPI - Downloads](https://pepy.tech/badge/tbtrim)](https://pepy.tech/count/tbtrim)\r\n[![PyPI - Version](https://img.shields.io/pypi/v/tbtrim.svg)](https://pypi.org/project/tbtrim)\r\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tbtrim.svg)](https://pypi.org/project/tbtrim)\r\n[![GitHub Actions - Status](https://github.com/gousaiyang/tbtrim/workflows/Build/badge.svg)](https://github.com/gousaiyang/tbtrim/actions?query=workflow%3ABuild)\r\n\r\n`tbtrim` is a utility to trim Python traceback information. By assigning user-refined [`sys.excepthook`](https://docs.python.org/3/library/sys.html#sys.excepthook), one can easily customize the behavior after an exception is raise and uncaught, and just before the interpreter prints out the given traceback and exception to `sys.stderr`.\r\n\r\nIn a more human-readable way, `tbtrim` is to let you handle the last words of a program when it exits because of an exception.\r\n\r\n## Installation\r\n\r\nSimply run the following to install the current version from PyPI:\r\n\r\n```shell\r\n$ pip install tbtrim\r\n```\r\n\r\nOr install the latest version from the git repository:\r\n\r\n```shell\r\ngit clone https://github.com/gousaiyang/tbtrim.git\r\ncd tbtrim\r\npip install -e .\r\n# and to update at any time\r\ngit pull\r\n```\r\n\r\n## Usage\r\n\r\n\u003e **set_trim_rule**(*predicate*, *target*=BaseException, *exclude*=None, *strict*=False, *exception*=None)\r\n\r\nSet the rule for trimming traceback (will set `sys.excepthook` and `threading.excepthook` if available).\r\n\r\nYou can determine whether to start trimming traceback items based on the filename (using `predicate`), and can choose to trim traceback only for some certain exceptions (using `target` and `exclude`).\r\n\r\n**Args:**\r\n\r\n- **predicate** (*function*): a function which takes one `str` parameter (the filename of a traceback item) and returns `bool` (returning `True` indicates that this traceback item and the following items should be trimmed)\r\n- **target** (*class_or_tuple*): an exception or a tuple of exceptions may be given to trim traceback only for those exceptions\r\n- **exclude** (*class_or_tuple*): an exception or a tuple of exceptions may be given to exclude them from traceback trimming\r\n- **strict** (*bool*): indicate whether to check an exception against `target` and `exclude` in a strict mode (setting `True` uses `is` to check, `False` uses `issubclass` to check)\r\n- **exception** (*class_or_tuple*): this is a deprecated alias of `exclude`, retained for backward compatibility\r\n\r\n\u003e **clear_trim_rule**()\r\n\r\nClear the rule for trimming traceback (restore the excepthooks).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgousaiyang%2Ftbtrim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgousaiyang%2Ftbtrim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgousaiyang%2Ftbtrim/lists"}