All Samples(1247) | Call(1235) | Derive(0) | Import(12)
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
import os, re, glob, brian, inspect, compiler, unicodedata, fnmatch
documentable_names = set()
for k, v in brian.__dict__.iteritems():
try:
if 'brian' in inspect.getsourcefile(v):
documentable_names.add(k)
except TypeError:
src/b/r/brian-HEAD/dev/tools/docs/generate_examples.py brian(Download)
import os, re, glob, brian, inspect, compiler, unicodedata, fnmatch
documentable_names = set()
for k, v in brian.__dict__.iteritems():
try:
if 'brian' in inspect.getsourcefile(v):
documentable_names.add(k)
except TypeError:
src/p/y/pylive-HEAD/example/i_pylons/ez_setup.py pylive(Download)
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
src/g/u/gunicorn-0.11.1/examples/frameworks/pylonstest/ez_setup.py gunicorn(Download)
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
src/c/o/cogen-0.2.1/examples/cogen-chat/ChatApp/ez_setup.py cogen(Download)
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
src/t/w/twMaps-0.1a0.dev-r720/twMapsSampleAppPylons/ez_setup/__init__.py twMaps(Download)
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
src/s/i/SimpleExampleEgg-0.2/ez_setup/__init__.py SimpleExampleEgg(Download)
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
src/i/p/ipython-py3k-HEAD/IPython/core/ultratb.py ipython-py3k(Download)
import types
# For purposes of monkeypatching inspect to fix a bug in it.
from inspect import getsourcefile, getfile, getmodule,\
ismodule, isclass, ismethod, isfunction, istraceback, isframe, iscode
# IPython's own modules
FIXED version with which we monkeypatch the stdlib to work around a bug."""
file = getsourcefile(object) or getfile(object)
# If the object is a frame, then trying to get the globals dict from its
# module won't work. Instead, the frame object itself has the globals
# dictionary.
src/p/y/pygccxml-HEAD/pydsc_dev/pydsc.py pygccxml(Download)
def getsourcefile( obj ):
try:
fpath = inspect.getsourcefile( obj )
if fpath is None:
fpath = inspect.getfile( obj )
if fpath:
fpath = os.path.abspath( fpath )
src/z/a/zamboni-lib-HEAD/lib/python/nose/ext/dtcompat.py zamboni-lib(Download)
# DocTestFinder._find_lineno to find the line number for a
# given object's docstring.
try:
file = inspect.getsourcefile(obj) or inspect.getfile(obj)
source_lines = linecache.getlines(file)
if not source_lines:
source_lines = None
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next