Did I find the right examples for you? yes no

All Samples(266)  |  Call(258)  |  Derive(0)  |  Import(8)
Return a list of source lines and starting line number for an object.

The argument may be a module, class, method, function, traceback, frame,
or code object.  The source code is returned as a list of the lines
corresponding to the object and the line number indicates where in the
original source file the first line of code was found.  An IOError is
raised if the source code cannot be retrieved.

        def getsourcelines(object):
    """Return a list of source lines and starting line number for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a list of the lines
    corresponding to the object and the line number indicates where in the
    original source file the first line of code was found.  An IOError is
    raised if the source code cannot be retrieved."""
    lines, lnum = findsource(object)

    if ismodule(object): return lines, 0
    else: return getblock(lines[lnum:]), lnum + 1
        


src/m/o/modern-python-example-HEAD/lib/python2.7/site-packages/logilab/common/debugger.py   modern-python-example(Download)
    or code object.  The source code is returned as a single string.  An
    IOError is raised if the source code cannot be retrieved."""
    lines, lnum = inspect.getsourcelines(obj)
    return ''.join(lines), lnum
 

src/m/a/mamba-0.6/mamba/example.py   mamba(Download)
    def source_line(self):
        try:
            return inspect.getsourcelines(self.test)[1]
        except IndexError:
            return 'inf'

src/d/j/django-cbv-inspector-HEAD/cbv/management/commands/populate_cbv.py   django-cbv-inspector(Download)
        # Use line inspection to work out whether the method is defined on this
        # klass. Possibly not the best way, but I can't think of another atm.
        lines, start_line = inspect.getsourcelines(member)
        parent_lines, parent_start_line = inspect.getsourcelines(parent)
        if start_line < parent_start_line or start_line > parent_start_line + len(parent_lines):
    def get_code(self, member):
            # Strip unneeded whitespace from beginning of code lines
            lines, start_line = inspect.getsourcelines(member)
            whitespace = len(lines[0]) - len(lines[0].lstrip())
            for i, line in enumerate(lines):
    def get_line_number(self, member):
        try:
            return inspect.getsourcelines(member)[1]
        except TypeError:
            return -1

src/a/l/ally-py-0.9.0/ally/support/util_sys.py   ally-py(Download)
 
from collections import deque
from inspect import isclass, ismodule, stack, isfunction, getsourcelines, \
    getsourcefile, ismethod
from os.path import dirname, relpath
    '''
    if isclass(located):
        try: _src, line = getsourcelines(located)
        except IOError: return '\n  Generated class "%s.%s"' % (located.__module__, located.__name__)
        return '\n  File "%s", line %i' % (getsourcefile(located), line)

src/k/u/kuma-lib-HEAD/packages/ipython/IPython/OInspect.py   kuma-lib(Download)
        try:
            try:
                lineno = inspect.getsourcelines(obj)[1]
            except TypeError:
                # For instances, try the class object like getsource() does
                if hasattr(obj,'__class__'):
                    lineno = inspect.getsourcelines(obj.__class__)[1]

src/s/a/sage-HEAD/src/sage/misc/sageinspect.py   sage(Download)
        if pos is None:
            try:
                return inspect.getsourcelines(obj)
            except IOError:
                if (not hasattr(obj, '__class__')) or hasattr(obj,'__metaclass__'):

src/s/q/sqlkit-0.9.6/sqlkit/debug/gtk_dbg.py   sqlkit(Download)
        try:
            txt.extend("# defined at line %s of file:\n# %s\n# module: %s\n\n" %(
                inspect.getsourcelines(obj)[1],
                inspect.getfile(obj),
                inspect.getmodule(obj),
        try:
            txt.extend("# defined at line %s of file:\n# %s\n# module: %s\n\n" %(
                inspect.getsourcelines(obj)[1],
                inspect.getfile(obj),
                inspect.getmodule(obj),

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/IPython/core/oinspect.py   antisocial(Download)
    try:
        try:
            lineno = inspect.getsourcelines(obj)[1]
        except TypeError:
            # For instances, try the class object like getsource() does
            if hasattr(obj, '__class__'):
                lineno = inspect.getsourcelines(obj.__class__)[1]

src/c/o/collective.z3cinspector-1.1/collective/z3cinspector/registry.py   collective.z3cinspector(Download)
        try:
            return inspect.getsourcefile(klass), \
                inspect.getsourcelines(klass)[1]
        except:
            return str(sys.exc_info()[1]) + ': ' + str(self.factory), '-'

src/a/l/alto-0.4/alto/urlviz.py   alto(Download)
def inspect_view(view):
    source_lines, line_number = inspect.getsourcelines(view)
    data = {
        'file': inspect.getsourcefile(view),
        'name': view.__name__,

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next