|
46 | 46 | import ntpath |
47 | 47 |
|
48 | 48 |
|
49 | | -__version__ = '1.0.1' |
| 49 | +__version__ = '1.0.2' |
50 | 50 |
|
51 | 51 | # See http://dejacode.org |
52 | 52 | __about_spec_version__ = '1.0' |
@@ -1270,49 +1270,81 @@ def generate_attribution(self, template_path=None, limit_to=None): |
1270 | 1270 | not_process_components = list(limit_to) |
1271 | 1271 | component_exist = False |
1272 | 1272 |
|
1273 | | - for component in not_process_components: |
| 1273 | + # Following code contains duplication and perhaps needs to do some |
| 1274 | + # refactoring |
| 1275 | + if limit_to: |
| 1276 | + for component in not_process_components: |
| 1277 | + for about_object in self: |
| 1278 | + # The about_object.location is the absolute path of the ABOUT |
| 1279 | + # file. The purpose of the following partition is to match |
| 1280 | + # the about_file's location with the input list. |
| 1281 | + about_relative_path = about_object.location.partition( |
| 1282 | + normpath(self.location))[2] |
| 1283 | + if component == about_relative_path: |
| 1284 | + component_exist = True |
| 1285 | + about_content = about_object.validated_fields |
| 1286 | + if '\n' in about_object.get_dje_license_name(): |
| 1287 | + msg = ('Multiple licenses is not supported. ' |
| 1288 | + 'Skipping License generation.') |
| 1289 | + err = Error(GENATTRIB, 'dje_license', |
| 1290 | + about_object.get_dje_license_name(), msg) |
| 1291 | + self.genattrib_errors.append(err) |
| 1292 | + |
| 1293 | + lic_text = unicode(about_object.license_text(), |
| 1294 | + errors='replace') |
| 1295 | + notice_text = unicode(about_object.notice_text(), |
| 1296 | + errors='replace') |
| 1297 | + about_content['license_text'] = lic_text |
| 1298 | + about_content['notice_text'] = notice_text |
| 1299 | + |
| 1300 | + license_dict[about_object.get_dje_license_name()] = about_content['license_text'] |
| 1301 | + |
| 1302 | + # report error if no license_text is found |
| 1303 | + if not about_content.get('license_text')\ |
| 1304 | + and not about_content.get('notice_text')\ |
| 1305 | + and not '\n' in about_object.get_dje_license_name(): |
| 1306 | + msg = ('No license_text found. ' |
| 1307 | + 'Skipping License generation.') |
| 1308 | + err = Error(GENATTRIB, 'name', |
| 1309 | + about_object.get_about_name(), msg) |
| 1310 | + self.genattrib_errors.append(err) |
| 1311 | + about_object_fields.append(about_content) |
| 1312 | + break |
| 1313 | + if not component_exist: |
| 1314 | + loc = self.location + component |
| 1315 | + msg = ('The requested ABOUT file: %r does not exist. ' |
| 1316 | + 'No attribution generated for this file.' % loc) |
| 1317 | + err = Error(GENATTRIB, 'about_file', loc, msg) |
| 1318 | + self.genattrib_errors.append(err) |
| 1319 | + else: |
1274 | 1320 | for about_object in self: |
1275 | | - # The about_object.location is the absolute path of the ABOUT |
1276 | | - # file. The purpose of the following partition is to match |
1277 | | - # the about_file's location with the input list. |
1278 | | - about_relative_path = about_object.location.partition( |
1279 | | - normpath(self.location))[2] |
1280 | | - |
1281 | | - if component == about_relative_path: |
1282 | | - component_exist = True |
1283 | | - about_content = about_object.validated_fields |
1284 | | - if '\n' in about_object.get_dje_license_name(): |
1285 | | - msg = ('Multiple licenses is not supported. ' |
1286 | | - 'Skipping License generation.') |
1287 | | - err = Error(GENATTRIB, 'dje_license', |
1288 | | - about_object.get_dje_license_name(), msg) |
1289 | | - self.genattrib_errors.append(err) |
1290 | | - |
1291 | | - lic_text = unicode(about_object.license_text(), |
1292 | | - errors='replace') |
1293 | | - notice_text = unicode(about_object.notice_text(), |
1294 | | - errors='replace') |
1295 | | - about_content['license_text'] = lic_text |
1296 | | - about_content['notice_text'] = notice_text |
1297 | | - |
1298 | | - license_dict[about_object.get_dje_license_name()] = about_content['license_text'] |
1299 | | - |
1300 | | - # report error if no license_text is found |
1301 | | - if not about_content.get('license_text')\ |
1302 | | - and not about_content.get('notice_text')\ |
1303 | | - and not '\n' in about_object.get_dje_license_name(): |
1304 | | - msg = ('No license_text found. ' |
1305 | | - 'Skipping License generation.') |
1306 | | - err = Error(GENATTRIB, 'name', |
1307 | | - about_object.get_about_name(), msg) |
1308 | | - self.genattrib_errors.append(err) |
1309 | | - about_object_fields.append(about_content) |
1310 | | - break |
1311 | | - if not component_exist: |
1312 | | - msg = ('The requested ABOUT file: %r does not exist. ' |
1313 | | - 'No attribution generated for this file.' % component) |
1314 | | - err = Error(GENATTRIB, 'about_file', component, msg) |
1315 | | - self.genattrib_errors.append(err) |
| 1321 | + about_content = about_object.validated_fields |
| 1322 | + if '\n' in about_object.get_dje_license_name(): |
| 1323 | + msg = ('Multiple licenses is not supported. ' |
| 1324 | + 'Skipping License generation.') |
| 1325 | + err = Error(GENATTRIB, 'dje_license', |
| 1326 | + about_object.get_dje_license_name(), msg) |
| 1327 | + self.genattrib_errors.append(err) |
| 1328 | + |
| 1329 | + lic_text = unicode(about_object.license_text(), |
| 1330 | + errors='replace') |
| 1331 | + notice_text = unicode(about_object.notice_text(), |
| 1332 | + errors='replace') |
| 1333 | + about_content['license_text'] = lic_text |
| 1334 | + about_content['notice_text'] = notice_text |
| 1335 | + |
| 1336 | + license_dict[about_object.get_dje_license_name()] = about_content['license_text'] |
| 1337 | + |
| 1338 | + # report error if no license_text is found |
| 1339 | + if not about_content.get('license_text')\ |
| 1340 | + and not about_content.get('notice_text')\ |
| 1341 | + and not '\n' in about_object.get_dje_license_name(): |
| 1342 | + msg = ('No license_text found. ' |
| 1343 | + 'Skipping License generation.') |
| 1344 | + err = Error(GENATTRIB, 'name', |
| 1345 | + about_object.get_about_name(), msg) |
| 1346 | + self.genattrib_errors.append(err) |
| 1347 | + about_object_fields.append(about_content) |
1316 | 1348 |
|
1317 | 1349 | # We want to display common_licenses in alphabetical order |
1318 | 1350 | license_key = [] |
|
0 commit comments