本文整理匯總了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)