本文整理匯總了Python中MMTK.Utility.readURL方法的典型用法代碼示例。如果您正苦於以下問題:Python Utility.readURL方法的具體用法?Python Utility.readURL怎麽用?Python Utility.readURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MMTK.Utility
的用法示例。
在下文中一共展示了Utility.readURL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import readURL [as 別名]
def __init__(self, filename, database_name, module, instancevars):
self.filename = filename
self.database_name = database_name
file_text = Utility.readURL(filename)
newvars = {}
exec file_text in vars(module), newvars
for name, value in newvars.items():
setattr(self, name, value)
self.parent = None
if not hasattr(self, 'instance'): self.instance = []
for attr in instancevars+('parent',):
if not hasattr(self, attr): setattr(self, attr, [])
if attr not in self.instance: self.instance.append(attr)
attributes = vars(self).items()
attributes.sort(lambda a, b: cmp(a[0], b[0]))
for name, object in attributes:
if hasattr(object, 'is_instance_var'):
if name not in self.instance:
self.instance.append(name)
object.parent = self
object.name = name
if hasattr(object, 'object_list'):
getattr(self, object.object_list).append(object)
示例2: createObject
# 需要導入模塊: from MMTK import Utility [as 別名]
# 或者: from MMTK.Utility import readURL [as 別名]
def createObject(self, newvars):
file_text = Utility.readURL(self.filename)
exec file_text in vars(self.environment), newvars