Example #1
0
def fromstr(string, data=None):
    """Create an action instance based on a str() representation of an
        action.

        Raises UnknownActionError if the action type is unknown.
        Raises MalformedActionError if the action has other syntactic problems.
        """

    atype, ahash, attr_dict = _fromstr(string)

    if atype not in types:
        raise UnknownActionError(string, atype)

    action = types[atype](data=data, **attr_dict)

    ka = action.key_attr
    if ka is not None and (ka not in action.attrs or action.attrs[ka] is None):
        raise InvalidActionError(
            string,
            _("required attribute '%s' "
              "was not provided.") % ka)

    if ahash:
        action.hash = ahash

    return action
Example #2
0
def fromstr(string, data=None):
        """Create an action instance based on a str() representation of an
        action.

        Raises UnknownActionError if the action type is unknown.
        Raises MalformedActionError if the action has other syntactic problems.
        """

        atype, ahash, attr_dict = _fromstr(string)

        if atype not in types:
                raise UnknownActionError(string, atype)

        action = types[atype](data=data, **attr_dict)

        ka = action.key_attr
        if ka is not None and (ka not in action.attrs or
            action.attrs[ka] is None):
                raise InvalidActionError(string, _("required attribute '%s' "
                    "was not provided.") % ka)

        if ahash:
                action.hash = ahash

        return action
Example #3
0
def fromstr(string, data=None):
        """Create an action instance based on a str() representation of an
        action.

        Raises UnknownActionError if the action type is unknown.
        Raises MalformedActionError if the action has other syntactic problems.
        """

        return _fromstr(string)
Example #4
0
def attrsfromstr(string):
        """Create an attribute dict given a string w/ key=value pairs.

        Raises MalformedActionError if the attributes have syntactic problems.
        """
        return _fromstr("bogus %s" % string)[2]
Example #5
0
def attrsfromstr(string):
    """Create an attribute dict given a string w/ key=value pairs.

        Raises MalformedActionError if the attributes have syntactic problems.
        """
    return _fromstr("bogus %s" % string)[2]