Python imp.is_builtin() Examples

The following are 30 code examples of imp.is_builtin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module imp , or try the search function .
Example #1
Source File: test_imp.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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 
Example #2
Source File: ihooks.py    From unity-python with MIT License 5 votes vote down vote up
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 
Example #3
Source File: ihooks.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #4
Source File: ihooks.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #5
Source File: test_import_jy.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_imp_is_builtin(self):
        self.assertTrue(all(imp.is_builtin(mod)
                            for mod in ['sys', '__builtin__']))
        self.assertFalse(imp.is_builtin('os')) 
Example #6
Source File: ihooks.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #7
Source File: ihooks.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #8
Source File: ihooks.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: ihooks.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #10
Source File: ihooks.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #11
Source File: ImportManager.py    From moviegrabber with GNU General Public License v3.0 5 votes vote down vote up
def getmod(self, nm, isbuiltin=imp.is_builtin):
        if isbuiltin(nm):
            mod = imp.load_module(nm, None, nm, ('', '', imp.C_BUILTIN))
            return mod
        return None 
Example #12
Source File: ihooks.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
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 
Example #13
Source File: ihooks.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #14
Source File: ihooks.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #15
Source File: iu.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
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) 
Example #16
Source File: ihooks.py    From unity-python with MIT License 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #17
Source File: ihooks.py    From unity-python with MIT License 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #18
Source File: ihooks.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #19
Source File: ihooks.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #20
Source File: ihooks.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #21
Source File: ihooks.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #22
Source File: ihooks.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #23
Source File: ihooks.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #24
Source File: test_import_jy.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_imp_is_builtin(self):
        self.assertTrue(all(imp.is_builtin(mod)
                            for mod in ['sys', '__builtin__']))
        self.assertFalse(imp.is_builtin('os')) 
Example #25
Source File: ihooks.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #26
Source File: ihooks.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #27
Source File: test_imp.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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") 
Example #28
Source File: ihooks.py    From meddle with MIT License 5 votes vote down vote up
def is_builtin(self, name): return imp.is_builtin(name) 
Example #29
Source File: ihooks.py    From meddle with MIT License 5 votes vote down vote up
def find_builtin_module(self, name):
        # XXX frozen packages?
        if self.hooks.is_builtin(name):
            return None, '', ('', '', BUILTIN_MODULE)
        if self.hooks.is_frozen(name):
            return None, '', ('', '', FROZEN_MODULE)
        return None 
Example #30
Source File: ihooks.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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