@@ -1263,68 +1263,79 @@ def generate_attribution(self, template_path=None, limit_to=None):
12631263 except j2 .TemplateNotFound :
12641264 return
12651265 limit_to = limit_to or []
1266- limit_to = set (limit_to )
1266+ # ToDo: The set(limit_to) break the order of the original limit_to list
1267+ #limit_to = set(limit_to)
12671268
12681269 about_object_fields = []
12691270 about_content_dict = {}
12701271
12711272 not_process_components = list (limit_to )
1273+
1274+ component_exist = False
12721275
1273- for about_object in self :
1274- # FIXME: what is the meaning of this partition?
1275- # PO created the var some_path to provide some clarity
1276- # but what does the second element means?
1277- file_name = about_object .location .partition (self .location )[2 ]
1278- # FIXME: a path starting with / is NOT relative
1279- about_relative_path = '/' + file_name
1280-
1281- if limit_to :
1282- try :
1283- not_process_components .remove (about_relative_path )
1284- except Exception as e :
1285- continue
1286-
1287- #if limit_to and about_relative_path in limit_to:
1288- # continue
1289-
1290- about_content = about_object .validated_fields
1291- # Add information in the dictionary if not in the ABOUT file
1292- lic_text = unicode (about_object .license_text (),
1293- errors = 'replace' )
1294-
1295- about_content ['license_text' ] = lic_text
1296- notice_text = about_object .notice_text ()
1297- about_content ['notice_text' ] = notice_text
1298-
1299- # FIXME: The following is temporary code to handle multiple
1300- # license_text_file paths in the field value, one per lne
1301- for k in about_content :
1302- if ('\n ' in about_content [k ]
1303- and k == 'license_text_file' ):
1304- # FIXME: we should report decoding errors
1305- lic_text = unicode (about_object .tmp_get_license_text (),
1276+ # ToDo: temp fix to have correct order in the attribution generation based on
1277+ # the input
1278+ for component in not_process_components :
1279+ for about_object in self :
1280+ # FIXME: what is the meaning of this partition?
1281+ # PO created the var some_path to provide some clarity
1282+ # but what does the second element means?
1283+ file_name = about_object .location .partition (self .location )[2 ]
1284+ # FIXME: a path starting with / is NOT relative
1285+ about_relative_path = '/' + file_name
1286+ """if limit_to:
1287+ try:
1288+ not_process_components.remove(about_relative_path)
1289+ except Exception as e:
1290+ continue"""
1291+
1292+ #if limit_to and about_relative_path in limit_to:
1293+ # continue
1294+ if component == about_relative_path :
1295+ component_exist = True
1296+ about_content = about_object .validated_fields
1297+ # Add information in the dictionary if not in the ABOUT file
1298+ lic_text = unicode (about_object .license_text (),
13061299 errors = 'replace' )
1300+
13071301 about_content ['license_text' ] = lic_text
1308-
1309- # report error if no license_text is found
1310- if not about_content .get ('license_text' ):
1311- msg = ('No license_text found. '
1312- 'Skipping License generation.' )
1313- err = Error (GENATTRIB , 'name' ,
1314- about_object .get_about_name (), msg )
1302+ notice_text = about_object .notice_text ()
1303+ about_content ['notice_text' ] = notice_text
1304+
1305+ # FIXME: The following is temporary code to handle multiple
1306+ # license_text_file paths in the field value, one per lne
1307+ for k in about_content :
1308+ if ('\n ' in about_content [k ]
1309+ and k == 'license_text_file' ):
1310+ # FIXME: we should report decoding errors
1311+ lic_text = unicode (about_object .tmp_get_license_text (),
1312+ errors = 'replace' )
1313+ about_content ['license_text' ] = lic_text
1314+
1315+ # report error if no license_text is found
1316+ if not about_content .get ('license_text' ):
1317+ msg = ('No license_text found. '
1318+ 'Skipping License generation.' )
1319+ err = Error (GENATTRIB , 'name' ,
1320+ about_object .get_about_name (), msg )
1321+ self .genattrib_errors .append (err )
1322+ about_object_fields .append (about_content )
1323+ break
1324+ if not component_exist :
1325+ msg = ('The requested ABOUT file: %r does not exist. '
1326+ 'No attribution generated for this file.' % component )
1327+ err = Error (GENATTRIB , 'about_file' , component , msg )
13151328 self .genattrib_errors .append (err )
13161329
1317- about_object_fields .append (about_content )
1318-
1319- # find paths requested in the limit_to paths arg that do not point to
1330+ """# find paths requested in the limit_to paths arg that do not point to
13201331 # a corresponding ABOUT file
13211332 for path in not_process_components:
13221333 path = posix_path(path)
13231334 afp = join(self.location, path)
13241335 msg = ('The requested ABOUT file: %(afp)r does not exist. '
13251336 'No attribution generated for this file.' % locals())
13261337 err = Error(GENATTRIB, 'about_file', path, msg)
1327- self .genattrib_errors .append (err )
1338+ self.genattrib_errors.append(err)"""
13281339
13291340 # TODO: Handle the grouping and ordering later
13301341 """# We want to display common_licenses in alphabetical order
0 commit comments