def getLineObjsFromLines(inputLines, validateFileExists=True, allInput=False): lineObjs = {} for index, line in enumerate(inputLines): line = line.replace('\t', ' ') # remove the new line as we place the cursor ourselves for each # line. this avoids curses errors when we newline past the end of the # screen line = line.replace('\n', '') formattedLine = FormattedText(line) result = parse.matchLine(str(formattedLine), validateFileExists=validateFileExists, allInput=allInput) if not result: line = format.SimpleLine(formattedLine, index) else: line = format.LineMatch(formattedLine, result, index, validateFileExists=validateFileExists, allInput=allInput) lineObjs[index] = line return lineObjs
def getLineObjs(): inputLines = sys.stdin.readlines() lineObjs = {} for index, line in enumerate(inputLines): line = line.replace('\t', ' ') line = re.sub(r'\x1b[^mK]*(m|K)', '', line) result = parse.matchLine(line) if not result: simple = format.SimpleLine(line, index) lineObjs[index] = simple continue match = format.LineMatch(line, result, index) lineObjs[index] = match return lineObjs
def getLineObjs(): inputLines = sys.stdin.readlines() lineObjs = {} for index, line in enumerate(inputLines): line = line.replace('\t', ' ') formattedLine = FormattedText(line) result = parse.matchLine(str(formattedLine)) if not result: line = format.SimpleLine(formattedLine, index) else: line = format.LineMatch(formattedLine, result, index) lineObjs[index] = line return lineObjs
def getLineObjs(customRegex=None): inputLines = sys.stdin.readlines() lineObjs = {} for index, line in enumerate(inputLines): line = line.replace('\t', ' ') line = re.sub(r'\x1b[^mK]*(m|K)', '', line) result = parse.matchLine(line, customRegex=customRegex) if not result: simple = format.SimpleLine(line, index) lineObjs[index] = simple continue match = format.LineMatch(line, result, index) # Ugly hack to remove prepended ./ from # matches from custom regexes if customRegex: match.file = result[0] lineObjs[index] = match return lineObjs