mirror of
https://github.com/clearml/clearml
synced 2025-01-31 17:17:00 +00:00
19 lines
607 B
Python
19 lines
607 B
Python
import six
|
|
import fnmatch
|
|
|
|
|
|
def get_config_object_matcher(**patterns):
|
|
unsupported = {k: v for k, v in patterns.items() if not isinstance(v, six.string_types)}
|
|
if unsupported:
|
|
raise ValueError('Unsupported object matcher (expecting string): %s'
|
|
% ', '.join('%s=%s' % (k, v) for k, v in unsupported.items()))
|
|
|
|
def _matcher(**kwargs):
|
|
for key, value in kwargs.items():
|
|
if not value:
|
|
continue
|
|
pat = patterns.get(key)
|
|
if pat and fnmatch.fnmatch(value, pat):
|
|
return True
|
|
return _matcher
|