本文整理匯總了Python中importlib.machinery.__name__方法的典型用法代碼示例。如果您正苦於以下問題:Python machinery.__name__方法的具體用法?Python machinery.__name__怎麽用?Python machinery.__name__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類importlib.machinery
的用法示例。
在下文中一共展示了machinery.__name__方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __repr__
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def __repr__(self):
return self.__class__.__name__ + repr(self.args)
示例2: run_script
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
require(dist_spec)[0].run_script(script_name, ns)
# backward compatibility
示例3: resolve
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def resolve(self):
"""
Resolve the entry point from its module and attrs.
"""
module = __import__(self.module_name, fromlist=['__name__'], level=0)
try:
return functools.reduce(getattr, self.attrs, module)
except AttributeError as exc:
raise ImportError(str(exc))
示例4: __repr__
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def __repr__(self):
return self.__class__.__name__+repr(self.args)
示例5: run_script
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
require(dist_spec)[0].run_script(script_name, ns)
# backward compatibility
示例6: run_script
# 需要導入模塊: from importlib import machinery [as 別名]
# 或者: from importlib.machinery import __name__ [as 別名]
def run_script(self, requires, script_name):
"""Locate distribution for `requires` and run `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
self.require(requires)[0].run_script(script_name, ns)