<commit_before>#!/usr/bin/env ruby

require "rubygems"
require "sinatra/base"
require "haml"
require "sass"
require "json"
require "redis"
require "shellwords"
require "logger"
require "rdiscount"
require "andand"

module NamespaceTools
  def namespace_input(ns, command, *args)
    command = command.to_s.downcase

    case command

    when "multi", "exec", "discard"

      # No arguments.

      [ command ]

    when "exists", "del", "type", "keys", "ttl", "set", "get", "getset",
         "setnx", "incr", "incrby", "decr", "decrby", "rpush", "lpush",
         "llen", "lrange", "ltrim", "lindex", "lset", "lrem", "lpop", "rpop",
         "sadd", "srem", "spop", "scard", "sismember", "smembers", "srandmember",
         "zadd", "zrem", "zincrby", "zrange", "zrevrange", "zrangebyscore",
         "zcard", "zscore", "zremrangebyscore", "expire", "expireat", "hlen",
         "hkeys", "hvals", "hgetall", "hset", "hget", "hincrby", "hexists",
         "hdel", "hmset"

      # Only the first argument is a key.

      head = add_namespace(ns, args.first)
      tail = args[1, args.length - 1] || []

      [ command, head, *tail ]

    when "smove"

      # The first two parmeters are keys.

      result = [ command ]

      args.each_with_index do |arg, i|
        result << ((i == 0 || i == 1) ? add_namespace(ns, arg) : arg)
      end

      result

    when "mget", "rpoplpush", "sinter", "sunion", "sdiff", "info",
         "sinterstore", "sunionstore", "sdiffstore"<commit_msg>Add support for RENAME and RENAMENX.<commit_after>#!/usr/bin/env ruby

require "rubygems"
require "sinatra/base"
require "haml"
require "sass"
require "json"
require "redis"
require "shellwords"
require "logger"
require "rdiscount"
require "andand"

module NamespaceTools
  def namespace_input(ns, command, *args)
    command = command.to_s.downcase

    case command

    when "multi", "exec", "discard"

      # No arguments.

      [ command ]

    when "exists", "del", "type", "keys", "ttl", "set", "get", "getset",
         "setnx", "incr", "incrby", "decr", "decrby", "rpush", "lpush",
         "llen", "lrange", "ltrim", "lindex", "lset", "lrem", "lpop", "rpop",
         "sadd", "srem", "spop", "scard", "sismember", "smembers", "srandmember",
         "zadd", "zrem", "zincrby", "zrange", "zrevrange", "zrangebyscore",
         "zcard", "zscore", "zremrangebyscore", "expire", "expireat", "hlen",
         "hkeys", "hvals", "hgetall", "hset", "hget", "hincrby", "hexists",
         "hdel", "hmset"

      # Only the first argument is a key.

      head = add_namespace(ns, args.first)
      tail = args[1, args.length - 1] || []

      [ command, head, *tail ]

    when "smove"

      # The first two parmeters are keys.

      result = [ command ]

      args.each_with_index do |arg, i|
        result << ((i == 0 || i == 1) ? add_namespace(ns, arg) : arg)
      end

      result

    when "mget", "rpoplpush", "sinter", "sunion", "sdiff", "info",
         "sinterstore", "sunionstore", "sdiffstore", "rename", "renamenx"
{'fraction_non_alphanumeric': 0.18545454545454546, 'fraction_numerical': 0.002644628099173554, 'mean_word_length': 3.1058344640434195, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '172566', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1096, 'n_words': 290}