本文整理汇总了Python中openalea.core.pkgmanager.PackageManager.get_factory_from_url方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.get_factory_from_url方法的具体用法?Python PackageManager.get_factory_from_url怎么用?Python PackageManager.get_factory_from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.core.pkgmanager.PackageManager
的用法示例。
在下文中一共展示了PackageManager.get_factory_from_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DT_Text
# 需要导入模块: from openalea.core.pkgmanager import PackageManager [as 别名]
# 或者: from openalea.core.pkgmanager.PackageManager import get_factory_from_url [as 别名]
class DT_Text(DataReader):
__name__ = "Text"
__created_mimetype__ = "text/plain"
__opened_mimetypes__ = ["text/plain",
"application/x-qt-windows-mime;value=\"FileName\"",
NodeFactory.mimetype,
CompositeNodeFactory.mimetype]
__icon_rc__ = ":icons/text.png"
def __init__(self):
DataReader.__init__(self)
self.pm = PackageManager()
def new(self):
text = ""
name = self.__name__
return self.wrap_data(name, text)
def open_url(self, parsedUrl):
url = parsedUrl.geturl()
if parsedUrl.scheme == "oa":
fac = self.pm.get_factory_from_url(parsedUrl)
if isinstance(fac, CompositeNodeFactory):
pkg = self.pm.get_package_from_url(parsedUrl)[0]
name = pkg.get_wralea_path()
else:
mod_name = fac.get_node_module()
name = inspect.getsourcefile(mod_name)
f = open(name)
elif parsedUrl.scheme == "file":
name = file_url_to_path(url)
#name = parsedUrl.path#.strip("/")
f = open(name)
else:
f = urllib2.urlopen(url)
name = parsedUrl.path
text = f.read()
f.close()
return self.wrap_data(name, text)