Esempio n. 1
0
    def __init__(self, other):
        super(dict, self).__init__()

        if not protocol.implements(other, structured.IStructured):
            raise TypeError("Can only set scope from IStructured.")

        # Copy the scope locally.
        for key in structured.getmembers_runtime(other):
            self[key] = structured.resolve(other, key)
Esempio n. 2
0
    def getmembers_runtime(self):
        """Gets members (vars) from all scopes using ONLY runtime information.

        You most likely want to use ScopeStack.getmembers instead.

        Returns:
            Set of available vars.

        Raises:
            NotImplementedError if any scope fails to implement 'getmembers'.
        """
        names = set()
        for scope in self.scopes:
            names.update(structured.getmembers_runtime(scope))

        return names
Esempio n. 3
0
    def getmembers_runtime(self):
        """Gets members (vars) from all scopes using ONLY runtime information.

        You most likely want to use ScopeStack.getmembers instead.

        Returns:
            Set of available vars.

        Raises:
            NotImplementedError if any scope fails to implement 'getmembers'.
        """
        names = set()
        for scope in self.scopes:
            names.update(structured.getmembers_runtime(scope))

        return names
Esempio n. 4
0
    def getmembers(self):
        """Gets members (vars) from all scopes, using both runtime and static.

        This method will attempt both static and runtime getmembers. This is the
        recommended way of getting available members.

        Returns:
            Set of available vars.

        Raises:
            NotImplementedError if any scope fails to implement 'getmembers'.
        """
        names = set()
        for scope in self.scopes:
            if isinstance(scope, type):
                names.update(structured.getmembers_static(scope))
            else:
                names.update(structured.getmembers_runtime(scope))

        return names
Esempio n. 5
0
    def getmembers(self):
        """Gets members (vars) from all scopes, using both runtime and static.

        This method will attempt both static and runtime getmembers. This is the
        recommended way of getting available members.

        Returns:
            Set of available vars.

        Raises:
            NotImplementedError if any scope fails to implement 'getmembers'.
        """
        names = set()
        for scope in self.scopes:
            if isinstance(scope, type):
                names.update(structured.getmembers_static(scope))
            else:
                names.update(structured.getmembers_runtime(scope))

        return names