Parsers

A parser defines chunk types it could meet during parsing.

Example:

class DataParser(FileParser):
    ChunkClasses = (
        HeaderChunk,
        DataChunk,
    )
class parsers.Parser(fp, total_length=None)

Parse chunks from file or streaming.

  • In file mode, total_length can be left None and will be read from file system.
  • In streaming mode, you must provide total_length to specify the end of the stream.
Parameters:
  • fp – File object to be read from.
  • total_length – Total length of the source.
Throws ParseTimeoutException:
 

Timeout. Default is 60s.

fp

FilePtr object to read.

chunks

A list of chunks inside.

class parsers.FileParser(path)

Parse from file.

Parameters:path – File path.
exception parsers.ParseTimeoutException

Exception indicating that timeout occurs when parsing.

Previous topic

Chunker - Easy Chunk-Based File Structure Parsing

Next topic

Chunks

This Page