Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
text += titled_group(group) + cls.show_keys(
keys, indent=indent, grouped=False, func=six.text_type,
include_links=include_links) + '\n\n'
return func(text.rstrip())
if not keys:
return
n = len(keys)
ncols = min([4, n]) # number of columns
# The number of cells in the table is one of the following cases:
# 1. The number of columns and equal to the number of keys
# 2. The number of keys
# 3. The number of keys plus the empty cells in the last column
ncells = n + ((ncols - (n % ncols)) if n != ncols else 0)
if include_links or (include_links is None and cls.include_links):
long_keys = list(map(lambda key: ':attr:`~%s.%s.%s`' % (
cls.__module__, cls.__name__, key), keys))
else:
long_keys = keys
maxn = max(map(len, long_keys)) # maximal lenght of the keys
# extend with empty cells
long_keys.extend([' ' * maxn] * (ncells - n))
bars = (str_indent + '+-' + ("-"*(maxn) + "-+-")*ncols)[:-1]
lines = ('| %s |\n%s' % (' | '.join(
key.ljust(maxn) for key in long_keys[i:i+ncols]), bars)
for i in range(0, n, ncols))
text = bars + "\n" + str_indent + ("\n" + str_indent).join(
lines)
if six.PY2:
text = text.encode('utf-8')
return func(text)
----------
fmt: dict
Keys can be any valid formatoptions with the corresponding values
(see the :attr:`formatoptions` attribute)
replot: bool
Boolean that determines whether the data specific formatoptions
shall be updated in any case or not.
%(InteractiveBase._register_update.parameters.force|todefault)s"""
if self.disabled:
return
self.replot = self.replot or replot
self._todefault = self._todefault or todefault
if force is True:
force = list(fmt)
self._force.update(
[ret[0] for ret in map(self.check_key, force or [])])
# check the keys
list(map(self.check_key, fmt))
self._registered_updates.update(fmt)
This method takes the :attr:`_rcparams_string` attribute from the given
`class` and combines it with the :attr:`_rcparams_string` attributes
from the base classes.
The returned frozenset can be used as base strings for the
:meth:`psyplot.config.rcsetup.RcParams.find_and_replace` method.
Returns
-------
list
The first entry is the :attr:`_rcparams_string` of this class,
the following the :attr:`_rcparams_string` attributes of the
base classes according to the method resolution order of this
class"""
return list(unique_everseen(chain(
*map(lambda base: getattr(base, '_rcparams_string', []),
cls.__mro__))))
See Also
--------
_format_keys"""
def base_fmtos(base):
return filter(
lambda key: isinstance(getattr(cls, key), Formatoption),
getattr(base, '_get_formatoptions', empty)(False))
def empty(*args, **kwargs):
return list()
fmtos = (attr for attr, obj in six.iteritems(cls.__dict__)
if isinstance(obj, Formatoption))
if not include_bases:
return fmtos
return unique_everseen(chain(fmtos, *map(base_fmtos, cls.__mro__)))
None if `func` is the print function, otherwise anything else
See Also
--------
show_summaries, show_docs"""
def titled_group(groupname):
bars = str_indent + '*' * len(groupname) + '\n'
return bars + str_indent + groupname + '\n' + bars
keys = cls._enhance_keys(keys, *args, **kwargs)
str_indent = " " * indent
func = func or default_print_func
# call this function recursively when grouped is True
if grouped:
grouped_keys = DefaultOrderedDict(list)
for fmto in map(lambda key: getattr(cls, key), keys):
grouped_keys[fmto.groupname].append(fmto.key)
text = ""
for group, keys in six.iteritems(grouped_keys):
text += titled_group(group) + cls.show_keys(
keys, indent=indent, grouped=False, func=six.text_type,
include_links=include_links) + '\n\n'
return func(text.rstrip())
if not keys:
return
n = len(keys)
ncols = min([4, n]) # number of columns
# The number of cells in the table is one of the following cases:
# 1. The number of columns and equal to the number of keys
# 2. The number of keys
# 3. The number of keys plus the empty cells in the last column
%(Plotter.show_keys.returns)s
See Also
--------
show_summaries, show_docs"""
def titled_group(groupname):
bars = str_indent + '*' * len(groupname) + '\n'
return bars + str_indent + groupname + '\n' + bars
func = func or default_print_func
keys = cls._enhance_keys(keys, *args, **kwargs)
str_indent = " " * indent
if grouped:
grouped_keys = DefaultOrderedDict(list)
for fmto in map(lambda key: getattr(cls, key), keys):
grouped_keys[fmto.groupname].append(fmto.key)
text = "\n\n".join(
titled_group(group) + cls._show_doc(
fmt_func, keys, indent=indent, grouped=False,
func=str, include_links=include_links)
for group, keys in six.iteritems(grouped_keys))
return func(text.rstrip())
if include_links or (include_links is None and cls.include_links):
long_keys = list(map(lambda key: ':attr:`~%s.%s.%s`' % (
cls.__module__, cls.__name__, key), keys))
else:
long_keys = keys
text = '\n'.join(str_indent + long_key + '\n' + fmt_func(
key, long_key, getattr(cls, key).__doc__) for long_key, key in zip(
----------
keys: string or iterable of strings
The iterable may contain formatoptions that shall be shared (or
unshared), or group names of formatoptions to share all
formatoptions of that group (see the :attr:`fmt_groups` property).
If None, all formatoptions of this plotter are inserted.
Returns
-------
set
The set of formatoptions to share (or unshare)"""
if isinstance(keys, str):
keys = {keys}
keys = set(self) if keys is None else set(keys)
fmto_groups = self._fmto_groups
keys.update(chain(*(map(lambda fmto: fmto.key, fmto_groups[key])
for key in keys.intersection(fmto_groups))))
keys.difference_update(fmto_groups)
return keys
def _set_rc(self):
"""Method to set the rcparams and defaultParams for this plotter"""
base_str = self._get_rc_strings()
# to make sure that the '.' is not interpreted as a regex pattern,
# we specify the pattern_base by ourselves
pattern_base = map(lambda s: s.replace('.', '\.'), base_str)
# pattern for valid keys being all formatoptions in this plotter
pattern = '(%s)(?=$)' % '|'.join(self._get_formatoptions())
self._rc = rcParams.find_and_replace(base_str, pattern=pattern,
pattern_base=pattern_base)
user_rc = SubDict(rcParams['plotter.user'], base_str, pattern=pattern,
pattern_base=pattern_base)
self._rc.update(user_rc.data)
self._defaultParams = SubDict(rcParams.defaultParams, base_str,
pattern=pattern,
pattern_base=pattern_base)