mirror of
https://github.com/hohn/sarif-cli.git
synced 2025-12-16 17:23:03 +01:00
sarif-results-summary -s: include source file lines in output
This commit is contained in:
committed by
=Michael Hohn
parent
ab1d7c27ef
commit
b69eec404d
@@ -1,9 +1,18 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
MIN_PYTHON = (3, 7)
|
||||
if sys.version_info < MIN_PYTHON:
|
||||
sys.exit("Python %s.%s or later is required.\n" % MIN_PYTHON)
|
||||
|
||||
def load_lines(root, path, line_from, line_to):
|
||||
"""Load the line range [line_from, line_to], including both,
|
||||
from the file at root/path. Lines are counted from 1. Newlines are dropped."""
|
||||
fname = os.path.join(root, path)
|
||||
with open(fname, 'r') as file:
|
||||
lines = file.readlines()
|
||||
return [line.strip() for line in lines[line_from-1 : line_to-1+1]]
|
||||
|
||||
def lineinfo(region):
|
||||
""" Return sensible values for start/end line/columns for the possibly empty
|
||||
entries in the sarif 'region' structure.
|
||||
@@ -33,4 +42,9 @@ def get(sarif_struct, *path):
|
||||
def msg(message):
|
||||
""" Print message to stdout """
|
||||
sys.stdout.write(message)
|
||||
|
||||
|
||||
def dbg(message):
|
||||
""" Print message to stderr """
|
||||
sys.stdout.flush()
|
||||
sys.stderr.write(message)
|
||||
sys.stderr.flush()
|
||||
|
||||
Reference in New Issue
Block a user