- # forbidden, completely ignore what the user requested
- combined_valid_types = []
- if user_valid_types and valid_types:
- combined_valid_types = list(
- set(user_valid_types) & set(combined_valid_types)
- )
-
- if not combined_valid_types:
- # No overlap! Just use the enforced ones
- combined_valid_types = valid_types
- else:
- # One list or the other was blank, so just use the one that isn't
- combined_valid_types = valid_types + user_valid_types
+ # forbidden, completely ignore what the user requested.
+ # And, just to complicate matters: "type" and language need to be
+ # considered separately.
+ def merge_requirements(func):
+ user = filter(func, user_valid_types)
+ system = filter(func, valid_types)
+
+ if user and system:
+ merged = list(set(user) & set(system))
+ if merged:
+ return merged
+ else:
+ # No overlap; use the system restrictions
+ return system
+ else:
+ # One or the other is blank; use the one that's not
+ return user or system