Decide what level the argument specifies and return it.  The argument
    must contain (case-insensitive) one of the values in LEVELS or be an integer
    constant.  Otherwise None will be returned.
161536
def first_arg_to_level_name(arg):
    """"""
    try:
        return int(arg)
    except ValueError:
        arg = arg.upper()
        for level in LEVELS:
            if level in arg:
                return level
        return None
74502
def range_values(args):
    
    if len(args) == 1:
        return Interval(0, args[0].high)
    elif len(args) == 2:
        return Interval(args[0].low, args[1].high)
    elif len(args) == 3:
        is_neg = args[2].low < 0
        is_pos = args[2].high > 0
        if is_neg and is_pos:
            return UNKNOWN_RANGE
        elif is_neg:
            return Interval(args[1].low, args[0].high)
        else:
            return Interval(args[0].low, args[1].high)
1307353
def level=(severity)
      if severity.is_a?(Integer)
        @logger.level = severity
      else
        case severity.to_s.downcase
        when 'debug'
          @logger.level = DEBUG
        when 'info'
          @logger.level = INFO
        when 'warn'
          @logger.level = WARN
        when 'error'
          @logger.level = ERROR
        when 'fatal'
          @logger.level = FATAL
        when 'unknown'
          @logger.level = UNKNOWN
        else
          raise ArgumentError, "invalid log level: #{severity}"
        end
      end
    end
347477
def level=(val)
      unless LEVELS.include?(val)
        fail "Unknown log level, valid values are: #{LEVELS}"
      end
      # Map the log4r levels to our simplified 3 level system
      # log4r level order is DEBUG < INFO < WARN < ERROR < FATAL
      case val
      when :normal
        # Output everything except debug statements
        console.level = Logger::INFO
        # Output everything
        log_files(:level=, Logger::DEBUG) unless console_only?
      when :verbose
        console.level = Logger::DEBUG
        log_files(:level=, Logger::DEBUG) unless console_only?
      when :silent
        # We don't use any fatal messages, so this is effectively OFF
        console.level = Logger::FATAL
        log_files(:level=, Logger::DEBUG) unless console_only?
      end

      @level = val
    end
200323
def convert(self, argument):
    """"""
    if _is_integer_type(argument):
      return argument
    elif isinstance(argument, six.string_types):
      base = 10
      if len(argument) > 2 and argument[0] == '0':
        if argument[1] == 'o':
          base = 8
        elif argument[1] == 'x':
          base = 16
      return int(argument, base)
    else:
      raise TypeError('Expect argument to be a string or int, found {}'.format(
          type(argument)))
470445
def cases(arg, case_result_pairs, default=None):
    
    builder = arg.case()
    for case, result in case_result_pairs:
        builder = builder.when(case, result)
    if default is not None:
        builder = builder.else_(default)
    return builder.end()
1368254
def level(self) -> str:
        
        levels = self._data['level']
        return self.random.choice(levels)
1175479
def _get_level(tag):
        
        m = re.match(r'^h([123456])$', tag, flags=re.IGNORECASE)
        if not m:
            return None
        return int(m.group(1))
692072
def _validate_index_level(self, level):
        
        if isinstance(level, int):
            if level < 0 and level != -1:
                raise IndexError("Too many levels: Index has only 1 level,"
                                 " %d is not a valid level number" % (level, ))
            elif level > 0:
                raise IndexError("Too many levels:"
                                 " Index has only 1 level, not %d" %
                                 (level + 1))
        elif level != self.name:
            raise KeyError('Level %s must be same as name (%s)' %
                           (level, self.name))
743600
def p_levelsigs(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
1352500
def _validate(self, val):
        
        if callable(val):
            return val

        if self.allow_None and val is None:
            return

        if not _is_number(val):
            raise ValueError("Parameter '%s' only takes numeric values"%(self.name))

        if self.step is not None and not _is_number(self.step):
            raise ValueError("Step parameter can only be None or a numeric value")

        self._checkBounds(val)
1218364
def safe_int(val, allow_zero=True):
    
    try:
        ret = int(val)
    except ValueError:
        print("Sorry, '%s' is not a valid integer." % val)
        return False
    if not allow_zero and ret == 0:
        print("Please enter a non-zero integer.")
        return False
    return ret
432150
def _argparse_minmax_type(self, string):
        """"""
        value = float(string)
        if value < 0 or value > 8:
            raise argparse.ArgumentTypeError(
                '%s must be between 0.0 and 8.0' % string,
            )

        return value
503011
def level(self):
        """"""
        # Used for dimmers, curtains
        # Have seen formats of 10, 0.0 and "0%"!
        level = self.get_value('level')
        try:
            return int(float(level))
        except (TypeError, ValueError):
            pass
        try:
            return int(level.strip('%'))
        except (TypeError, AttributeError, ValueError):
            pass
        return 0
1343922
def check_argument_types(cllable = None, call_args = None, clss = None, caller_level = 0):
    
    return _check_caller_type(False, cllable, call_args, clss, caller_level+1)
436713
def level=(level)
      @logger.level = case level
      when :debug, ::Logger::DEBUG
        Java::org.apache.log4j.Level::DEBUG
      when :info, ::Logger::INFO
        Java::org.apache.log4j.Level::INFO
      when :warn, ::Logger::WARN
        Java::org.apache.log4j.Level::WARN
      when :error, ::Logger::ERROR
        Java::org.apache.log4j.Level::ERROR
      when :fatal, ::Logger::FATAL
        Java::org.apache.log4j.Level::FATAL
      else
        raise NotImplementedError
      end
    end
1276997
def max_values(args):
    
    return Interval(max(x.low for x in args), max(x.high for x in args))