This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A method to give a rudimentary 'diff' of 2 sequences. | |
| """ | |
| import collections | |
| # Holds a single set of continuous differences between two sequences. | |
| # The offset gives the offset in the original sequences where the | |
| # differences begin. The a and b will hold the respective differing | |
| # elements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A data buffer read/write utility. Intended for handling network binary | |
| packet data. Works by using basic python strings which include binary | |
| bytes. The string can be tossed directly into a socket send() or | |
| sendto(). Similarly, can be used to parse out data types out of a binary | |
| string. | |
| Note this isn't restricted to network data; it can be used to read/write | |
| any binary data string. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Another simple token parser. Generator yielding tokens out of a | |
| multi-line string. | |
| Tokens are white-space, quote, or comment dilimited. Quoted tokens | |
| with escaped characters are supported. | |
| Example: | |
| ' token1 token2 "quoted token" # comment until end of line ' | |
| ' token1 "quoted with \"escape\" sequences" ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| A simple token parser. | |
| """ | |
| import string | |
| class Tokenizer(object): | |
| """ | |
| Utility to parse out tokens from a possibly multi-line string. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Struct Unpacker: use a simply formatted string to tell how to unpack | |
| binary data into a dict. | |
| Example: "x <i, y <i, name 8s" | |
| { | |
| "x": a signed 32-bit int, | |
| "y": a signed 32-bit int, | |
| name": a string of 8 characters | |
| } |