@@ -55,7 +55,7 @@ class AutotoolsConfigureHandler(models.DatafileHandler):
5555 documentation_url = 'https://www.gnu.org/software/automake/'
5656
5757 @classmethod
58- def parse (cls , location ):
58+ def parse (cls , location , package_only = False ):
5959 # we use the parent directory as a package name
6060 name = fileutils .file_name (fileutils .parent_directory (location ))
6161 # we could use checksums as version in the future
@@ -67,12 +67,13 @@ def parse(cls, location):
6767 # there are dependencies we could use
6868 # dependencies = []
6969
70- yield models . PackageData (
70+ package_data = dict (
7171 datasource_id = cls .datasource_id ,
7272 type = cls .default_package_type ,
7373 name = name ,
7474 version = version ,
7575 )
76+ yield models .PackageData .from_data (package_data , package_only )
7677
7778 @classmethod
7879 def assign_package_to_resources (cls , package , resource , codebase , package_adder ):
@@ -112,6 +113,7 @@ def assemble(cls, package_data, resource, codebase, package_adder):
112113 package = models .Package .from_package_data (
113114 package_data = package_data ,
114115 datafile_path = resource .path ,
116+ package_only = True ,
115117 )
116118
117119 if TRACE :
@@ -143,8 +145,7 @@ def assemble(cls, package_data, resource, codebase, package_adder):
143145 yield resource
144146
145147 @classmethod
146- def parse (cls , location ):
147-
148+ def parse (cls , location , package_only = False ):
148149 # Thanks to Starlark being a Python dialect, we can use `ast` to parse it
149150 with open (location , 'rb' ) as f :
150151 tree = ast .parse (f .read ())
@@ -196,23 +197,28 @@ def parse(cls, location):
196197 if TRACE :
197198 logger_debug (f"build: parse: license_files: { license_files } " )
198199
199- package_data = models . PackageData (
200+ package_data = dict (
200201 datasource_id = cls .datasource_id ,
201202 type = cls .default_package_type ,
202203 name = name ,
204+ extracted_license_statement = license_files ,
205+ )
206+ # `package_only` is True as we do the license detection
207+ # on assembly
208+ yield models .PackageData .from_data (
209+ package_data = package_data ,
210+ package_only = True ,
203211 )
204-
205- package_data .extracted_license_statement = license_files
206- yield package_data
207212
208213 else :
209214 # If we don't find anything in the pkgdata file, we yield a Package
210215 # with the parent directory as the name
211- yield models . PackageData (
216+ package_data = dict (
212217 datasource_id = cls .datasource_id ,
213218 type = cls .default_package_type ,
214219 name = fileutils .file_name (fileutils .parent_directory (location ))
215220 )
221+ yield models .PackageData .from_data (package_data , package_only )
216222
217223 @classmethod
218224 def assign_package_to_resources (cls , package , resource , codebase , package_adder , skip_name = None ):
@@ -334,7 +340,7 @@ class BuckMetadataBzlHandler(BaseStarlarkManifestHandler):
334340 documentation_url = 'https://buck.build/'
335341
336342 @classmethod
337- def parse (cls , location ):
343+ def parse (cls , location , package_only = True ):
338344
339345 with open (location , 'rb' ) as f :
340346 tree = ast .parse (f .read ())
@@ -386,7 +392,7 @@ def parse(cls, location):
386392 ):
387393 # TODO: Create function that determines package type from download URL,
388394 # then create a package of that package type from the metadata info
389- yield models . PackageData (
395+ package_data = dict (
390396 datasource_id = cls .datasource_id ,
391397 type = metadata_fields .get ('upstream_type' , cls .default_package_type ),
392398 name = metadata_fields .get ('name' ),
@@ -396,6 +402,7 @@ def parse(cls, location):
396402 homepage_url = metadata_fields .get ('upstream_address' , '' ),
397403 # TODO: Store 'upstream_hash` somewhere
398404 )
405+ yield models .PackageData .from_data (package_data , package_only = True )
399406
400407 if (
401408 'package_type'
@@ -409,7 +416,7 @@ def parse(cls, location):
409416 and 'vcs_commit_hash'
410417 in metadata_fields
411418 ):
412- yield models . PackageData (
419+ package_data = dict (
413420 datasource_id = cls .datasource_id ,
414421 type = metadata_fields .get ('package_type' , cls .default_package_type ),
415422 name = metadata_fields .get ('name' ),
@@ -422,6 +429,7 @@ def parse(cls, location):
422429 sha1 = metadata_fields .get ('download_archive_sha1' , '' ),
423430 extra_data = dict (vcs_commit_hash = metadata_fields .get ('vcs_commit_hash' , '' ))
424431 )
432+ yield models .PackageData .from_data (package_data , package_only = True )
425433
426434 @classmethod
427435 def assign_package_to_resources (cls , package , resource , codebase , package_adder ):
0 commit comments