|
43 | 43 | import sys |
44 | 44 | import urlparse |
45 | 45 | import logging |
| 46 | + |
46 | 47 | from collections import namedtuple |
47 | 48 | from datetime import datetime |
48 | 49 | from email.parser import HeaderParser |
@@ -969,6 +970,8 @@ class AboutCollector(object): |
969 | 970 | Summarize all the issues from each instance. |
970 | 971 | """ |
971 | 972 | def __init__(self, input_path): |
| 973 | + if isdir(input_path) and not input_path.endswith('/'): |
| 974 | + input_path = input_path + '/' |
972 | 975 | self.user_provided_path = input_path |
973 | 976 | self.absolute_path = abspath(input_path) |
974 | 977 | assert exists(self.absolute_path) |
@@ -1105,10 +1108,18 @@ def generate_attribution(self, template_path='templates/default.html', |
1105 | 1108 | license_key = [] |
1106 | 1109 | license_text = [] |
1107 | 1110 | license_dict = {} |
1108 | | - #common_license = ['GNU General Public License 2.0','OpenSSL/SSLeay License', 'Apache License 2.0', 'BSD-Modified'] |
| 1111 | + not_exist_components = list(limit_to) |
1109 | 1112 |
|
1110 | 1113 | for about_object in self: |
1111 | 1114 | about_relative_path = '/'+ about_object.location.partition(self.user_provided_path)[2] |
| 1115 | + # Check is there any components in the 'limit_to' list that |
| 1116 | + # does not exist in the code base. |
| 1117 | + if limit_to: |
| 1118 | + try: |
| 1119 | + not_exist_components.remove(about_relative_path) |
| 1120 | + except Exception as e: |
| 1121 | + continue |
| 1122 | + |
1112 | 1123 | if not limit_to or about_relative_path in limit_to: |
1113 | 1124 | validated_fields.append(about_object.validated_fields) |
1114 | 1125 | notice_text.append(about_object.notice_text()) |
@@ -1142,6 +1153,14 @@ def generate_attribution(self, template_path='templates/default.html', |
1142 | 1153 | about_object.about_resource,\ |
1143 | 1154 | msg)) |
1144 | 1155 |
|
| 1156 | + if not_exist_components: |
| 1157 | + for component in not_exist_components: |
| 1158 | + msg = 'about file: %s - file does not exist. '\ |
| 1159 | + 'No attribution is generated for this component.'\ |
| 1160 | + % (self.user_provided_path + component).replace('//', '/') |
| 1161 | + self.genattrib_errors.append(Error(GENATTRIB, 'about_file',\ |
| 1162 | + component, msg)) |
| 1163 | + |
1145 | 1164 | # We want the license generation in alphabetical order |
1146 | 1165 | for key in sorted(license_dict.keys()): |
1147 | 1166 | license_key.append(key) |
|
0 commit comments