@@ -97,7 +97,7 @@ def repr_problem(obj):
9797
9898
9999IGNORED = 'field or line ignored problem'
100- VALUE = 'missing or empty value problem'
100+ VALUE = 'missing or empty or multiple value problem'
101101FILE = 'file problem'
102102URL = 'URL problem'
103103VCS = 'Version control problem'
@@ -109,16 +109,13 @@ def repr_problem(obj):
109109
110110
111111MANDATORY_FIELDS = (
112- # 'about_resource',
113- # 'about_file',
114112 'name' ,
115113 'version' ,
116114)
117115
118116
119117BASIC_FIELDS = (
120118 'about_resource' ,
121- 'about_resource_path' , # Need to update spec
122119 'spec_version' ,
123120 'date' ,
124121 'description' ,
@@ -734,7 +731,6 @@ def validate(self):
734731
735732 for field_name , value in self .validated_fields .items ():
736733 self .check_is_ascii (self .validated_fields .get (field_name ))
737- # self.validate_known_optional_fields(field_name)
738734 self .validate_file_field_exists (field_name , value )
739735 self .validate_url_field (field_name , network_check = False )
740736 self .validate_spdx_license (field_name , value )
@@ -854,28 +850,28 @@ def validate_spdx_license(self, field_name, field_value):
854850 if not field_name == 'license_spdx' :
855851 return
856852 # FIXME: do we support more than one ID?
857- spdx_ids = field_value . split ()
858- for spdx_id in spdx_ids :
859- # valid id, matching the case
860- if spdx_id in SPDX_LICENSE_IDS .values ():
861- continue
853+ # Not support multiple IDs
854+ spdx_id = field_value
855+ # valid id, matching the case
856+ if spdx_id in SPDX_LICENSE_IDS .values ():
857+ return
862858
863- spdx_id_lower = spdx_id .lower ()
859+ spdx_id_lower = spdx_id .lower ()
864860
865- # conjunctions
866- if spdx_id_lower in ['or' , 'and' ]:
867- continue
861+ # conjunctions
862+ if spdx_id_lower in ['or' , 'and' ]:
863+ return
868864
869- # lowercase check
870- try :
871- standard_id = SPDX_LICENSE_IDS [spdx_id_lower ]
872- except KeyError :
873- self .errors .append (Error (SPDX , field_name , spdx_id ,
874- 'Invalid SPDX license id.' ))
875- else :
876- msg = ('Non standard SPDX license id case. Should be %r.'
877- % (standard_id ))
878- self .warnings .append (Warn (SPDX , field_name , id , msg ))
865+ # lowercase check
866+ try :
867+ standard_id = SPDX_LICENSE_IDS [spdx_id_lower ]
868+ except KeyError :
869+ self .errors .append (Error (SPDX , field_name , spdx_id ,
870+ 'Invalid SPDX license id.' ))
871+ else :
872+ msg = ('Non standard SPDX license id case. Should be %r.'
873+ % (standard_id ))
874+ self .warnings .append (Warn (SPDX , field_name , id , msg ))
879875
880876 def validate_url_field (self , field_name , network_check = False ):
881877 """
@@ -974,23 +970,31 @@ def get_custom_field_keys(self):
974970 return custom_key
975971
976972 def get_row_data (self , updated_path , custom_keys ):
973+ print (updated_path )
974+ print (custom_keys )
977975 """
978976 Create a csv compatible row of data for this object.
979977 """
980978 row = [updated_path ]
981- # FIXME: this list is not used? what was the intent?
982- custom_field = []
979+ no_multi_license_fields = ('license_text_file' ,
980+ 'license_spdx' ,
981+ 'dje_license' ,
982+ 'dje_license_name' )
983983 for field in MANDATORY_FIELDS + OPTIONAL_FIELDS :
984984 if field in self .validated_fields :
985985 row += [self .validated_fields [field ]]
986- elif field == 'about_resource_path' :
987- about = self .validated_fields ['about_resource' ]
988- if about .endswith ('.' ):
989- about_resource_path = dirname (updated_path ) + '/'
990- else :
991- about_resource_path = normpath (join (dirname (updated_path ),
992- about ))
993- row += [about_resource_path ]
986+ # The following code is to catch is the input contians any
987+ # multiple licenses
988+ if field in no_multi_license_fields :
989+ for lic_field in no_multi_license_fields :
990+ try :
991+ if '\n ' in self .validated_fields [lic_field ]:
992+ self .errors .append (Error (VALUE ,
993+ lic_field ,
994+ self .validated_fields [field ],
995+ "Multiple Licenses are not supported." ))
996+ except :
997+ pass
994998 else :
995999 row += ['' ]
9961000
@@ -1044,20 +1048,6 @@ def duplicate_file_names_when_lowercased(file_location):
10441048 names .append (name )
10451049 return names
10461050
1047- """def tmp_get_license_text(self):
1048- # TODO: This is a temp fix for handling multiple 'license_text_file'
1049- # The code should get the license text from the def license_text(self),
1050- # not this function.
1051- license_text = ""
1052- licenses = self.parsed.get('license_text_file', '')
1053- license_list = licenses.split('\n ')
1054- for lic in license_list:
1055- location = join(dirname(self.location), lic)
1056- with open(location, 'rU') as f:
1057- license_text += f.read()
1058- license_text += '\n \n \n \n \n \n '
1059- return license_text"""
1060-
10611051 def license_text (self ):
10621052 """
10631053 Return the license text if the license_text_file field exists and the
0 commit comments