locomotor package¶
Submodules¶
locomotor.identify module¶
-
locomotor.identify.
REDIS_METHODS
= set(['append', 'blpop', 'brpop', 'brpoplpush', 'decr', 'delete', 'execute', 'exists', 'expire', 'expireat', 'get', 'getbit', 'getset', 'hdel', 'hget', 'hgetall', 'hincrby', 'hkeys', 'hlen', 'hmget', 'hmset', 'hset', 'hsetnx', 'hvals', 'incr', 'lindex', 'linsert', 'llen', 'lpop', 'lpush', 'lpushnx', 'lrange', 'lrem', 'lset', 'ltrim', 'mget', 'move', 'mset', 'msetnx', 'persist', 'publish', 'randomkey', 'rename', 'renamenx', 'rpop', 'rpoplpush', 'rpush', 'rpushx', 'sadd', 'scard', 'sdiff', 'sdiffstore', 'set', 'setbit', 'setex', 'setnx', 'setrange', 'sinter', 'sinterstore', 'sismember', 'smembers', 'smove', 'sort', 'spop', 'srandmember', 'srem', 'strlen', 'substr', 'sunion', 'sunionstore', 'ttl', 'zadd', 'zcard', 'zincrby', 'zinterstore', 'zrange', 'zrangebyscore', 'zrank', 'zrem', 'zremrangebyrank', 'zrevrange', 'zrevrangebyscore', 'zrevrank', 'zrevscore', 'zunionstore'])¶ Method names used when trying to identify Redis client objects
-
locomotor.identify.
REDIS_METHOD_COUNT
= 2¶ The minimum number of methods which must be identified as Redis calls to denote an object as corresponding to a Redis client
-
locomotor.identify.
REDIS_METHOD_PCT
= 0.8¶ The percentage of method calls which must match a predefined list
Module contents¶
-
locomotor.
DEBUG_LOG_CHANNEL
= 'locomotor-debug'¶ A channel used to push debug messages from Lua scripts
-
locomotor.
FUNC_BUILTINS
= ('append', 'insert', 'join', 'replace')¶ Function names which we assume are builtins
-
locomotor.
LUA_HEADER
= 'redis.replicate_commands()\nlocal __RETVAL = function(value, retval)\n local __RESULT = {}\n __RESULT["__value"] = value\n __RESULT["__return"] = retval\n\n return cmsgpack.pack(__RESULT)\nend\n\nlocal __TRUE = function(expr)\n local __VAL = expr\n if not __VAL or __VAL == 0 then\n return false\n end\n\n local __TYPE = type(__VAL)\n if (__TYPE == "table" or __TYPE == "string") and #__VAL == 0 then\n return false\n else\n return true\n end\nend\n\nlocal __OR = function(...)\n local __VAL = nil\n for i, v in ipairs(arg) do\n if __TRUE(v) then\n return v\n else\n __VAL = v\n end\n end\n\n return __VAL\nend\n\nlocal __AND = function(...)\n local __VAL = nil\n for i, v in ipairs(arg) do\n if not __TRUE(v) then\n return v\n else\n __VAL = v\n end\n end\n\n return __VAL\nend\n'¶ A header added to all generated Lua code
-
locomotor.
PACKED_TYPES
= (<type 'list'>, <type 'dict'>, <type 'NoneType'>, <type 'datetime.datetime'>)¶ Types which should be serialized via msgpack
-
locomotor.
PIPELINED_CODE
= 'local __PIPELINE_RESULTS = {}\n\nlocal __PIPE_ADD = function(key, value)\n if __PIPELINE_RESULTS[key] == nil then\n __PIPELINE_RESULTS[key] = {}\n end\n\n table.insert(__PIPELINE_RESULTS[key], value)\n return value\nend\n\nlocal __PIPE_GET = function(key)\n local RETVAL = __PIPELINE_RESULTS[key]\n __PIPELINE_RESULTS[key] = {}\n return RETVAL\nend\n\n'¶ Additional functions for code which uses pipelining
-
class
locomotor.
RedisFuncFragment
(taint, minlineno=None, maxlineno=None, redis_objs=None, helper=False)[source]¶ Bases:
object
-
process_AugAssign
(node, code, indent, loops)[source]¶ Generate code for agumented assignment (e.g. +=)
-
process_node
(node, indent=0, loops=0)[source]¶ Generate code for a single node at a particular indentation level
-
-
locomotor.
TAB
= ' '¶ The string literal to use for tabs in generated Lua code
-
locomotor.
UNPIPELINED_CODE
= '\nlocal __PIPE_ADD = function(key, value) return value end\n'¶ A dummy function to use for code which does not involve pipelining