• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(205)  |  Call(199)  |  Derive(0)  |  Import(6)
Work out which source or compiled file an object was defined in.

        def getfile(object):
    """Work out which source or compiled file an object was defined in."""
    if ismodule(object):
        if hasattr(object, '__file__'):
            return object.__file__
        raise TypeError('{!r} is a built-in module'.format(object))
    if isclass(object):
        object = sys.modules.get(object.__module__)
        if hasattr(object, '__file__'):
            return object.__file__
        raise TypeError('{!r} is a built-in class'.format(object))
    if ismethod(object):
        object = object.im_func
    if isfunction(object):
        object = object.func_code
    if istraceback(object):
        object = object.tb_frame
    if isframe(object):
        object = object.f_code
    if iscode(object):
        return object.co_filename
    raise TypeError('{!r} is not a module, class, method, '
                    'function, traceback, frame, or code object'.format(object))
        


src/b/r/braintree_python_examples-HEAD/tr_checkout_app_engine/braintree/environment.py   braintree_python_examples(Download)
    def braintree_root():
        return os.path.dirname(inspect.getfile(Environment))
 
Environment.Development = Environment("localhost", os.getenv("GATEWAY_PORT") or "3000", False, None)
Environment.Sandbox = Environment("sandbox.braintreegateway.com", "443", True, Environment.braintree_root() + "/ssl/sandbox_braintreegateway_com.ca.crt")
Environment.Production = Environment("www.braintreegateway.com", "443", True, Environment.braintree_root() + "/ssl/www_braintreegateway_com.ca.crt")
 

src/b/l/Blogmaker-0.6/examples/myblog/urls.py   Blogmaker(Download)
def module_media_dir(mod):
    """returns the media dir relative to a module object"""
    initfile = inspect.getfile(mod)
    relmedia = os.path.join(os.path.dirname(initfile), 'media')
    if not os.path.exists(relmedia):
        raise OSError("Could not find media directory relative to module %s (tried %s)" % (
                                                                mod.__name__, relmedia))

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

src/b/a/badger-lib-HEAD/packages/nose/nose/ext/dtcompat.py   badger-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

src/m/y/mywsgiserver-HEAD/lib/python2.6/site-packages/nose/ext/dtcompat.py   mywsgiserver(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

src/m/d/mdn-lib-HEAD/packages/nose/nose/ext/dtcompat.py   mdn-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

src/s/e/secret-squirrel-lib-HEAD/packages/nose/nose/ext/dtcompat.py   secret-squirrel-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

src/p/y/python-nose-HEAD/nose/ext/dtcompat.py   python-nose(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