Skip to content

Commit

Permalink
support for comments in filter files
Browse files Browse the repository at this point in the history
  • Loading branch information
counterthreatunit committed Oct 26, 2019
1 parent 5a6c389 commit cb4eb20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion aristotle/aristotle.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ def set_metadata_filter(self, metadata_filter):
try:
if os.path.isfile(metadata_filter):
print_debug("Loading metadata_filter file '{}'.".format(metadata_filter))
self.metadata_filter = ""
with open(metadata_filter, 'r') as fh:
self.metadata_filter = fh.read()
for line in fh:
# strip out comments and ignore blank lines
if line.strip().startswith('#') or len(line.strip()) == 0:
continue
self.metadata_filter += line
else:
self.metadata_filter = metadata_filter
except Exception as e:
Expand Down
2 changes: 2 additions & 0 deletions docs/filter_strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ uses the metadata key-value pairs as values in a (concrete)

- Extraneous whitespace, including newlines, *is* allowed in the filter
string.
- If a file containing a Boolean filter string is supplied, lines beginning
with '#' are considered comments and are ignored.

The following keys support the ``>``, ``<``, ``>=``, and ``<=`` operators
in the filter string to specify, respectively, "greater than", "less than",
Expand Down

0 comments on commit cb4eb20

Please sign in to comment.