コード例 #1
0
ファイル: displayautogrades.py プロジェクト: c0ns0le/nbgrader
 def _indent(self, val):
     lines = val.split("\n")
     new_lines = []
     for line in lines:
         new_line = self.indent + strip_ansi(line)
         if len(new_line) > (self.width - 3):
             new_line = new_line[:(self.width - 3)] + "..."
         new_lines.append(new_line)
     return "\n".join(new_lines)
コード例 #2
0
ファイル: test_execute.py プロジェクト: 2t7/ipython
 def normalize_output(output):
     """
     Normalizes outputs for comparison.
     """
     output = dict(output)
     if 'metadata' in output:
         del output['metadata']
     if 'text' in output:
         output['text'] = re.sub(addr_pat, '<HEXADDR>', output['text'])
     if 'svg' in output:
         del output['text']
     if 'traceback' in output:
         tb = []
         for line in output['traceback']:
             tb.append(strip_ansi(line))
         output['traceback'] = tb
         
     return output
コード例 #3
0
    def normalize_output(output):
        """
        Normalizes outputs for comparison.
        """
        output = dict(output)
        if "metadata" in output:
            del output["metadata"]
        if "text" in output:
            output["text"] = re.sub(addr_pat, "<HEXADDR>", output["text"])
        if "text/plain" in output.get("data", {}):
            output["data"]["text/plain"] = re.sub(addr_pat, "<HEXADDR>", output["data"]["text/plain"])
        if "traceback" in output:
            tb = []
            for line in output["traceback"]:
                tb.append(strip_ansi(line))
            output["traceback"] = tb

        return output