Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self._registered_updates.setdefault(key, getattr(self, key).value)
for key, value in chain(
six.iteritems(self._registered_updates),
six.iteritems(
{key: getattr(self, key).default for key in self})
if self._todefault else ()):
if key in seen:
continue
seen.add(key)
fmto = getattr(self, key)
# if the key is shared, a warning will be printed as long as
# this plotter is not also updating (for example due to a whole
# project update)
if key in self._shared and key not in self._force:
if not self._shared[key].plotter._updating:
warn(("%s formatoption is shared with another plotter."
" Use the unshare method to enable the updating") % (
fmto.key),
logger=self.logger)
changed = False
else:
try:
changed = fmto.check_and_set(
value, todefault=self._todefault,
validate=not self.no_validation)
except Exception as e:
self._registered_updates.pop(key, None)
self.logger.debug('Failed to set %s', key)
raise e
changed = changed or key in self._force
if changed:
fmtos.append(fmto)
def update(self, *args, **kwargs):
for k, v in six.iteritems(dict(*args, **kwargs)):
try:
self[k] = v
except (ValueError, RuntimeError):
# force the issue
warn(_rcparam_warn_str.format(key=repr(k), value=repr(v),
func='update'))
dict.__setitem__(self, k, v)
Other Parameters
----------------
``*args, **kwargs``
Any key-value pair for the initialization of the dictionary
"""
defaultParams = kwargs.pop('defaultParams', None)
if defaultParams is not None:
self.defaultParams = defaultParams
self._deprecated_map = {}
self._deprecated_ignore_map = {}
for k, v in six.iteritems(dict(*args, **kwargs)):
try:
self[k] = v
except (ValueError, RuntimeError):
# force the issue
warn(_rcparam_warn_str.format(key=repr(k), value=repr(v),
func='__init__'))
dict.__setitem__(self, k, v)
for i, key in enumerate(keys[:]):
if key in fmto_groups:
del keys[new_i]
for key2 in fmto_groups[key]:
if key2 not in keys:
keys.insert(new_i, key2)
new_i += 1
else:
valid, similar, message = check_key(
key, all_keys, False, 'formatoption keyword', *args,
**kwargs)
if not valid:
keys.remove(key)
new_i -= 1
warn(message)
new_i += 1
return keys
def _get_depreceated(self, key, *args):
if key in self._deprecated_map:
alt_key, alt_val = self._deprecated_map[key]
warn(self.msg_depr % (key, alt_key))
key = alt_key
return key, alt_val(args[0]) if args else None
elif key in self._deprecated_ignore_map:
alt = self._deprecated_ignore_map[key]
warn(self.msg_depr_ignore % (key, alt))
return None, None
elif key not in self.defaultParams:
raise KeyError(
'%s is not a valid rc parameter. See rcParams.keys() for a '
'list of valid parameters.' % (key,))
return key, args[0] if args else None
def groupname(self):
"""Long name of the group this formatoption belongs too."""
try:
return groups[self.group]
except KeyError:
warn("Unknown formatoption group " + str(self.group),
PsyPlotRuntimeWarning)
return self.group
def _get_depreceated(self, key, *args):
if key in self._deprecated_map:
alt_key, alt_val = self._deprecated_map[key]
warn(self.msg_depr % (key, alt_key))
key = alt_key
return key, alt_val(args[0]) if args else None
elif key in self._deprecated_ignore_map:
alt = self._deprecated_ignore_map[key]
warn(self.msg_depr_ignore % (key, alt))
return None, None
elif key not in self.defaultParams:
raise KeyError(
'%s is not a valid rc parameter. See rcParams.keys() for a '
'list of valid parameters.' % (key,))
return key, args[0] if args else None