clearml/trains/storage/util.py
2019-06-10 20:02:11 +03:00

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