@@ -116,7 +116,6 @@ def check_about_resource_filename(arp):
116116 return ''
117117
118118
119- # TODO: this should be either the CSV or the ABOUT files but not both???
120119def load_inventory (location , from_attrib = False , base_dir = None , scancode = False , reference_dir = None ):
121120 """
122121 Load the inventory file at `location` for ABOUT and LICENSE files stored in
@@ -152,24 +151,24 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
152151 arp_list = []
153152 errors = []
154153 for component in inventory :
155- arp = component ['about_resource' ]
156- dup_err = check_duplicated_about_resource (arp , arp_list )
157- if dup_err :
158- if not dup_err in errors :
159- errors .append (dup_err )
160- else :
161- arp_list .append (arp )
154+ if not from_attrib :
155+ arp = component ['about_resource' ]
156+ dup_err = check_duplicated_about_resource (arp , arp_list )
157+ if dup_err :
158+ if not dup_err in errors :
159+ errors .append (dup_err )
160+ else :
161+ arp_list .append (arp )
162+
163+ invalid_about_filename = check_about_resource_filename (arp )
164+ if invalid_about_filename and not invalid_about_filename in errors :
165+ errors .append (invalid_about_filename )
162166
163167 newline_in_file_err = check_newline_in_file_field (component )
164168 if newline_in_file_err :
165169 errors .extend (newline_in_file_err )
166-
167- invalid_about_filename = check_about_resource_filename (arp )
168- if invalid_about_filename and not invalid_about_filename in errors :
169- errors .append (invalid_about_filename )
170170 if errors :
171171 return errors , abouts
172-
173172 except Exception as e :
174173 # TODO: why catch ALL Exception
175174 msg = "The essential field 'about_resource' is not found in the <input>"
@@ -183,22 +182,32 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
183182
184183 for f in required_fields :
185184 if f not in fields :
186- msg = "Required field: %(f)r not found in the <input>" % locals ()
187- errors .append (Error (CRITICAL , msg ))
188- return errors , abouts
189- afp = fields .get (model .About .ABOUT_RESOURCE_ATTR )
185+ if from_attrib and f == 'about_resource' :
186+ continue
187+ else :
188+ msg = "Required field: %(f)r not found in the <input>" % locals ()
189+ errors .append (Error (CRITICAL , msg ))
190+ return errors , abouts
191+ # Set about file path to '' if no 'about_resource' is provided from
192+ # the input for `attrib`
193+ if not 'about_resource' in fields :
194+ afp = ''
195+ else :
196+ afp = fields .get (model .About .ABOUT_RESOURCE_ATTR )
190197
198+ """
191199 # FIXME: this should not be a failure condition
192200 if not afp or not afp.strip():
193201 msg = 'Empty column: %(afp)r. Cannot generate .ABOUT file.' % locals()
194202 errors.append(Error(ERROR, msg))
195203 continue
196204 else:
197- afp = util .to_posix (afp )
198- if base_dir :
199- loc = join (base_dir , afp )
200- else :
201- loc = afp
205+ """
206+ afp = util .to_posix (afp )
207+ if base_dir :
208+ loc = join (base_dir , afp )
209+ else :
210+ loc = afp
202211 about = model .About (about_file_path = afp )
203212 about .location = loc
204213
@@ -213,6 +222,11 @@ def load_inventory(location, from_attrib=False, base_dir=None, scancode=False, r
213222 updated_resource_value = basename (resource_path )
214223 fields ['about_resource' ] = updated_resource_value
215224
225+ # Set 'about_resource' to '.' if no 'about_resource' is provided from
226+ # the input for `attrib`
227+ elif not 'about_resource' in fields and from_attrib :
228+ fields ['about_resource' ] = u'.'
229+
216230 ld_errors = about .load_dict (
217231 fields ,
218232 base_dir ,
0 commit comments