Пример #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
Пример #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
Пример #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)
Пример #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]
Пример #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]