@@ -1055,7 +1055,7 @@ def duplicate_file_names_when_lowercased(file_location):
10551055 names .append (name )
10561056 return names
10571057
1058- def tmp_get_license_text (self ):
1058+ """ def tmp_get_license_text(self):
10591059 # TODO: This is a temp fix for handling multiple 'license_text_file'
10601060 # The code should get the license text from the def license_text(self),
10611061 # not this function.
@@ -1067,7 +1067,7 @@ def tmp_get_license_text(self):
10671067 with open(location, 'rU') as f:
10681068 license_text += f.read()
10691069 license_text += '\n \n \n \n \n \n '
1070- return license_text
1070+ return license_text"""
10711071
10721072 def license_text (self ):
10731073 """
@@ -1181,7 +1181,6 @@ def collect(location):
11811181 paths = [posix_path (p )for p in paths ]
11821182 return paths
11831183
1184-
11851184 @property
11861185 def errors (self ):
11871186 """
@@ -1232,28 +1231,6 @@ def get_relative_path(self, location):
12321231 else :
12331232 return user_loc .replace ('\\ ' , '/' )
12341233
1235- def get_relative_path2 (self , about_object_location ):
1236- """
1237- Return a relative path as provided by the user for an about_object.
1238-
1239- TODO: For some reasons, the join(input_path, subpath) does not work if
1240- the input_path startswith "../". Therefore, using the
1241- "hardcode" to add/append the path.
1242- """
1243- # FIXME: we should use correct path manipulation, not our own cooking
1244- # this is too complex
1245- user_provided_path = self .location
1246- if os .path .isdir (self .absolute_path ):
1247- subpath = about_object_location .partition (
1248- os .path .basename (os .path .normpath (user_provided_path )))[2 ]
1249- if user_provided_path [- 1 ] == '/' :
1250- user_provided_path = user_provided_path .rpartition ('/' )[0 ]
1251- if user_provided_path [- 1 ] == '\\ ' :
1252- user_provided_path = user_provided_path .rpartition ('\\ ' )[0 ]
1253- return (user_provided_path + subpath ).replace ('\\ ' , '/' )
1254- else :
1255- return user_provided_path .replace ('\\ ' , '/' )
1256-
12571234 def custom_keys (self ):
12581235 custom_keys = []
12591236 for about_object in self :
@@ -1321,15 +1298,6 @@ def generate_attribution(self, template_path=None, limit_to=None):
13211298 not_process_components = list (limit_to )
13221299 component_exist = False
13231300
1324- """
1325- # ToDo: temp fix to have correct order in the attribution generation based on
1326- # the input
1327- # Many of the following code were written as the criteria to have user
1328- # generate ALL the attribution output without providing the component list.
1329- # However, the component_list is requried at this stage in the genattrib.py.
1330- # Therefore, these code are commented out for later use.
1331- """
1332- #if not_process_components:
13331301 for component in not_process_components :
13341302 for about_object in self :
13351303 # The about_object.location is the absolute path of the ABOUT
@@ -1338,44 +1306,29 @@ def generate_attribution(self, template_path=None, limit_to=None):
13381306 about_relative_path = about_object .location .partition (
13391307 normpath (self .location ))[2 ]
13401308
1341- """if limit_to:
1342- try:
1343- not_process_components.remove(about_relative_path)
1344- except Exception as e:
1345- continue"""
1346-
1347- #if limit_to and about_relative_path in limit_to:
1348- # continue
13491309 if component == about_relative_path :
13501310 component_exist = True
13511311 about_content = about_object .validated_fields
1352- licenses = about_object .get_dje_license_name ()
1353- if '\n ' in licenses :
1354- lic_text = unicode (about_object .tmp_get_license_text (),
1355- errors = 'replace' )
1356- else :
1357- # Add information in the dictionary if not in the ABOUT file
1358- lic_text = unicode (about_object .license_text (),
1359- errors = 'replace' )
1360- """
1361- # FIXME: The following is temporary code to handle multiple
1362- # license_text_file paths in the field value, one per line
1363- for k in about_content:
1364- if ('\n ' in about_content[k]
1365- and k == 'license_text_file'):
1366- # FIXME: we should report decoding errors
1367- lic_text = unicode(about_object.tmp_get_license_text(),
1368- errors='replace')
1369- """
1312+ if '\n ' in about_object .get_dje_license_name ():
1313+ msg = ('Multiple licenses is not supported. '
1314+ 'Skipping License generation.' )
1315+ err = Error (GENATTRIB , 'dje_license' ,
1316+ about_object .get_dje_license_name (), msg )
1317+ self .genattrib_errors .append (err )
1318+
1319+ lic_text = unicode (about_object .license_text (),
1320+ errors = 'replace' )
13701321 notice_text = unicode (about_object .notice_text (),
1371- errors = 'replace' )
1322+ errors = 'replace' )
13721323 about_content ['license_text' ] = lic_text
13731324 about_content ['notice_text' ] = notice_text
13741325
13751326 license_dict [about_object .get_dje_license_name ()] = about_content ['license_text' ]
13761327
13771328 # report error if no license_text is found
1378- if not about_content .get ('license_text' ) and not about_content .get ('notice_text' ):
1329+ if not about_content .get ('license_text' )\
1330+ and not about_content .get ('notice_text' )\
1331+ and not '\n ' in about_object .get_dje_license_name ():
13791332 msg = ('No license_text found. '
13801333 'Skipping License generation.' )
13811334 err = Error (GENATTRIB , 'name' ,
@@ -1389,74 +1342,6 @@ def generate_attribution(self, template_path=None, limit_to=None):
13891342 err = Error (GENATTRIB , 'about_file' , component , msg )
13901343 self .genattrib_errors .append (err )
13911344
1392- # This code can be removed.
1393- # This following code was written to support user to generate the
1394- # attribution for ALL of the about files if user does not provide
1395- # the component_list. However, this feature should be developed in
1396- # this next release, not the current release.
1397- """
1398- else:
1399- for about_object in self:
1400- # FIXME: what is the meaning of this partition?
1401- # PO created the var some_path to provide some clarity
1402- # but what does the second element means?
1403- file_name = about_object.location.partition(self.location)[2]
1404- # FIXME: a path starting with / is NOT relative
1405- about_relative_path = '/' + file_name
1406-
1407-
1408- if limit_to:
1409- try:
1410- not_process_components.remove(about_relative_path)
1411- except Exception as e:
1412- continue
1413-
1414- about_content = about_object.validated_fields
1415- licenses = about_object.get_dje_license_name()
1416- if '\n ' in licenses:
1417- lic_text = unicode(about_object.tmp_get_license_text(),
1418- errors='replace')
1419- else:
1420- # Add information in the dictionary if not in the ABOUT file
1421- lic_text = unicode(about_object.license_text(),
1422- errors='replace')
1423-
1424- # FIXME: The following is temporary code to handle multiple
1425- # license_text_file paths in the field value, one per line
1426- for k in about_content:
1427- if ('\n ' in about_content[k]
1428- and k == 'license_text_file'):
1429- # FIXME: we should report decoding errors
1430- lic_text = unicode(about_object.tmp_get_license_text(),
1431- errors='replace')
1432-
1433- notice_text = unicode(about_object.notice_text(),
1434- errors='replace')
1435- about_content['license_text'] = lic_text
1436- about_content['notice_text'] = notice_text
1437-
1438- license_dict[about_object.get_dje_license_name()] = about_content['license_text']
1439-
1440- # report error if no license_text is found
1441- if not about_content.get('license_text') and not about_content.get('notice_text'):
1442- msg = ('No license_text found. '
1443- 'Skipping License generation.')
1444- err = Error(GENATTRIB, 'name',
1445- about_object.get_about_name(), msg)
1446- self.genattrib_errors.append(err)
1447- about_object_fields.append(about_content)
1448- break"""
1449-
1450- """# find paths requested in the limit_to paths arg that do not point to
1451- # a corresponding ABOUT file
1452- for path in not_process_components:
1453- path = posix_path(path)
1454- afp = join(self.location, path)
1455- msg = ('The requested ABOUT file: %(afp)r does not exist. '
1456- 'No attribution generated for this file.' % locals())
1457- err = Error(GENATTRIB, 'about_file', path, msg)
1458- self.genattrib_errors.append(err)"""
1459-
14601345 # We want to display common_licenses in alphabetical order
14611346 license_key = []
14621347 license_text_list = []
0 commit comments