Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.
/ spp_py Public archive

SSDB Protocol Parser For Python, Built For Speed.

Notifications You must be signed in to change notification settings

hit9/spp_py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Protocol Parser

Actually, this is ssdb's network protocol, and I think it can be used on other projects.

Support Py2.6+/3.3+ (Input str and out str, (the str means bytes in py2.x and unicode in py3.x)).

Protocol

Packet := Block+ '\n'
Block  := Size '\n' Data '\n'
Size   := literal_integer
Data   := string_bytes

For example:

3
set
3
key
3
val

Install

pip install spp

Usage

from spp import Parser

parser = Parser()
parser.feed('2\nok\n\n')

while 1:
    res = parser.get()
    if res is not None:
        print (res)  # => ['ok']
    else:
        break

API Ref

  • parser.feed(str)
  • parser.get()
  • parser.clear()

License

MIT (c) 2014, hit9 (Chao Wang).

About

SSDB Protocol Parser For Python, Built For Speed.

Resources

Stars

Watchers

Forks

Packages

No packages published