tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

github_checks_output.py (1104B)


      1 from typing import Optional, Text
      2 
      3 
      4 class GitHubChecksOutputter:
      5    """Provides a method to output data to be shown in the GitHub Checks UI.
      6 
      7    This can be useful to provide a summary of a given check (e.g. the lint)
      8    to enable developers to quickly understand what has gone wrong. The output
      9    supports markdown format.
     10 
     11    https://docs.taskcluster.net/docs/reference/integrations/github/checks#custom-text-output-in-checks
     12    """
     13    def __init__(self, path: Text) -> None:
     14        self.path = path
     15 
     16    def output(self, line: Text) -> None:
     17        with open(self.path, mode="a") as f:
     18            f.write(line)
     19            f.write("\n")
     20 
     21 
     22 __outputter = None
     23 
     24 
     25 def get_gh_checks_outputter(filepath: Optional[Text]) -> Optional[GitHubChecksOutputter]:
     26    """Return the outputter for GitHub Checks output, if enabled.
     27 
     28    :param filepath: The filepath to write GitHub Check output information to,
     29                     or None if not enabled.
     30    """
     31    global __outputter
     32    if filepath and __outputter is None:
     33        __outputter = GitHubChecksOutputter(filepath)
     34    return __outputter