Commit e209fd97 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Entry points utils improvements

- Skip entry points for python distributions names existing in
  ``SYNNEFO_EXCLUDE_PACKAGES`` environmental variable
- Avoid duplicate entries in list setting objects
parent b568f78b
......@@ -35,13 +35,19 @@ import sys
import pkg_resources
import inspect
import types
import os
from collections import defaultdict
import inspect
# List of python distribution names which entry points will get excluded
# from snf-common settings extension mechanism
EXCLUDED_PACKAGES = os.environ.get('SYNNEFO_EXCLUDE_PACKAGES', '').split(":")
def get_entry_points(ns, name):
for entry_point in pkg_resources.iter_entry_points(group=ns):
if == name:
if == name and \
not entry_point.dist.project_name in EXCLUDED_PACKAGES:
yield entry_point
......@@ -93,6 +99,10 @@ def extend_list_from_entry_point(settings_object, ns, entry_point_name,
for e in get_entry_points(ns, entry_point_name):
obj = entry_point_to_object(e)
for row in obj:
# skip duplicate entries
if row in settings_object:
if type(row) == dict and (row.get('before', False) or \
row.get('after', False)):
if row.get('before', False):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment