當前位置: 首頁>>代碼示例>>Python>>正文


Python __builtin__.reload方法代碼示例

本文整理匯總了Python中__builtin__.reload方法的典型用法代碼示例。如果您正苦於以下問題:Python __builtin__.reload方法的具體用法?Python __builtin__.reload怎麽用?Python __builtin__.reload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在__builtin__的用法示例。


在下文中一共展示了__builtin__.reload方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reload

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def reload(module, exclude=['sys', 'os.path', '__builtin__', '__main__']):
    """Recursively reload all modules used in the given module.  Optionally
    takes a list of modules to exclude from reloading.  The default exclude
    list contains sys, __main__, and __builtin__, to prevent, e.g., resetting
    display, exception, and io hooks.
    """
    global found_now
    for i in exclude:
        found_now[i] = 1
    try:
        with replace_import_hook(deep_import_hook):
            ret = deep_reload_hook(module)
    finally:
        found_now = {}
    return ret

# Uncomment the following to automatically activate deep reloading whenever
# this module is imported
#__builtin__.reload = reload 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:deepreload.py

示例2: patch_reload

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def patch_reload():
    if sys.version_info[0] >= 3:
        import builtins # Py3
    else:
        import __builtin__ as builtins

    if hasattr(builtins, "reload"):
        sys.builtin_orig_reload = builtins.reload
        builtins.reload = patched_reload(sys.builtin_orig_reload)  # @UndefinedVariable
        try:
            import imp
            sys.imp_orig_reload = imp.reload
            imp.reload = patched_reload(sys.imp_orig_reload)  # @UndefinedVariable
        except:
            pass
    else:
        try:
            import importlib
            sys.importlib_orig_reload = importlib.reload  # @UndefinedVariable
            importlib.reload = patched_reload(sys.importlib_orig_reload)  # @UndefinedVariable
        except:
            pass

    del builtins 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:26,代碼來源:_pydev_sys_patch.py

示例3: cancel_patches_in_sys_module

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def cancel_patches_in_sys_module():
    sys.exc_info = sys.system_exc_info  # @UndefinedVariable
    if sys.version_info[0] >= 3:
        import builtins # Py3
    else:
        import __builtin__ as builtins

    if hasattr(sys, "builtin_orig_reload"):
        builtins.reload = sys.builtin_orig_reload

    if hasattr(sys, "imp_orig_reload"):
        import imp
        imp.reload = sys.imp_orig_reload

    if hasattr(sys, "importlib_orig_reload"):
        import importlib
        importlib.reload = sys.importlib_orig_reload

    del builtins 
開發者ID:fabioz,項目名稱:PyDev.Debugger,代碼行數:21,代碼來源:_pydev_sys_patch.py

示例4: patch_reload

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def patch_reload():
    try:
        import __builtin__ as builtins
    except ImportError:
        import builtins

    if hasattr(builtins, "reload"):
        sys.builtin_orig_reload = builtins.reload
        builtins.reload = patched_reload(sys.builtin_orig_reload)  # @UndefinedVariable
        try:
            import imp
            sys.imp_orig_reload = imp.reload
            imp.reload = patched_reload(sys.imp_orig_reload)  # @UndefinedVariable
        except:
            pass
    else:
        try:
            import importlib
            sys.importlib_orig_reload = importlib.reload  # @UndefinedVariable
            importlib.reload = patched_reload(sys.importlib_orig_reload)  # @UndefinedVariable
        except:
            pass

    del builtins 
開發者ID:mrknow,項目名稱:filmkodi,代碼行數:26,代碼來源:_pydev_sys_patch.py

示例5: cancel_patches_in_sys_module

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def cancel_patches_in_sys_module():
    sys.exc_info = sys.system_exc_info  # @UndefinedVariable
    try:
        import __builtin__ as builtins
    except ImportError:
        import builtins

    if hasattr(sys, "builtin_orig_reload"):
        builtins.reload = sys.builtin_orig_reload

    if hasattr(sys, "imp_orig_reload"):
        import imp
        imp.reload = sys.imp_orig_reload

    if hasattr(sys, "importlib_orig_reload"):
        import importlib
        importlib.reload = sys.importlib_orig_reload

    del builtins 
開發者ID:mrknow,項目名稱:filmkodi,代碼行數:21,代碼來源:_pydev_sys_patch.py

