|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # -*- coding: utf8 -*- |
3 | 3 | # ============================================================================ |
4 | | -# Copyright (c) 2013-2019 nexB Inc. http://www.nexb.com/ - All rights reserved. |
| 4 | +# Copyright (c) 2013-2020 nexB Inc. http://www.nexb.com/ - All rights reserved. |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | # you may not use this file except in compliance with the License. |
7 | 7 | # You may obtain a copy of the License at |
@@ -677,7 +677,7 @@ def validate_fields(fields, about_file_path, running_inventory, base_dir, |
677 | 677 | def validate_field_name(name): |
678 | 678 | if not is_valid_name(name): |
679 | 679 | msg = ('Field name: %(name)r contains illegal name characters: ' |
680 | | - '0 to 9, a to z, A to Z and _.') |
| 680 | + '0 to 9, a to z, A to Z and _. (or empty spaces)') |
681 | 681 | return Error(CRITICAL, msg % locals()) |
682 | 682 |
|
683 | 683 |
|
@@ -1095,6 +1095,53 @@ def dump(self, location): |
1095 | 1095 | dumped.write(genereated_tk_version) |
1096 | 1096 | dumped.write(self.dumps()) |
1097 | 1097 |
|
| 1098 | + def dump_android_notice(self, path, context): |
| 1099 | + """ |
| 1100 | + Write the NOITCE file consist of copyright, notice and license |
| 1101 | + """ |
| 1102 | + if on_windows: |
| 1103 | + path = add_unc(path) |
| 1104 | + |
| 1105 | + with io.open(path, mode='w', encoding='utf-8') as dumped: |
| 1106 | + dumped.write(context) |
| 1107 | + |
| 1108 | + def android_module_license(self, about_parent_path): |
| 1109 | + """ |
| 1110 | + Create MODULE_LICENSE_XXX which the XXX is the value of license key. |
| 1111 | + """ |
| 1112 | + for lic_key in self.license_key.value: |
| 1113 | + # Make uppercase and with dash and spaces and dots replaced by underscore |
| 1114 | + # just to look similar and consistent. |
| 1115 | + name = 'MODULE_LICENSE_' + lic_key.replace('.', '_').replace('-', '_').replace(' ', '_').upper() |
| 1116 | + module_lic_path = os.path.join(about_parent_path, name) |
| 1117 | + # Create an empty MODULE_LICESE_XXX file |
| 1118 | + open(module_lic_path, 'a').close() |
| 1119 | + |
| 1120 | + def android_notice(self, about_parent_path): |
| 1121 | + """ |
| 1122 | + Return a notice dictionary which the path of the notice file going |
| 1123 | + to create will be the key and its context will be the value of the dict. |
| 1124 | + """ |
| 1125 | + # Create NOTICE file with the combination context of copyright, |
| 1126 | + # notice_file and license_file |
| 1127 | + notice_path = posixpath.join(about_parent_path, 'NOTICE') |
| 1128 | + notice_context = '' |
| 1129 | + if self.copyright.value: |
| 1130 | + notice_context += self.copyright.value |
| 1131 | + if self.notice_file.value: |
| 1132 | + notice_file_dict = self.notice_file.value |
| 1133 | + notice_file_key = notice_file_dict.keys() |
| 1134 | + for key in notice_file_key: |
| 1135 | + if notice_file_dict[key]: |
| 1136 | + notice_context += '\n' + notice_file_dict[key] + '\n' |
| 1137 | + if self.license_file.value: |
| 1138 | + lic_file_dict = self.license_file.value |
| 1139 | + lic_file_key = lic_file_dict.keys() |
| 1140 | + for key in lic_file_key: |
| 1141 | + if lic_file_dict[key]: |
| 1142 | + notice_context += '\n\n' + lic_file_dict[key] + '\n\n' |
| 1143 | + return notice_path, notice_context |
| 1144 | + |
1098 | 1145 | def dump_lic(self, location, license_dict): |
1099 | 1146 | """ |
1100 | 1147 | Write LICENSE files and return the a list of key, name, context and the url |
|
0 commit comments