Skip to content

Commit c427e01

Browse files
Fix test failures and address feedback
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 6d93bba commit c427e01

24 files changed

+167
-48
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
license_expression: cclrc
3+
is_license_notice: yes
4+
referenced_filenames:
5+
- External_License/CCLRC_CDAT_License.txt
6+
---
7+
8+
* This software may be distributed under the terms of the
9+
* {{CCLRC Licence}} for CCLRC Software
10+
* <CDATDIR>/External_License/CCLRC_CDAT_License.txt
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
license_expression: cclrc
3+
is_license_notice: yes
4+
---
5+
6+
* This software may be distributed under the terms of the
7+
* {{CCLRC Licence}} for CCLRC Software

src/licensedcode/data/rules/mit_1182.RULE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
license_expression: mit
33
is_license_reference: yes
4+
is_required_phrase: yes
45
relevance: 100
56
---
67

src/licensedcode/data/rules/mit_334.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ referenced_filenames:
66
- LICENSE
77
---
88

9-
This software is released under the MIT software license.
9+
This software is released under the {{MIT software license}}.
1010
This license, including disclaimer, is available in the 'LICENSE' file.

src/licensedcode/data/rules/mit_337.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ignorable_urls:
66
- http://www.opensource.org/licenses/mit-license.php
77
---
88

9-
This is the http://www.opensource.org/licenses/mit-license.php MIT Software License
9+
This is the http://www.opensource.org/licenses/mit-license.php {{MIT Software License}}
1010
which is OSI-certified, and GPL-compatible.

src/licensedcode/data/rules/mit_392.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ ignorable_urls:
88
- http://www.opensource.org/licenses/mit-license.php
99
---
1010

11-
"Distributed under the MIT software license, see the accompanying file COPYING or
11+
"Distributed under the {{MIT software license}}, see the accompanying file COPYING or
1212
http://www.opensource.org/licenses/mit-license.php.

src/licensedcode/data/rules/mit_396.RULE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ referenced_filenames:
66
- COPYING
77
---
88

9-
// Distributed under the MIT software license, see the accompanying
9+
// Distributed under the {{MIT software license}}, see the accompanying
1010
// file COPYING

src/licensedcode/data/rules/mit_397.RULE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ relevance: 100
55
referenced_filenames:
66
- COPYING
77
ignorable_urls:
8-
- http://www.opensource.org/licenses/mit-license.php
8+
- https://www.opensource.org/licenses/mit-license.php
99
---
1010

11-
// Distributed under the MIT software license, see the accompanying
12-
// file COPYING or shttp://www.opensource.org/{{licenses/mit}}-license.php.
11+
// Distributed under the {{MIT software license}}, see the accompanying
12+
// file COPYING or https://www.opensource.org/licenses/mit-license.php.

src/licensedcode/models.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,10 +1832,6 @@ def license_flags(self):
18321832
for license_flag_name in self.license_flag_names
18331833
}
18341834

1835-
@property
1836-
def license_flag_values(self):
1837-
return self.license_flags.values()
1838-
18391835
def validate(self, licensing=None, thorough=False):
18401836
"""
18411837
Validate this rule using the provided ``licensing`` Licensing and yield
@@ -1844,8 +1840,7 @@ def validate(self, licensing=None, thorough=False):
18441840
is_false_positive = self.is_false_positive
18451841

18461842
has_license_flags = any(self.license_flag_values)
1847-
has_no_license_flags = len([l for l in self.license_flag_values if l]) == 0
1848-
has_many_license_flags = len([l for l in self.license_flag_values if l]) > 1
1843+
license_flags_count = sum(self.license_flags.values())
18491844

18501845
license_expression = self.license_expression
18511846

@@ -1888,11 +1883,8 @@ def validate(self, licensing=None, thorough=False):
18881883

18891884
if not (0 <= self.relevance <= 100):
18901885
yield 'Invalid rule relevance. Should be between 0 and 100.'
1891-
1892-
if has_no_license_flags:
1893-
yield 'Invalid rule no is_license_* flags present.'
18941886

1895-
if has_many_license_flags:
1887+
if license_flags_count:
18961888
yield 'Invalid rule is_license_* flags. Only one allowed.'
18971889

18981890
if not has_license_flags:
@@ -2295,6 +2287,8 @@ def dump(self, rules_data_dir, **kwargs):
22952287
rule_file = self.rule_file(rules_data_dir=rules_data_dir)
22962288

22972289
metadata = self.to_dict()
2290+
# This can be used to pass objects to dump on the rule file with
2291+
# other rule metadata, like debugging collection of required phrases
22982292
if kwargs:
22992293
metadata.update(kwargs)
23002294
content = self.text
@@ -2328,7 +2322,7 @@ def load(self, rule_file, with_checks=True):
23282322
raise e
23292323

23302324
known_attributes = set(attr.fields_dict(self.__class__))
2331-
# This is an attirbute used to debug marking required phrases, and is not needed
2325+
# This is an attribute used to debug marking required phrases, and is not needed
23322326
if "sources" in data:
23332327
data.pop("sources")
23342328
data_file_attributes = set(data)

src/licensedcode/required_phrases.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ def get_required_phrase_spans(text):
5252
>>> x = get_required_phrase_spans(text)
5353
>>> assert x == [Span(4, 6)], x
5454
55-
>>> text = 'This is enclosed in {{double curly braces}}'
56-
>>> # 0 1 2 3 4 5 6
57-
>>> x = get_required_phrase_spans(text)
58-
>>> assert x == ['double', 'curly', 'braces'], x
59-
6055
>>> text = 'This is {{enclosed}} a {{double curly braces}} or not'
6156
>>> # 0 1 2 SW 3 4 5 6 7
6257
>>> x = get_required_phrase_spans(text)
@@ -114,7 +109,7 @@ def get_required_phrase_texts(text):
114109
>>> text = 'This is enclosed in {{double curly braces}}'
115110
>>> # 0 1 2 3 4 5 6
116111
>>> x = get_required_phrase_texts(text=text)
117-
>>> assert x == ['double', 'curly', 'braces'], x
112+
>>> assert x == ['double curly braces'], x
118113
"""
119114
return [
120115
required_phrase.text

0 commit comments

Comments
 (0)