Return a HTML block showing the trace.
195764
def trace_to_html(simtrace, trace_list=None, sortkey=None):
    

    from .simulation import SimulationTrace, _trace_sort_key
    if not isinstance(simtrace, SimulationTrace):
        raise PyrtlError('first arguement must be of type SimulationTrace')

    trace = simtrace.trace
    if sortkey is None:
        sortkey = _trace_sort_key

    if trace_list is None:
        trace_list = sorted(trace, key=sortkey)

    wave_template = (
        """\
        <script type="WaveDrom">
        { signal : [
        %s
        ]}
        </script>

        """
        )

    def extract(w):
        wavelist = []
        datalist = []
        last = None
        for i, value in enumerate(trace[w]):
            if last == value:
                wavelist.append('.')
            else:
                if len(w) == 1:
                    wavelist.append(str(value))
                else:
                    wavelist.append('=')
                    datalist.append(value)
                last = value

        wavestring = ''.join(wavelist)
        datastring = ', '.join(['"%d"' % data for data in datalist])
        if len(w) == 1:
            return bool_signal_template % (w, wavestring)
        else:
            return int_signal_template % (w, wavestring, datastring)

    bool_signal_template = '{ name: "%s",  wave: "%s" },'
    int_signal_template = '{ name: "%s",  wave: "%s", data: [%s] },'
    signals = [extract(w) for w in trace_list]
    all_signals = '\n'.join(signals)
    wave = wave_template % all_signals
    # print(wave)
    return wave
794093
def _trace (frame, event, arg):
    """"""
    if event in ('call', 'c_call'):
        _trace_line(frame, event, arg)
    elif event in ('return', 'c_return'):
        _trace_line(frame, event, arg)
        print("  return:", arg)
    #elif event in ('exception', 'c_exception'):
    #    _trace_line(frame, event, arg)
    return _trace
898724
private function renderTrace($trace)
    {
        foreach ($trace as $i => $entry) {
            $s = '';
            if (!empty($entry['file'])) {
                $s .= $this->stripFile($entry['file']);
                if (!empty($entry['line'])) {
                    $s .= ' (line ' . $entry['line'] . ')';
                }
            }
            if (!empty($entry['function'])) {
                $class = !empty($entry['class']) ? $entry['class'] . $entry['type'] : '';
                $args  = !empty($entry['args']) ? $this->dumpArgs($entry['args']) : '' ;
                $s .= ':<br/>&nbsp;&nbsp;&nbsp;' . $class . $entry['function'] . '(' . $args . ')';
            }
            $trace[$i] = '<li>' . $s . '</li>';
        }

        return '<code><ul>' . implode('<br/>', $trace) . '</ul></code>';
    }
223469
def trace(self):
        """"""
        if self._trace is None:
            self._trace = self.load_trace(self.mname)
        return self._trace
1098062
def with_debug_id(debug_id):
        """"""
        ctx = SpanContext(
            trace_id=None, span_id=None, parent_id=None, flags=None
        )
        ctx._debug_id = debug_id
        return ctx
1066342
def trace():
    
    import traceback
    import sys
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # script name + line number
    line = tbinfo.split(", ")[1]
    # Get Python syntax error
    #
    synerror = traceback.format_exc().splitlines()[-1]
    return line, __file__, synerror
1360680
def random_tracing():
    
    new_id = _uniq_id()
    return Tracing(
        span_id=new_id,
        parent_id=0,
        trace_id=new_id,
        traceflags=0)
992103
public static function traceBegin()
    {
        $dbg = debug_backtrace();
        $str = '=> ';
        if (!empty ($dbg[1]['class'])) {
            $str .= $dbg[1]['class'] . '::';
        }
        $str .= $dbg[1]['function'] . '(';
        if (is_array($dbg[1]['args'])) {
            foreach ($dbg[1]['args'] as $index => $arg) {
                if ($index != 0) {
                    $str .= ', ';
                }
                if (is_object($arg)) {
                    $str .= get_class($arg);
                } else {
                    $str .= str_replace(array("\r\n", "\n", "\r"), "", var_export($arg, true));
                }
            }
        }
        if (isset($dbg[1]['file'])) {
            $file = basename($dbg[1]['file']);
        } else {
            $file = 'unknown_file';
        }
        if (isset($dbg[1]['line'])) {
            $line = $dbg[1]['line'];
        } else {
            $line = 'unknown_line';
        }
        $str .= ') [' . $file . ':' . $line . ']';
        phpCAS :: log($str);
        if (!isset(self::$_PHPCAS_DEBUG['indent'])) {
            self::$_PHPCAS_DEBUG['indent'] = 0;
        } else {
            self::$_PHPCAS_DEBUG['indent']++;
        }
    }
638691
def html(self):
        """"""
        output = self.html_preamble
        output += self._repr_html_()
        output += self.html_post
        return output
841415
def traceit(frame, event, arg):
    

    import linecache
    try:
        if event == "line":
            lineno = frame.f_lineno
            filename = frame.f_globals.get("__file__")

            if (filename.endswith(".pyc") or filename.endswith(".pyo")):
                filename = filename[:-1]

            name = frame.f_globals["__name__"]
            line = linecache.getline(filename, lineno)
            if name.startswith('ambry'):
                print "%s:%s: %s" % (name, lineno, line.rstrip())

    finally:
        return traceit
