Skip to content

Instantly share code, notes, and snippets.

@the5fire
Created June 20, 2017 01:20
Show Gist options
  • Select an option

  • Save the5fire/d2d1fe3ec1408ba1e70bf68d791e0183 to your computer and use it in GitHub Desktop.

Select an option

Save the5fire/d2d1fe3ec1408ba1e70bf68d791e0183 to your computer and use it in GitHub Desktop.

Revisions

  1. the5fire revised this gist Jun 20, 2017. No changes.
  2. the5fire created this gist Jun 20, 2017.
    32 changes: 32 additions & 0 deletions format_redis_log.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # coding:utf-8

    data = """
    1)1) (integer) 4
    2) (integer) 1332222
    3) (integer) 13
    4) 1) "SET"
    2) "database"
    3) "Redis"
    2)1) (integer) 4
    2) (integer) 1332222
    3) (integer) 13
    4) 1) "SET"
    2) "database"
    3) "Redis"
    """

    commands = []
    params = []


    for line in data.split('\n'):
    if line.strip():
    if not line.startswith(' ') and params:
    commands.append(params[:])
    params = []

    params.append(line.split(')')[-1])

    commands.append(params)

    print commands