summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2020-04-27 19:21:41 -0700
committerMichael Dickens <michael.dickens@ettus.com>2020-04-28 17:04:46 -0400
commit63c3e626d163578c71d9d2fc685ca2172742e359 (patch)
tree5dda60b16e18cef27743b62ffe643c21b1ef07f4
parent3641f8f4502aec0a4905e4610bb664e2b6a48907 (diff)
grc: Deduplicate block paths
GRC reads paths from various sources, including the GRC_BLOCKS_PATH environment variable. It can happen that paths appear twice in the list, causing warnings about findings blocks twice. This deduplicates the paths in the config object.
-rw-r--r--grc/core/Config.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/grc/core/Config.py b/grc/core/Config.py
index 0a75ca607e..ff98674b3e 100644
--- a/grc/core/Config.py
+++ b/grc/core/Config.py
@@ -9,6 +9,7 @@ from __future__ import absolute_import
import os
from os.path import expanduser, normpath, expandvars, exists
+from collections import OrderedDict
from . import Constants
@@ -43,6 +44,9 @@ class Config(object):
valid_paths = [normpath(expanduser(expandvars(path)))
for path in collected_paths if exists(path)]
+ # Deduplicate paths to avoid warnings about finding blocks twice, but
+ # preserve order of paths
+ valid_paths = list(OrderedDict.fromkeys(valid_paths))
return valid_paths