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


Python imp.is_builtin方法代碼示例

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


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

示例1: test_sys_path_none_builtins

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def test_sys_path_none_builtins(self):
        prevPath = sys.path

        #import some builtin modules not previously imported
        try:
            sys.path = prevPath + [None]
            if not imp.is_builtin('copy_reg'):
                self.assertTrue('copy_reg' not in sys.modules.keys())
            import datetime
            import copy_reg
            self.assertTrue('datetime' in sys.modules.keys())
            self.assertTrue('copy_reg' in sys.modules.keys())
            
            sys.path = [None]
            if not imp.is_builtin('binascii'):
                self.assertTrue('binascii' not in sys.modules.keys())
            import datetime
            import copy_reg
            import binascii
            self.assertTrue('datetime' in sys.modules.keys())
            self.assertTrue('copy_reg' in sys.modules.keys())
            self.assertTrue('binascii' in sys.modules.keys())
            
        finally:
            sys.path = prevPath 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:test_imp.py

示例2: find_builtin_module

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def find_builtin_module(self, name):
        # XXX frozen packages?
        if imp.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if imp.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:9,代碼來源:ihooks.py

示例3: is_builtin

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def is_builtin(self, name): return imp.is_builtin(name) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:3,代碼來源:ihooks.py

示例4: test_is_builtin

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def test_is_builtin(self):
    
        self.assertEqual(imp.is_builtin("xxx"),0)
        self.assertEqual(imp.is_builtin("12324"),0)
        self.assertEqual(imp.is_builtin("&*^^"),0)
        
        self.assertEqual(imp.is_builtin("dir"),0)
        self.assertEqual(imp.is_builtin("__doc__"),0)
        self.assertEqual(imp.is_builtin("__name__"),0)
        
        self.assertEqual(imp.is_builtin("_locle"),0)
        
        self.assertEqual(imp.is_builtin("cPickle"),1)
        self.assertEqual(imp.is_builtin("_random"),1)
            
        if is_posix:
            self.assertEqual(imp.is_builtin("posix"),1)
        else:
            self.assertEqual(imp.is_builtin("nt"),1)
            
        self.assertEqual(imp.is_builtin("thread"),1)
        
        
        # there are a several differences between ironpython and cpython
        if is_cli:
            self.assertEqual(imp.is_builtin("copy_reg"),1)
        else:
            self.assertEqual(imp.is_builtin("copy_reg"),0)
        
        # supposedly you can't re-init these
        self.assertEqual(imp.is_builtin("sys"), -1)
        self.assertEqual(imp.is_builtin("__builtin__"), -1)
        self.assertEqual(imp.is_builtin("exceptions"), -1)
        
        imp.init_builtin("sys")
        imp.init_builtin("__builtin__")
        imp.init_builtin("exceptions") 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:39,代碼來源:test_imp.py

示例5: test_is_builtin

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def test_is_builtin(self):

        self.assertEqual(imp.is_builtin("xxx"),0)
        self.assertEqual(imp.is_builtin("12324"),0)
        self.assertEqual(imp.is_builtin("&*^^"),0)

        self.assertEqual(imp.is_builtin("dir"),0)
        self.assertEqual(imp.is_builtin("__doc__"),0)
        self.assertEqual(imp.is_builtin("__name__"),0)

        self.assertEqual(imp.is_builtin("_locle"),0)

        if is_cli:
            self.assertEqual(imp.is_builtin("_pickle"),0)
        else:
            self.assertEqual(imp.is_builtin("_pickle"),1)
        self.assertEqual(imp.is_builtin("_random"),1)

        # nt module disabled in Silverlight
        if is_posix:
            self.assertEqual(imp.is_builtin("posix"),1)
        else:
            self.assertEqual(imp.is_builtin("nt"),1)

        self.assertEqual(imp.is_builtin("_thread"),1)

        # there are a several differences between ironpython and cpython
        if is_cli:
            self.assertEqual(imp.is_builtin("copyreg"),1)
        else:
            self.assertEqual(imp.is_builtin("copyreg"),0)

        # supposedly you can't re-init these
        self.assertEqual(imp.is_builtin("sys"), -1)
        self.assertEqual(imp.is_builtin("builtins"), -1)

        imp.init_builtin("sys")
        imp.init_builtin("builtins") 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:40,代碼來源:test_imp.py

示例6: get

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def get(self, fullname):
        if isinstance(fullname, str) and is_builtin(fullname) != 0:
            raise ImportError()
        imp = self._raw_get(fullname)
        if not imp.exists:
            raise ImportError()
        return imp 
開發者ID:lordmauve,項目名稱:chopsticks,代碼行數:9,代碼來源:bubble.py

示例7: test_imp_is_builtin

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def test_imp_is_builtin(self):
        self.assertTrue(all(imp.is_builtin(mod)
                            for mod in ['sys', '__builtin__', 'imp']))
        self.assertFalse(imp.is_builtin('os')) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:6,代碼來源:test_import_jy.py

示例8: is_stdlib_name

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def is_stdlib_name(modname):
    """
    Return :data:`True` if `modname` appears to come from the standard library.
    """
    if imp.is_builtin(modname) != 0:
        return True

    module = sys.modules.get(modname)
    if module is None:
        return False

    # six installs crap with no __file__
    modpath = os.path.abspath(getattr(module, '__file__', ''))
    return is_stdlib_path(modpath) 
開發者ID:dw,項目名稱:mitogen,代碼行數:16,代碼來源:master.py

示例9: getmod

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def getmod(self, nm, isbuiltin=imp.is_builtin):
        if isbuiltin(nm):
            return depend.modules.BuiltinModule(nm)
        return None 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:6,代碼來源:impdirector.py

示例10: getmod

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def getmod(self, nm, isbuiltin=imp.is_builtin):
        # Return initialized built-in module object or None
        # if there is no built-in module with that name.
        return imp.init_builtin(nm) 
開發者ID:Lithium876,項目名稱:ConTroll_Remote_Access_Trojan,代碼行數:6,代碼來源:iu.py

示例11: test_imp_is_builtin

# 需要導入模塊: import imp [as 別名]
# 或者: from imp import is_builtin [as 別名]
def test_imp_is_builtin(self):
        self.assertTrue(all(imp.is_builtin(mod)
                            for mod in ['sys', '__builtin__']))
        self.assertFalse(imp.is_builtin('os')) 
開發者ID:Acmesec,項目名稱:CTFCrackTools-V2,代碼行數:6,代碼來源:test_import_jy.py


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