Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
Return the filename that can be used to locate an object's source.
Return None if no way can be identified to get the source.

        def getsourcefile(object):
    """Return the filename that can be used to locate an object's source.
    Return None if no way can be identified to get the source.
    """
    filename = getfile(object)
    if string.lower(filename[-4:]) in ('.pyc', '.pyo'):
        filename = filename[:-4] + '.py'
    for suffix, mode, kind in imp.get_suffixes():
        if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
            # Looks like a binary file.  We want to only return a text file.
            return None
    if os.path.exists(filename):
        return filename
    # only return a non-existent filename if the module has a PEP 302 loader
    if hasattr(getmodule(object, filename), '__loader__'):
        return filename
    # or it is in the linecache
    if filename in linecache.cache:
        return filename
        


src/p/l/plexnet-HEAD/third_party/generic/pypy/py/code/source.py   plexnet(Download)
    except TypeError:
        # fallback to 
        fn = (py.std.inspect.getsourcefile(obj) or
              py.std.inspect.getfile(obj))
        fspath = fn and py.path.local(fn) or None

src/n/u/nupic-linux64-HEAD/lib/python2.6/site-packages/py/_code/source.py   nupic-linux64(Download)
    except TypeError:
        try:
            fn = (py.std.inspect.getsourcefile(obj) or
                  py.std.inspect.getfile(obj))
        except TypeError:

src/p/y/py-1.4.20/py/_code/source.py   py(Download)
    except TypeError:
        try:
            fn = (py.std.inspect.getsourcefile(obj) or
                  py.std.inspect.getfile(obj))
        except TypeError: