Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get(cs, ix, default=no_default):
try:
return cs[ix]
except IndexError:
if default is no_default:
raise
return default
def _get_as_str(groups, section, field, default=no_default):
"""Lookup a field from a given section.
Parameters
----------
groups : dict[str, dict[str, str]]
The grouped osu! file.
section : str
The section to read from.
field : str
The field to read.
default : int, optional
A value to return if ``field`` is not in ``groups[section]``.
Returns
-------
cs : str
def _get_as_int(groups, section, field, default=no_default):
"""Lookup a field from a given section and parse it as an integer.
Parameters
----------
groups : dict[str, dict[str, str]]
The grouped osu! file.
section : str
The section to read from.
field : str
The field to read and parse.
default : int, optional
A value to return if ``field`` is not in ``groups[section]``.
Returns
-------
integer : int
def _get(cs, ix, default=no_default):
try:
return cs[ix]
except IndexError:
if default is no_default:
raise
return default
def _get_as_float(groups, section, field, default=no_default):
"""Lookup a field from a given section and parse it as an float
Parameters
----------
groups : dict[str, dict[str, str]]
The grouped osu! file.
section : str
The section to read from.
field : str
The field to read and parse.
default : float, optional
A value to return if ``field`` is not in ``groups[section]``.
Returns
-------
f : float