Did I find the right examples for you? yes no

All Samples(83)  |  Call(81)  |  Derive(0)  |  Import(2)
Get lines of comments immediately preceding an object's source code.

Returns None when source can't be found.

        def getcomments(object):
    """Get lines of comments immediately preceding an object's source code.

    Returns None when source can't be found.
    """
    try:
        lines, lnum = findsource(object)
    except (IOError, TypeError):
        return None

    if ismodule(object):
        # Look for a comment block at the top of the file.
        start = 0
        if lines and lines[0][:2] == '#!': start = 1
        while start < len(lines) and string.strip(lines[start]) in ('', '#'):
            start = start + 1
        if start < len(lines) and lines[start][:1] == '#':
            comments = []
            end = start
            while end < len(lines) and lines[end][:1] == '#':
                comments.append(string.expandtabs(lines[end]))
                end = end + 1
            return string.join(comments, '')

    # Look for a preceding block of comments at the same indentation.
    elif lnum > 0:
        indent = indentsize(lines[lnum])
        end = lnum - 1
        if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \
            indentsize(lines[end]) == indent:
            comments = [string.lstrip(string.expandtabs(lines[end]))]
            if end > 0:
                end = end - 1
                comment = string.lstrip(string.expandtabs(lines[end]))
                while comment[:1] == '#' and indentsize(lines[end]) == indent:
                    comments[:0] = [comment]
                    end = end - 1
                    if end < 0: break
                    comment = string.lstrip(string.expandtabs(lines[end]))
            while comments and string.strip(comments[0]) == '#':
                comments[:1] = []
            while comments and string.strip(comments[-1]) == '#':
                comments[-1:] = []
            return string.join(comments, '')
        


src/m/a/main-HEAD/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/pydoc.py   main(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/m/a/main-HEAD/External.LCA_RESTRICTED/Languages/CPython/27/Lib/pydoc.py   main(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/p/y/pydroid-HEAD/src/pydroid/framework/project_skeleton/libs/python27/lib/python2.7/pydoc.py   pydroid(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/s/p/Spherebot-Host-GUI-HEAD/InkscapePortable/App/Inkscape/python/Lib/pydoc.py   Spherebot-Host-GUI(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/l/a/landline-server-HEAD/co.whatisuplabs.ldln/lib/play/python/Lib/pydoc.py   landline-server(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/g/i/gitstack-HEAD/python/Lib/pydoc.py   gitstack(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/e/m/empythoned-HEAD/cpython/Lib/pydoc.py   empythoned(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/p/y/pytaint-HEAD/Python-2.7.5-pytaint/Lib/pydoc.py   pytaint(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/p/y/PyAutoC-HEAD/Python27/Lib/pydoc.py   PyAutoC(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

src/p/y/PyCPython-HEAD/Python-2.7.1/Lib/pydoc.py   PyCPython(Download)
def getdoc(object):
    """Get the doc string or comments for an object."""
    result = inspect.getdoc(object) or inspect.getcomments(object)
    return result and re.sub('^ *\n', '', rstrip(result)) or ''
 

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