xoa.misc.dict_filter

xoa.misc.dict_filter(kwargs, filters, defaults=None, copy=False, short=False, keep=False, **kwadd)[source]

Filter out kwargs (typically extra calling keywords)

Parameters:
  • kwargs – Dictionnary to filter.

  • filters – Single or list of prefixes.

  • defaults – dictionnary of default values for output fictionnary.

  • copy – Simply copy items, do not remove them from kwargs.

  • short – Allow prefixes to not end with "_".

  • keep – Keep prefix filter in output keys.

Example

In [1]: kwargs = {'basemap':'f', 'basemap_fillcontinents':True, 'quiet':False,'basemap_plot':False}

In [2]: dict_filter(kwargs,'basemap', defaults=dict(drawcoastlines=True,plot=True), good=True)
Out[2]: 
{'basemap': 'f',
 'fillcontinents': True,
 'plot': False,
 'good': True,
 'drawcoastlines': True}

In [3]: kwargs
Out[3]: {'quiet': False}
Returns:

dict