(self, name, value)
Control then set a metadata field.
Control then set a metadata field.
Control then set a metadata field .
def set(self, name, value):
        """Control then set a metadata field."""
        name = self._convert_name(name)

        if ((name in _ELEMENTSFIELD or name == 'Platform') and
            not isinstance(value, (list, tuple))):
            if isinstance(value, string_types):
                value = [v.strip() for v in value.split(',')]
            else:
                value = []
        elif (name in _LISTFIELDS and
              not isinstance(value, (list, tuple))):
            if isinstance(value, string_types):
                value = [value]
            else:
                value = []

        if logger.isEnabledFor(logging.WARNING):
            project_name = self['Name']

            scheme = get_scheme(self.scheme)
            if name in _PREDICATE_FIELDS and value is not None:
                for v in value:
                    # check that the values are valid
                    if not scheme.is_valid_matcher(v.split(';')[0]):
                        logger.warning(
                            "'%s': '%s' is not valid (field '%s')",
                            project_name, v, name)
            # FIXME this rejects UNKNOWN, is that right?
            elif name in _VERSIONS_FIELDS and value is not None:
                if not scheme.is_valid_constraint_list(value):
                    logger.warning("'%s': '%s' is not a valid version (field '%s')",
                                   project_name, value, name)
            elif name in _VERSION_FIELDS and value is not None:
                if not scheme.is_valid_version(value):
                    logger.warning("'%s': '%s' is not a valid version (field '%s')",
                                   project_name, value, name)

        if name in _UNICODEFIELDS:
            if name == 'Description':
                value = self._remove_line_prefix(value)

        self._fields[name] = value
def set ( self , name , value ) : name = self . _convert_name ( name ) if ( ( name in _ELEMENTSFIELD or name == 'Platform' ) and not isinstance ( value , ( list , tuple ) ) ) : if isinstance ( value , string_types ) : value = [ v . strip ( ) for v in value . split ( ',' ) ] else : value = [ ] elif ( name in _LISTFIELDS and not isinstance ( value , ( list , tuple ) ) ) : if isinstance ( value , string_types ) : value = [ value ] else : value = [ ] if logger . isEnabledFor ( logging . WARNING ) : project_name = self [ 'Name' ] scheme = get_scheme ( self . scheme ) if name in _PREDICATE_FIELDS and value is not None : for v in value : # check that the values are valid if not scheme . is_valid_matcher ( v . split ( ';' ) [ 0 ] ) : logger . warning ( "'%s': '%s' is not valid (field '%s')" , project_name , v , name ) # FIXME this rejects UNKNOWN, is that right? elif name in _VERSIONS_FIELDS and value is not None : if not scheme . is_valid_constraint_list ( value ) : logger . warning ( "'%s': '%s' is not a valid version (field '%s')" , project_name , value , name ) elif name in _VERSION_FIELDS and value is not None : if not scheme . is_valid_version ( value ) : logger . warning ( "'%s': '%s' is not a valid version (field '%s')" , project_name , value , name ) if name in _UNICODEFIELDS : if name == 'Description' : value = self . _remove_line_prefix ( value ) self . _fields [ name ] = value