Skip to content

Commit bae62f0

Browse files
committed
Fixed #88
Log error if any of the ABOUT files in the input does not exist in the codebase for the attribution generation.
1 parent b370492 commit bae62f0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

about_code_tool/about.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import sys
4444
import urlparse
4545
import logging
46+
4647
from collections import namedtuple
4748
from datetime import datetime
4849
from email.parser import HeaderParser
@@ -969,6 +970,8 @@ class AboutCollector(object):
969970
Summarize all the issues from each instance.
970971
"""
971972
def __init__(self, input_path):
973+
if isdir(input_path) and not input_path.endswith('/'):
974+
input_path = input_path + '/'
972975
self.user_provided_path = input_path
973976
self.absolute_path = abspath(input_path)
974977
assert exists(self.absolute_path)
@@ -1105,10 +1108,18 @@ def generate_attribution(self, template_path='templates/default.html',
11051108
license_key = []
11061109
license_text = []
11071110
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)
11091112

11101113
for about_object in self:
11111114
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+
11121123
if not limit_to or about_relative_path in limit_to:
11131124
validated_fields.append(about_object.validated_fields)
11141125
notice_text.append(about_object.notice_text())
@@ -1142,6 +1153,14 @@ def generate_attribution(self, template_path='templates/default.html',
11421153
about_object.about_resource,\
11431154
msg))
11441155

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+
11451164
# We want the license generation in alphabetical order
11461165
for key in sorted(license_dict.keys()):
11471166
license_key.append(key)

about_code_tool/genattrib.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ def main(parser, options, args):
158158
with open(component_subset_path, "rU") as f:
159159
input_dict = csv.DictReader(f)
160160
for row in input_dict:
161+
# Force the path to start with the '/' to do the mapping
162+
# with the project structure
163+
if not row['about_file'].startswith('/'):
164+
row['about_file'] = '/' + row['about_file']
161165
input_list.append(row)
162166
if mapping_config:
163167
mapping_list = genabout.GenAbout().get_mapping_list()

0 commit comments

Comments
 (0)