heikkiorsila/bencode-tools — pull request #6 by japeq (2012-05-02 17:04:12+00:00)
Title: Implement unpacking data structures similar to scanf()

The new unpacking function takes bencode data structure, a format string
and a list of pointers as variable arguments. The structure is checked
against the format and values are unpacked using the given specifiers.
A specifier begins with a percent (%) that follows a string of specifier
characters.
The syntax is similar to Python format for recursive data structures, and
consists of tokens {, }, [, ] with any number of spaces between them.
The keys of a dictionary are given as literal strings or integers and
matched against the keys of the Bencoded structure.