我们从Python开源项目中,提取了以下30个代码示例,用于说明如何使用imp.is_frozen()。
def main_is_frozen(): return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")) # tools/freeze #~ if __name__ == '__main__': #some test code here. #~ def hello(name="bla"): #~ print "hello, ", name #~ myt = MyTimer(1.0, 5, hello, ["bob"]) #~ myt.start() #~ time.sleep(4) #~ myt.cancel() #~ print "next timer" #~ myt = MyTimer(1.0, 0, hello, ["bob"]) #~ myt.start() #~ time.sleep(6) #~ myt.cancel()
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
def is_frozen(self, name): return imp.is_frozen(name)
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
def main_is_frozen(): return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") # old py2exe or imp.is_frozen("__main__")) # tools/freeze
def main_is_frozen(): return (hasattr(sys, "frozen") or # new py2exe hasattr(sys, "importers") or # old py2exe imp.is_frozen("__main__")) # tools/freeze
def test_everyone_has___loader__(self): # Issue #17098: all modules should have __loader__ defined. for name, module in sys.modules.items(): if isinstance(module, types.ModuleType): if name in sys.builtin_module_names: self.assertEqual(importlib.machinery.BuiltinImporter, module.__loader__) elif imp.is_frozen(name): self.assertEqual(importlib.machinery.FrozenImporter, module.__loader__)
def main_is_frozen(): return (hasattr(sys, "frozen") or hasattr(sys, "importers") or imp.is_frozen("__main__"))