994200
public RayTraceResult trace()
	{
		RayTraceResult mop = null, firstHit = null;
		double tX, tY, tZ, min;
		int count = 0;
		boolean ret = false;

		int currentX = blockSrc.getX();
		int currentY = blockSrc.getY();
		int currentZ = blockSrc.getZ();

		while (!ret && count++ <= MAX_BLOCKS)
		{
			tX = ray.intersectX(currentX + (ray.direction.x > 0 ? 1 : 0));
			tY = ray.intersectY(currentY + (ray.direction.y > 0 ? 1 : 0));
			tZ = ray.intersectZ(currentZ + (ray.direction.z > 0 ? 1 : 0));

			min = getMin(tX, tY, tZ);

			// do not trace first block
			if (count != 1 || !hasOption(Options.IGNORE_FIRST_BLOCK))
				mop = rayTraceBlock(new BlockPos(currentX, currentY, currentZ), ray.getPointAt(min));
			if (firstHit == null)
				firstHit = mop;
			if (hasOption(Options.LOG_BLOCK_PASSED))
				blockPassed.put(new BlockPos(currentX, currentY, currentZ), mop);

			if (dest != null && currentX == blockDest.getX() && currentY == blockDest.getY() && currentZ == blockDest.getZ())
				ret = true;

			if (!ret)
			{
				if (min == tX)
					currentX += step.x;
				if (min == tY)
					currentY += step.y;
				if (min == tZ)
					currentZ += step.z;
			}

			if (dest != null && dest.equals(ray.getPointAt(min)))
				ret = true;

		}

		if (firstHit == null && dest != null)
			firstHit = new RayTraceResult(RayTraceResult.Type.MISS, dest.toVec3d(), null, new BlockPos(currentX, currentY, currentZ));

		firstHit = ChunkCollision.get().getRayTraceResult(	world,
															Pair.of(src, dest),
															firstHit,
															hasOption(Options.HIT_LIQUIDS),
															hasOption(Options.CHECK_COLLISION),
															true);

		if (!ret)
			MalisisCore.message("Trace fail : " + MAX_BLOCKS + " blocks passed (" + currentX + "," + currentY + "," + currentZ + ")");
		return firstHit;
	}
992510
def trace(line):
    """"""
    args = line.split()
    enable = args[0] in {'enable', 'on'}

    if not enable:
        sys.settrace(None)
        sys.stdout = _ORIGINAL_STDOUT
        return

    pattern = args[1] if len(args) > 1 else None
    sys.stdout = open(args[2], 'a') if len(args) > 2 else sys.stdout
    sys.settrace(partial(trace_line, pattern))
1103644
def trace_decorator(self):
        """"""

        def decorator(func):

            def wrapper(*args, **kwargs):
                self.tracer.start_span(name=func.__name__)
                return_value = func(*args, **kwargs)
                self.tracer.end_span()
                return return_value

            return wrapper

        return decorator
1029971
def get_real_last_traceback(exception):
    
    traceback_blocks = []
    _n, _n, exc_traceback = sys.exc_info()
    tb_list = get_all_tracebacks(exc_traceback)[1:]

    # Remove already captured tracebacks
    # TODO(jmv): This must be a better way of doing this. Need to revisit.
    tb_list = [tb for tb in tb_list if tb not in CAPTURED_TRACEBACKS]
    CAPTURED_TRACEBACKS.extend(tb_list)

    for traceback in tb_list:
        lines, path, line_num = get_source_from_frame(traceback.tb_frame)
        traceback_lines = get_numbered_source(lines, traceback.tb_lineno,
                                              line_num)

        traceback_lines.insert(0, '  - {0}'.format(path))
        traceback_lines.insert(1, '  ------------------')
        traceback_lines.append('  ------------------')
        traceback_blocks.append(traceback_lines)

    traced_lines = ['Error Traceback:']
    traced_lines.extend(itertools.chain.from_iterable(traceback_blocks))
    traced_lines.append('  - Error | {0}: {1}'.format(
        type(exception).__name__, exception))

    return traced_lines
259587
def from_traceback(cls, tb):
        """"""
        stack_trace = cls(
            stack_trace_hash_id=generate_hash_id_from_traceback(tb)
        )
        # use the add_stack_frame so that json formatting is applied
        for tb_frame_info in traceback.extract_tb(tb):
            filename, line_num, fn_name, _ = tb_frame_info
            stack_trace.add_stack_frame(
                StackFrame(
                    func_name=fn_name,
                    original_func_name=fn_name,
                    file_name=filename,
                    line_num=line_num,
                    col_num=0,  # I don't think this is available in python
                    load_module=filename,
                    build_id=BUILD_ID,
                    source_version=SOURCE_VERSION
                )
            )
        return stack_trace
859650
def print_trace(self):
        
        traceback.print_exc()
        for tb in self.tracebacks:
            print tb,
        print ''
176338
def html(self):
        
        return """
        <div class="property"><i>{name}</i><br/>
        <pre>{value}</pre></div>
        """.format(name=tag.text(self.name), value=tag.text(self.value))