當前位置: 首頁>>代碼示例>>Python>>正文


Python PackageManager.has_key方法代碼示例

本文整理匯總了Python中openalea.core.pkgmanager.PackageManager.has_key方法的典型用法代碼示例。如果您正苦於以下問題:Python PackageManager.has_key方法的具體用法?Python PackageManager.has_key怎麽用?Python PackageManager.has_key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openalea.core.pkgmanager.PackageManager的用法示例。


在下文中一共展示了PackageManager.has_key方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Session

# 需要導入模塊: from openalea.core.pkgmanager import PackageManager [as 別名]
# 或者: from openalea.core.pkgmanager.PackageManager import has_key [as 別名]
class Session(Observed):

    """
    A session is composed by different workspaces, and an user package.
    A workspace is an open node
    A session can be saved on disk.
    """

    USR_PKG_NAME = "__my package__"

    def __init__(self):

        Observed.__init__(self)

        self.workspaces = []
        self.cworkspace = -1  # current workspace
        self.graphViews = weakref.WeakKeyDictionary()

        self.datapool = DataPool()

        # Use dictionary
        self.use_by_name = {}
        self.use_by_interface = {}

        self.pkgmanager = PackageManager()

        self.empty_cnode_factory = CompositeNodeFactory("Workspace")
        self.clipboard = CompositeNodeFactory("Clipboard")

        self.init()

    # gengraph
    def simulate_workspace_addition(self):
        for ws in self.workspaces:
            self.notify_listeners(("workspace_added", ws))
    #/gengraph

    def get_current_workspace(self, ):
        """ Return the current workspace object """
        return self.workspaces[self.cworkspace]

    ws = property(get_current_workspace)

    def get_graph_views(self):
        return self.graphViews.keys()

    def add_graph_view(self, view):
        self.graphViews[view] = None

    def add_workspace(self, compositenode=None, notify=True):
        """
        Open a new workspace in the session
        if compositenode = None, create a new empty compositenode
        """
        if compositenode is None:
            compositenode = self.empty_cnode_factory.instantiate()
            compositenode.set_caption("")
            self.workspaces.append(compositenode)

        elif(compositenode not in self.workspaces):
            self.workspaces.append(compositenode)
        else:
            return compositenode

        if(notify):
            self.notify_listeners(("workspace_added", compositenode))

        return compositenode

    def close_workspace(self, index, notify=True):
        """ Close workspace at index """

        del self.workspaces[index]
        if(notify):
            self.notify_listeners()

    def init(self, create_workspace=True):
        """ Init the Session """

        self.session_filename = None
        #self.workspaces = []

        # init pkgmanager
        self.pkgmanager.find_and_register_packages()

        # Create user package if needed
        if (not self.pkgmanager.has_key(self.USR_PKG_NAME)):
            try:
                self.pkgmanager.create_user_package(self.USR_PKG_NAME, {})
            except:
                pass

        if (create_workspace):
            self.add_workspace()
            self.cworkspace = 0

        load_interfaces()
        self.notify_listeners()

    def clear(self, create_workspace=True):
#.........這裏部分代碼省略.........
開發者ID:VirtualPlants,項目名稱:openalea,代碼行數:103,代碼來源:session.py


注:本文中的openalea.core.pkgmanager.PackageManager.has_key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。