66import argparse
77import glob
88import os
9- from typing import List , Tuple
9+ from typing import List
1010
1111import dfetch .commands .command
1212import dfetch .manifest .manifest
1616from dfetch .project .metadata import Metadata
1717from dfetch .project .vcs import VCS
1818from dfetch .reporting import REPORTERS , ReportTypes
19- from dfetch .util .license import guess_license_in_file
19+ from dfetch .util .license import License , guess_license_in_file
2020
2121logger = get_logger (__name__ )
2222
@@ -71,14 +71,14 @@ def __call__(self, args: argparse.Namespace) -> None:
7171 determined_licenses = self ._determine_licenses (project )
7272 version = self ._determine_version (project )
7373 reporter .add_project (
74- project = project , license_names = determined_licenses , version = version
74+ project = project , licenses = determined_licenses , version = version
7575 )
7676
7777 if reporter .dump_to_file (args .outfile ):
7878 logger .info (f"Generated { reporter .name } report: { args .outfile } " )
7979
8080 @staticmethod
81- def _determine_licenses (project : ProjectEntry ) -> List [Tuple [ str , float ] ]:
81+ def _determine_licenses (project : ProjectEntry ) -> List [License ]:
8282 """Try to determine license of fetched project."""
8383 if not os .path .exists (project .destination ):
8484 logger .print_warning_line (
@@ -91,10 +91,13 @@ def _determine_licenses(project: ProjectEntry) -> List[Tuple[str, float]]:
9191
9292 for license_file in filter (VCS .is_license_file , glob .glob ("*" )):
9393 logger .debug (f"Found license file { license_file } for { project .name } " )
94- guessed_license , probability = guess_license_in_file (license_file )
94+ guessed_license = guess_license_in_file (license_file )
9595
96- if guessed_license :
97- license_files .append ((str (guessed_license .name ), probability ))
96+ if (
97+ guessed_license
98+ and guessed_license .probability > LICENSE_PROBABILITY_THRESHOLD
99+ ):
100+ license_files .append (guessed_license )
98101 else :
99102 logger .print_warning_line (
100103 project .name , f"Could not determine license in { license_file } "
0 commit comments