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 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/a/p/Apydia-0.0.2/apydia/descriptors.py Apydia(Download)
import logging
import sys
from os.path import split
from inspect import ismodule, isclass, isfunction, ismethod, isbuiltin, \
getmodule, getsourcefile, findsource, getdoc, \
getcomments, getargspec, formatargspec
def root_module_basedir(module):
module = getmodule(module)
if "." in module.__name__:
module = sys.modules[module.__name__.split(".")[0]]
return split(getsourcefile(module))[0]
else:
return split(getsourcefile(module))[0]
base = dist.location
else:
base = root_module_basedir(obj)
absolute_path = getsourcefile(obj)
log.debug("base: %r, abspath: %r", base, absolute_path)
return absolute_path[len(base):]
except (TypeError, AttributeError):
src/s/y/sympy-old-HEAD/sympy/mpmath/__init__.py sympy-old(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/s/y/sympy-tensor-HEAD/sympy/mpmath/__init__.py sympy-tensor(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/s/y/sympy-HEAD/sympy/mpmath/__init__.py sympy(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/s/i/simplegrate-HEAD/sympy/sympy/mpmath/__init__.py simplegrate(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/s/y/sympy-0.6.6/sympy/mpmath/__init__.py sympy(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/l/i/libs-HEAD/cream/util/__init__.py libs(Download)
def get_source_file(object):
from inspect import getsourcefile
return getsourcefile(object)
def joindir(_file, *parts):
import os
return os.path.join(os.path.dirname(os.path.abspath(_file)), *parts)
src/m/p/mpmath-0.16/mpmath/__init__.py mpmath(Download)
def runtests():
"""
Run all mpmath tests and print output.
"""
import os.path
from inspect import getsourcefile
import tests.runtests as tests
testdir = os.path.dirname(os.path.abspath(getsourcefile(tests)))
src/a/s/aspyct-HEAD/trunk/src/Aspyct/utils.py aspyct(Download)
# along with this program. If not, see <http://www.gnu.org/licenses/>. import sys from inspect import getsourcefile from threading import RLock if sys.version_info[0] == 2:
if doRaise:
raise TypeError("Restricted access violation, "\
+ "in %s at line %i" \
% (getsourcefile(f), f.f_lineno)) # Check for Python 3.0
class Cache(Aspect):
def __init__(self):
1 | 2 Next