Skip to content

Commit df76984

Browse files
Add ignored_resources attribute in ABOUT file
Reference: #527 Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent e9d0af3 commit df76984

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/attributecode/model.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,22 @@ def _validate(self, *args, **kwargs):
558558
return errors
559559

560560

561+
class IgnoredResourcesField(PathField):
562+
"""
563+
Special field for ignored_resources. self.ignored_paths contains a list of
564+
path patterns (glob patterns) which are not part of the summarization provided
565+
by the ABOUT file.
566+
"""
567+
568+
def __init__(self, *args, ** kwargs):
569+
super(AboutResourceField, self).__init__(*args, ** kwargs)
570+
self.resolved_paths = []
571+
572+
def _validate(self, *args, **kwargs):
573+
errors = super(AboutResourceField, self)._validate(*args, ** kwargs)
574+
return errors
575+
576+
561577
class FileTextField(PathField):
562578
"""
563579
A path field pointing to one or more text files such as license files.
@@ -764,6 +780,7 @@ def set_standard_fields(self):
764780
"""
765781
self.fields = dict([
766782
('about_resource', AboutResourceField(required=True)),
783+
('ignored_resources', AboutResourceField()),
767784
('name', SingleLineField(required=True)),
768785
('version', SingleLineField()),
769786

tests/test_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,17 @@ def test_About_with_existing_about_resource_has_no_error(self):
456456
# this means we have a location
457457
self.assertNotEqual([], result)
458458

459+
def test_About_loads_ignored_resources_field(self):
460+
# fields in this file are not in the standard order
461+
test_file = get_test_loc('test_model/parse/with_ignored_resources.ABOUT')
462+
a = model.About(test_file)
463+
#assert [] == a.errors
464+
465+
expected = ['about_resource', 'ignored_resources', 'name']
466+
result = [f.name for f in a.all_fields() if f.present]
467+
assert expected == result
468+
469+
459470
def test_About_has_errors_when_about_resource_is_missing(self):
460471
test_file = get_test_loc('test_gen/parser_tests/.ABOUT')
461472
a = model.About(test_file)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: elasticsearch-sidecar
2+
about_resource: elasticsearch-sidecar
3+
ignored_resources:
4+
- elasticsearch-sidecar/plugins/
5+
- elasticsearch-sidecar/logs/

0 commit comments

Comments
 (0)