@@ -1002,33 +1002,12 @@ def notice_text(self):
10021002 pass
10031003 return ''
10041004
1005-
1006- def get_license_text_file_name (self ):
1007- """
1008- Return the license_text_file name if the license_text_file field
1009- exists
1010- """
1011- return self .parsed .get ('license_text_file' , '' )
1012-
1013- def get_license_text (self ):
1014- """
1015- Return the license_text if the license_text field exists.
1016- """
1017- return self .parsed .get ('license_text' , '' )
1018-
10191005 def get_about_name (self ):
10201006 """
10211007 Return the about object's name.
10221008 """
10231009 return self .parsed .get ('name' , '' )
10241010
1025- def get_about_resource_path (self ):
1026- """
1027- Return the about object's name
1028- """
1029- return self .parsed .get ('about_resource_path' , '' )
1030-
1031-
10321011class AboutCollector (object ):
10331012 """
10341013 A collection of AboutFile instances.
@@ -1174,13 +1153,8 @@ def generate_attribution(self, template_path=None, limit_to=None):
11741153 print ('Template: %(template_name)s not found' % locals ())
11751154 return
11761155
1177- # We only need the fields names and values to render the template
1178- validated_fields = []
1179- notice_text = []
1180- license_key = []
1181- license_text_list = []
1182- license_dict = {}
1183- common_license_dict = {}
1156+ about_object_fields = []
1157+ about_content_dict = {}
11841158 not_exist_components = list (limit_to )
11851159
11861160 # FIXME: this loop and conditional is too complex.
@@ -1198,59 +1172,23 @@ def generate_attribution(self, template_path=None, limit_to=None):
11981172 continue
11991173
12001174 if not limit_to or about_relative_path in limit_to :
1201- validated_fields .append (about_object .validated_fields )
1202- notice_text .append (about_object .notice_text ())
1203- license_text_file = about_object .get_license_text_file_name ()
1204- about_resource_path = about_object .get_about_resource_path ()
1205-
1206- if not about_resource_path :
1207- msg = ('About File: %s - The required field '
1208- 'about_resource_path was not found. '
1209- 'License generation is skipped.'
1210- % about_object .location )
1211- err = Error (GENATTRIB , 'about_resource' ,
1212- about_object .location , msg )
1213- self .genattrib_errors .append (err )
1214-
1215- if license_text_file :
1216- # Use the about_file_path as the key
1217- # Check if the key already existed in the dictionary
1218- # This shouldn't be reached as the 'about_resource_path'
1219- # should be unique.
1220- if about_resource_path in license_dict :
1221- # Raise error if key name are the same but the content
1222- # are different
1223- license_text_check = license_dict [about_resource_path ]
1224-
1225- if (unicode (license_text_check )
1226- != unicode (about_object .license_text ())):
1227- msg = ('License Name: %s - Same license name '
1228- 'with different content. License '
1229- 'generation is skipped.'
1230- % license_text_file )
1231- err = Error (GENATTRIB , 'license_text' ,
1232- license_text_file , msg )
1233- self .genattrib_errors .append (err )
1234- else :
1235- lft = unicode (about_object .license_text (),
1175+ about_content_dict = about_object .validated_fields
1176+ # Add information in the dictionary where it does not
1177+ # present in the ABOUT file
1178+ about_content_dict ['license_text_content' ] = unicode (about_object .license_text (),
12361179 errors = 'replace' )
1237- license_dict [about_resource_path ] = lft
1238-
1239- if license_text_file in COMMON_LICENSES :
1240- ltf = unicode (about_object .license_text (),
1241- errors = 'replace' )
1242- common_license_dict [license_text_file ] = ltf
1243- elif about_object .get_license_text ():
1244- # We do not need to do anything here as the license_text
1245- # will be captured directly in the about object.
1246- pass
1247- else :
1180+ about_content_dict ['notice_text_content' ] = about_object .notice_text ()
1181+
1182+ # Raise error if no license_text is found
1183+ if not about_content_dict ['license_text_content' ]:
12481184 msg = ('No license_text is found. '
12491185 'License generation is skipped.' )
12501186 err = Error (GENATTRIB , 'name' ,
12511187 about_object .get_about_name (), msg )
12521188 self .genattrib_errors .append (err )
12531189
1190+ about_object_fields .append (about_content_dict )
1191+
12541192 if not_exist_components :
12551193 for component in not_exist_components :
12561194 afp = self .user_provided_path + component .replace ('//' , '/' )
@@ -1260,17 +1198,13 @@ def generate_attribution(self, template_path=None, limit_to=None):
12601198 err = Error (GENATTRIB , 'about_file' , component , msg )
12611199 self .genattrib_errors .append (err )
12621200
1263- # We want to display common_licenses in alphabetical order
1201+ # TODO: Handle the grouping and ordering later
1202+ """# We want to display common_licenses in alphabetical order
12641203 for key in sorted(common_license_dict.keys()):
12651204 license_key.append(key)
1266- license_text_list .append (common_license_dict [key ])
1267-
1268- return template .render (about_objects = validated_fields ,
1269- license_keys = license_key ,
1270- license_texts = license_text_list ,
1271- notice_texts = notice_text ,
1272- license_dicts = license_dict ,
1273- common_licenses = COMMON_LICENSES )
1205+ license_text_list.append(common_license_dict[key])"""
1206+
1207+ return template .render (about_objects = about_object_fields )
12741208
12751209 def get_genattrib_errors (self ):
12761210 return self .genattrib_errors
0 commit comments