@@ -1189,7 +1189,12 @@ def get_license_tokens():
11891189 yield 'licensed'
11901190
11911191
1192- def load_rules (rules_data_dir = rules_data_dir , with_checks = True , is_builtin = True ):
1192+ def load_rules (
1193+ rules_data_dir = rules_data_dir ,
1194+ with_checks = True ,
1195+ is_builtin = True ,
1196+ ignore_deprecated = True ,
1197+ ):
11931198 """
11941199 Return an iterable of rules loaded from rule files in ``rules_data_dir``.
11951200 Optionally check for consistency if ``with_checks`` is True.
@@ -1211,7 +1216,12 @@ def load_rules(rules_data_dir=rules_data_dir, with_checks=True, is_builtin=True)
12111216 space_problems .append (rule_file )
12121217
12131218 try :
1214- yield Rule .from_file (rule_file = rule_file )
1219+ rule = Rule .from_file (rule_file = rule_file )
1220+ if rule .is_deprecated and ignore_deprecated :
1221+ continue
1222+ else :
1223+ yield rule
1224+
12151225 except Exception as re :
12161226 if with_checks :
12171227 model_errors .append (str (re ))
@@ -1387,6 +1397,22 @@ class BasicRule:
13871397 'after. Mutually exclusive from any other is_license_* flag' )
13881398 )
13891399
1400+ is_license_clue = attr .ib (
1401+ default = False ,
1402+ repr = False ,
1403+ metadata = dict (
1404+ help = 'True if this is rule text is a clue to a license '
1405+ 'but cannot be considered in a proper license detection '
1406+ 'as a license text/notice/reference/tag/intro as it is'
1407+ 'merely a clue and does not actually point to or refer to '
1408+ 'the actual license directly. This is still valuable information '
1409+ 'useful in determining the license/origin of a file, but this '
1410+ 'should not be summarized/present in the license expression for '
1411+ 'a package or a file, nor its list of license detections. '
1412+ 'considered in the context of the detection that it precedes. '
1413+ 'Mutually exclusive from any other is_license_* flag' )
1414+ )
1415+
13901416 is_false_positive = attr .ib (
13911417 default = False ,
13921418 repr = False ,
@@ -1505,6 +1531,19 @@ class BasicRule:
15051531 'built at runtime, such as an SPDX license rule.' )
15061532 )
15071533
1534+ is_deprecated = attr .ib (
1535+ default = False ,
1536+ repr = False ,
1537+ metadata = dict (
1538+ help = 'Flag set to True if this rule is deleted, '
1539+ 'and not to be used anymore in license detection. '
1540+ 'This happens usually when a rule is renamed/assigned '
1541+ 'to a seperate license-expression, promoted to being a '
1542+ 'license text or just plain retired. This is used to '
1543+ 'preserve the link to the rule, and therefore make links '
1544+ 'to rules as permanent.' )
1545+ )
1546+
15081547 ###########################################################################
15091548 # lists of clues that can be ignored when detected in this license as they
15101549 # are part of the license or rule text itself
@@ -1769,6 +1808,7 @@ def validate(self, licensing=None, thorough=False):
17691808 self .is_license_reference ,
17701809 self .is_license_tag ,
17711810 self .is_license_intro ,
1811+ self .is_license_clue ,
17721812 )
17731813
17741814 has_license_flags = any (license_flags )
@@ -1924,6 +1964,7 @@ def to_reference(self):
19241964 data ['is_license_reference' ] = self .is_license_reference
19251965 data ['is_license_tag' ] = self .is_license_tag
19261966 data ['is_license_intro' ] = self .is_license_intro
1967+ data ['is_license_clue' ] = self .is_license_clue
19271968 data ['is_continuous' ] = self .is_continuous
19281969 data ['is_builtin' ] = self .is_builtin
19291970 data ['is_from_license' ] = self .is_from_license
@@ -1961,6 +2002,7 @@ def to_dict(self, include_text=False):
19612002 'is_license_reference' ,
19622003 'is_license_tag' ,
19632004 'is_license_intro' ,
2005+ 'is_license_clue' ,
19642006 'is_continuous' ,
19652007 )
19662008
@@ -2253,7 +2295,9 @@ def load(self, rule_file, with_checks=True):
22532295 self .is_license_tag = data .get ('is_license_tag' , False )
22542296 self .is_license_reference = data .get ('is_license_reference' , False )
22552297 self .is_license_intro = data .get ('is_license_intro' , False )
2298+ self .is_license_clue = data .get ('is_license_clue' , False )
22562299 self .is_continuous = data .get ('is_continuous' , False )
2300+ self .is_deprecated = data .get ('is_deprecated' , False )
22572301
22582302 self .referenced_filenames = data .get ('referenced_filenames' , []) or []
22592303
0 commit comments