Пример #1
0
 def __setCore(self, path, value, *, force=True):
     new_core_state = setDataForPath(self.__coreState, path, value)
     if self.__coreState is new_core_state and not force:
         return
     self.__coreState = new_core_state
     next_state = self.__nextState
     for core_plugin_path in self.__corePluginPaths:
         next_state = setDataForPath(
             next_state, core_plugin_path, new_core_state
         )
     if next_state is not self.__nextState:
         self.__nextState = next_state
         self.__stateUpdateEvent.set()
Пример #2
0
    async def __stateUpdateTaskImpl(self):
        while True:
            await self.__stateUpdateEvent.wait()
            self.__stateUpdateEvent.clear()

            next_state = self.__nextState
            if self.__unresolvedState is not next_state:
                for path_prefix in self.__corePluginPaths:
                    next_state = setDataForPath(
                        next_state,
                        path_prefix + ("symlinks",),
                        AttachedInfo.symlinkInfoDict(next_state),
                    )

                self.__resolvedState = AttachedInfo.resolved(next_state)
                self.__realpath = (
                    lambda func: lambda path: func(makePath(path))
                )(AttachedInfo.realpath(next_state))
                self.__unresolvedState = self.__nextState = next_state

            self.__rawSubscriptionRoot.update(
                self.__rawState, self.__updatedSubscriptions
            )
            self.__unresolvedSubscriptionRoot.update(
                self.__unresolvedState, self.__updatedSubscriptions
            )
            self.__resolvedSubscriptionRoot.update(
                self.__resolvedState, self.__updatedSubscriptions
            )

            updated_subscriptions = self.__updatedSubscriptions
            self.__updatedSubscriptions = set()
            for sub in updated_subscriptions:
                sub.update()
Пример #3
0
 def __setPluginState(self, plugin_info, path, value):
     if not plugin_info.disabled:
         new_state = setDataForPath(
             plugin_info.state, path, value, undefined=None
         )
         if plugin_info.state is not new_state:
             plugin_info.state = new_state
             self.__set(plugin_info.path, new_state)
Пример #4
0
    def setRawState(self, new_state: ImmutableDict):
        new_state = sanitize(new_state)
        if self.__rawState is new_state:
            return
        if not new_state.isImmutableJson:
            raise Exception("Invalid state (not immutable json)")
        self.__rawState = new_state
        self.__updatePlugins()

        for plugin in self.__pluginInfos:
            new_state = setDataForPath(new_state, plugin.path, plugin.state)

        self.__nextState = new_state
        self.__setCore(
            ("plugins",),
            {pathToString(path): config for path, config in self.__pluginList},
            force=True,
        )
Пример #5
0
 def __set(self, path: PathType, value):
     self.__nextState = setDataForPath(self.__nextState, path, value)
     if self.__nextState is not self.__unresolvedState:
         self.__stateUpdateEvent.set()
Пример #6
0
 def set(self, path, value):
     self.__state = setDataForPath(self.__state, path, value)
     if self.__immediate_updates:
         self.submitState()