docs: def normalize_errorlevel(error, accept_none=False):
      """\
      Returns a constant for the provided error level.
  
      This function returns ``None`` if the provided parameter is ``None`` and
      `accept_none` is set to ``True`` (default: ``False``). If `error` is ``None``
      and `accept_none` is ``False`` or if the provided parameter cannot be
      mapped to a valid QR Code error level, a ErrorLevelError is raised.
  
      :param error: String or ``None``.
      :param bool accept_none: Indicates if ``None`` is accepted as error level.
      :rtype: int
      """
      if error is None:
          if not accept_none:
              raise ErrorLevelError('The error level must be provided')
          return error
      try:
          return consts.ERROR_MAPPING[error.upper()]
      except:  # KeyError or error.upper() fails
          if error in consts.ERROR_MAPPING.values():
              return error
          raise ErrorLevelError('Illegal error correction level: "{0}".'
                                'Supported levels: {1}'
                                .format(error, ', '.join(sorted(consts.ERROR_MAPPING.keys()))))