示例6: reload_pipeline

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def reload_pipeline():
    """Attempt to reload pipeline at run-time.

    CAUTION: This is primarily for development and debugging purposes.

    """

    api.uninstall()
    _uninstall_menu()

    for module in ("avalon.api",
                   "avalon.io",
                   "avalon.lib",
                   "avalon.pipeline",
                   "avalon.tools",
                   "avalon.nuke",
                   "avalon.nuke.pipeline",
                   "avalon.nuke.lib",
                   "avalon.nuke.workio"
                   ):

        log.info("Reloading module: {}...".format(module))

        module = importlib.import_module(module)
        reload(module)

    import avalon.nuke
    api.install(avalon.nuke)

    _register_events() 
開發者ID:getavalon,項目名稱:core,代碼行數:32,代碼來源:pipeline.py

示例7: reloadAll

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def reloadAll(prefix=None, debug=False):
    """Automatically reload everything whose __file__ begins with prefix.
    - Skips reload if the file has not been updated (if .pyc is newer than .py)
    - if prefix is None, checks all loaded modules
    """
    failed = []
    changed = []
    for modName, mod in list(sys.modules.items()):  ## don't use iteritems; size may change during reload
        if not inspect.ismodule(mod):
            continue
        if modName == '__main__':
            continue
        
        ## Ignore if the file name does not start with prefix
        if not hasattr(mod, '__file__') or os.path.splitext(mod.__file__)[1] not in ['.py', '.pyc']:
            continue
        if prefix is not None and mod.__file__[:len(prefix)] != prefix:
            continue
        
        ## ignore if the .pyc is newer than the .py (or if there is no pyc or py)
        py = os.path.splitext(mod.__file__)[0] + '.py'
        pyc = py + 'c'
        if py not in changed and os.path.isfile(pyc) and os.path.isfile(py) and os.stat(pyc).st_mtime >= os.stat(py).st_mtime:
            #if debug:
                #print "Ignoring module %s; unchanged" % str(mod)
            continue
        changed.append(py)  ## keep track of which modules have changed to insure that duplicate-import modules get reloaded.
        
        try:
            reload(mod, debug=debug)
        except:
            printExc("Error while reloading module %s, skipping\n" % mod)
            failed.append(mod.__name__)
        
    if len(failed) > 0:
        raise Exception("Some modules failed to reload: %s" % ', '.join(failed)) 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:38,代碼來源:reload.py

示例8: updateFunction

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def updateFunction(old, new, debug, depth=0, visited=None):
    #if debug and depth > 0:
        #print "    -> also updating previous version", old, " -> ", new
        
    old.__code__ = new.__code__
    old.__defaults__ = new.__defaults__
    
    if visited is None:
        visited = []
    if old in visited:
        return
    visited.append(old)
    
    ## finally, update any previous versions still hanging around..
    if hasattr(old, '__previous_reload_version__'):
        maxDepth = updateFunction(old.__previous_reload_version__, new, debug, depth=depth+1, visited=visited)
    else:
        maxDepth = depth
        
    ## We need to keep a pointer to the previous version so we remember to update BOTH
    ## when the next reload comes around.
    if depth == 0:
        new.__previous_reload_version__ = old
    return maxDepth



## For classes:
##  1) find all instances of the old class and set instance.__class__ to the new class
##  2) update all old class methods to use code from the new class methods 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:32,代碼來源:reload.py

示例9: reload

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def reload(self, module, path = None):
        name = str(module.__name__)
        stuff = self.loader.find_module(name, path)
        if not stuff:
            raise ImportError, "Module %s not found for reload" % name
        return self.loader.load_module(name, stuff) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:8,代碼來源:ihooks.py

示例10: install

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def install(self):
        self.save_import_module = __builtin__.__import__
        self.save_reload = __builtin__.reload
        if not hasattr(__builtin__, 'unload'):
            __builtin__.unload = None
        self.save_unload = __builtin__.unload
        __builtin__.__import__ = self.import_module
        __builtin__.reload = self.reload
        __builtin__.unload = self.unload 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:11,代碼來源:ihooks.py

示例11: uninstall

# 需要導入模塊: import __builtin__ [as 別名]
# 或者: from __builtin__ import reload [as 別名]
def uninstall(self):
        __builtin__.__import__ = self.save_import_module
        __builtin__.reload = self.save_reload
        __builtin__.unload = self.save_unload
        if not __builtin__.unload:
            del __builtin__.unload 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:8,代碼來源:ihooks.py


注:本文中的__builtin__.reload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。