All Samples(1294) | Call(1252) | Derive(0) | Import(42)
Return true if the object is a module.
Module objects provide these attributes:
__doc__ documentation string
__file__ filename (missing for built-in modules)
def ismodule(object):
"""Return true if the object is a module.
Module objects provide these attributes:
__doc__ documentation string
__file__ filename (missing for built-in modules)"""
return isinstance(object, types.ModuleType)
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
if not lines:
raise IOError('could not get source code')
if ismodule(object):
return lines, 0
if isclass(object):
src/z/a/zamboni-lib-HEAD/lib/python/IPython/OInspect.py zamboni-lib(Download)
# HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We
# simply monkeypatch inspect with code copied from python 2.4.
if sys.version_info[:2] == (2,3):
from inspect import ismodule, getabsfile, modulesbyfile
def getmodule(object):
"""Return the module an object was defined in, or None if not found."""
if ismodule(object):
src/t/o/topographica-HEAD/releases/0.9.7/topographica/topo/misc/asizeof.py topographica(Download)
from __future__ import generators #PYCHOK for yield in Python 2.2
from inspect import isbuiltin, isclass, iscode, isframe, \
isfunction, ismethod, ismodule, stack
from math import log
from os import linesep
v = _Typedef(base=_basicsize(t, obj=obj),
kind=_kind_dynamic, type=t)
##_printf('new %r %r/%r %s', t, _basicsize(t), _itemsize(t), _repr(dir(obj)))
if ismodule(obj): # handle module like dict
v.dup(item=_dict_typedef.item + _sizeof_CPyModuleObject,
leng=_len_module,
refs=_module_refs)
if self._profile: # profile type
self._prof(k).update(obj, s)
# recurse, but not for nested modules
if deep < self._limit_ and not (deep and ismodule(obj)):
# add sizes of referents
r, z, d = v.refs, self._sizer, deep + 1
if self._all_: # use 'all' referents
src/t/o/topographica-HEAD/topographica/topo/misc/asizeof.py topographica(Download)
from __future__ import generators #PYCHOK for yield in Python 2.2
from inspect import isbuiltin, isclass, iscode, isframe, \
isfunction, ismethod, ismodule, stack
from math import log
from os import linesep
v = _Typedef(base=_basicsize(t, obj=obj),
kind=_kind_dynamic, type=t)
##_printf('new %r %r/%r %s', t, _basicsize(t), _itemsize(t), _repr(dir(obj)))
if ismodule(obj): # handle module like dict
v.dup(item=_dict_typedef.item + _sizeof_CPyModuleObject,
leng=_len_module,
refs=_module_refs)
if self._profile: # profile type
self._prof(k).update(obj, s)
# recurse, but not for nested modules
if deep < self._limit_ and not (deep and ismodule(obj)):
# add sizes of referents
r, z, d = v.refs, self._sizer, deep + 1
if self._all_: # use 'all' referents
src/i/p/ipython-0.10/IPython/OInspect.py ipython(Download)
# HACK!!! This is a crude fix for bugs in python 2.3's inspect module. We
# simply monkeypatch inspect with code copied from python 2.4.
if sys.version_info[:2] == (2,3):
from inspect import ismodule, getabsfile, modulesbyfile
def getmodule(object):
"""Return the module an object was defined in, or None if not found."""
if ismodule(object):
src/t/o/topographica-0.9.7/topo/misc/asizeof.py topographica(Download)
from __future__ import generators #PYCHOK for yield in Python 2.2
from inspect import isbuiltin, isclass, iscode, isframe, \
isfunction, ismethod, ismodule, stack
from math import log
from os import linesep
v = _Typedef(base=_basicsize(t, obj=obj),
kind=_kind_dynamic, type=t)
##_printf('new %r %r/%r %s', t, _basicsize(t), _itemsize(t), _repr(dir(obj)))
if ismodule(obj): # handle module like dict
v.dup(item=_dict_typedef.item + _sizeof_CPyModuleObject,
leng=_len_module,
refs=_module_refs)
if self._profile: # profile type
self._prof(k).update(obj, s)
# recurse, but not for nested modules
if deep < self._limit_ and not (deep and ismodule(obj)):
# add sizes of referents
r, z, d = v.refs, self._sizer, deep + 1
if self._all_: # use 'all' referents
src/p/y/Pympler-0.1/pympler/asizeof/asizeof.py Pympler(Download)
from __future__ import generators #PYCHOK for yield in Python 2.2
from inspect import isbuiltin, isclass, iscode, isframe, \
isfunction, ismethod, ismodule, stack
from math import log
from os import linesep
v = _Typedef(base=_basicsize(t, obj=obj),
kind=_kind_dynamic, type=t)
##_printf('new %r %r/%r %s', t, _basicsize(t), _itemsize(t), _repr(dir(obj)))
if ismodule(obj): # handle module like dict
v.dup(item=_dict_typedef.item + _sizeof_CPyModuleObject,
leng=_len_module,
refs=_module_refs)
if self._profile: # profile type
self._prof(k).update(obj, s)
# recurse, but not for nested modules
if v.refs and deep < self._limit_ and not (deep and ismodule(obj)):
# add sizes of referents
r, z, d = v.refs, self._sizer, deep + 1
if sized and deep < self._detail_:
src/g/a/gamera-HEAD/trunk/gamera/gamera/gui/rule_engine_runner.py gamera(Download)
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # from inspect import isfunction, ismodule from os import path import wx from gamera.gui import toolbar, gui_util
engine = ruleengine.RuleEngine([data])
elif isinstance(data, ruleengine.RuleEngine):
engine = data
elif ismodule(data):
engine = ruleengine.RuleEngine(
[val for val in data.__dict__.values()
if isinstance(val, ruleengine.RuleEngine)])
src/t/o/topographica-HEAD/releases/0.8.2/topographica/topo/base/utils.py topographica(Download)
# CEBHACKALERT: when a base class for PatternGeneratorParameter etc
# exists, consider making this a method of that class.
from inspect import ismodule
def find_classes_in_package(package,parentclass):
"""
Return a dictionary containing all items of the type
"""
result = {}
for v1 in package.__dict__.itervalues():
if ismodule(v1):
for v2 in v1.__dict__.itervalues():
if (isinstance(v2,type)
and issubclass(v2,parentclass)
src/t/o/topographica-HEAD/releases/0.8.1/topographica/topo/base/utils.py topographica(Download)
# CEBHACKALERT: when a base class for PatternGeneratorParameter etc
# exists, consider making this a method of that class.
from inspect import ismodule
def find_classes_in_package(package,parentclass):
"""
Return a dictionary containing all items of the type
"""
result = {}
for v1 in package.__dict__.itervalues():
if ismodule(v1):
for v2 in v1.__dict__.itervalues():
if (isinstance(v2,type)
and issubclass(v2,parentclass)
1 | 2 | 3 | 4 | 5 Next