示例#1
0
    def data(self, value):
        """Resource data is stored as a tuple with one line per element.

        The value must be formatted only if it contains a value. If an empty
        string or a tuple would be passed to format_data, the result would be
        tuple that contains one empty string. The reason is that empty data is
        considered valid byte the formatter.
        """

        if not value:
            value = None

        self._data = Parser.format_data(self.category, value)
示例#2
0
    def data(self, value):
        """Convert content data to tuple of utf-8 encoded unicode strings.

        The tool must be able to idenfity if the value was given at all. This
        case is idenfigied with value None. With empty value from user, there
        will be a single element in tuple which is empty string. By doing this,
        there is no need to check value None each time when accessed.
        """

        if value is not None:
            data = Parser.format_data(self.category, value)
        else:
            data = ()

        self._data = data  # pylint: disable=attribute-defined-outside-init