Did I find the right examples for you? yes no

All Samples(91)  |  Call(90)  |  Derive(0)  |  Import(1)
Extract the block of code at the top of the given list of lines.

        def getblock(lines):
    """Extract the block of code at the top of the given list of lines."""
    blockfinder = BlockFinder()
    try:
        tokenize.tokenize(iter(lines).next, blockfinder.tokeneater)
    except (EndOfBlock, IndentationError):
        pass
    return lines[:blockfinder.last]
        


src/g/a/gae-twitter-oauth-example-HEAD/werkzeug/debug/tbtools.py   gae-twitter-oauth-example(Download)
                lineno -= 1
            try:
                offset = len(inspect.getblock([x.code + '\n' for x
                                               in lines[lineno:]]))
            except TokenError:

src/s/a/sage-HEAD/src/sage/misc/sageinspect.py   sage(Download)
                # if it's at toplevel, it's already the best one
                if lines[i][0] == 'c':
                    return inspect.getblock(lines[i:]), i+base_lineno
                # else add whitespace to candidate list
                candidates.append((match.group(1), i))
        if candidates:
            # this will sort by whitespace, and by line number,
            # less whitespace first
            candidates.sort()
            return inspect.getblock(lines[candidates[0][1]:]), candidates[0][1]+base_lineno
            lnum -= 1
 
        return inspect.getblock(lines[lnum:]), lnum+base_lineno
    raise IOError('could not find code object')
 

src/d/i/dill-HEAD/dill/source.py   dill(Download)
from inspect import ismodule, isclass, ismethod, isfunction, istraceback
from inspect import isframe, iscode, getfile, getmodule, getsourcefile
from inspect import getblock, indentsize, isbuiltin
from .dill import PY3
 
    #XXX: 'enclosing' means: closures only? or classes and files?
    indent = indentsize(lines[lnum])
    block = getblock(lines[lnum:]) #XXX: catch any TokenError here?
 
    if not enclosing or not indent:
        if pat1.match(lines[line]):
            if not skip:
                try: code = getblock(lines[line:])
                except TokenError: code = [lines[line]]
            if indentsize(lines[line]) > indent: #XXX: should be >= ?
        # find skip: the number of consecutive decorators
        elif pat2.match(lines[line]):
            try: code = getblock(lines[line:])
            except TokenError: code = [lines[line]]
            skip = 1

src/s/a/sardana-1.3.1/src/sardana/sardanameta.py   sardana(Download)
 
    if inspect.ismodule(object): return lines, 0
    else: return inspect.getblock(lines[lnum:]), lnum + 1
 
def getsource(object):

src/s/c/scikit-learn-0.14.1/sklearn/externals/joblib/func_inspect.py   scikit-learn(Download)
            # All the lines after the function definition:
            source_lines = list(islice(source_file_obj, first_line - 1, None))
        return ''.join(inspect.getblock(source_lines)), source_file, first_line
    except:
        # If the source code fails, we use the hash. This is fragile and

src/p/d/pdb-clone-1.5/pdb_clone/pdb.py   pdb-clone(Download)
    elif inspect.ismodule(obj):
        return lines, 1
    return inspect.getblock(lines[lineno:]), lineno+1
 
def lasti2lineno(code, lasti):

src/l/e/leo-editor-HEAD/leo/external/edb.py   leo-editor(Download)
    elif inspect.ismodule(obj):
        return lines, 1
    return inspect.getblock(lines[lineno:]), lineno+1
#@+node:ekr.20110914171443.7248: *3* lasti2lineno
def lasti2lineno(code, lasti):

src/l/e/leo-4.11-final/leo/external/edb.py   leo(Download)
    elif inspect.ismodule(obj):
        return lines, 1
    return inspect.getblock(lines[lineno:]), lineno+1
#@+node:ekr.20110914171443.7248: *3* lasti2lineno
def lasti2lineno(code, lasti):

src/p/y/pypreprocess-HEAD/pypreprocess/external/joblib/func_inspect.py   pypreprocess(Download)
            # All the lines after the function definition:
            source_lines = list(islice(source_file_obj, first_line - 1, None))
        return ''.join(inspect.getblock(source_lines)), source_file, first_line
    except:
        # If the source code fails, we use the hash. This is fragile and

src/p/y/PyXRD-0.5.4/pyxrd/joblib/func_inspect.py   PyXRD(Download)
            # All the lines after the function definition:
            source_lines = list(islice(source_file_obj, first_line - 1, None))
        return ''.join(inspect.getblock(source_lines)), source_file, first_line
    except:
        # If the source code fails, we use the hash. This is fragile and

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