baobabsoluciones/mango

Implement traceback formatting with filtering

オープン

#150 opened on 2024/11/07

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Python (2 件のフォーク)auto 404
good first issue

Repository metrics

Stars
 (3 個のスター)
PR merge metrics
 (PR metrics pending)

説明

In other projects I have been using functions like this one (maybe there are libraries that do something similar, airflow does):

def parse_traceback(exc_type, exc_value, tb):
    tb_parsed = traceback.format_tb(tb)
    cleaned_traceback = []

    for line in tb_parsed:
        # Find "super_secret" and remove everything before it, replacing with "***"
        cleaned_line = re.sub(
            r".*super_secret.*", r' "***', line
        )
        # Remove \n
        cleaned_line = cleaned_line.replace("\n", "")
        # Clean \t
        cleaned_line = cleaned_line.replace("\t", " ")
        # Remove more than 1 space
        cleaned_line = re.sub(r" {2,}", " ", cleaned_line)
        # If line empty skip it
        if cleaned_line:
            cleaned_traceback.append(cleaned_line)

    return " ".join(cleaned_traceback)
    

コントリビューターガイド