Psifas (or pypsifas) is a free and open source Python library for parsing and building of data structures with the ability of solving simple heuristics of interdepent sub-structures.
Psifas is based on the concept of defining data structures in a declarative manner, where complex structures are composed by combining simpler ones. Refer to the Features list below.
Psifas is the hebrew word for Mosaic. The word comes from the greek word: ψ???φος (psefos), which means "a stone".
Here are some key features of "Psifas":
· Bit-level - you can work with individual bits.
· Byte ordering - supports both little and big endian byte ordering
· Componentized - combine the primitives into more complex structures
· Symmetrical - psifases can both parse (create an object from raw data) and build (create raw data from an object)
· Ready - comes with many built-in primitives and inventory psifases that you can use out-of-the-box.
· Declarative - you write a data structure, not code.
· Easy to debug - much easier to correct a data structure instead of code. Furthermore, when an exception is raised, the user is told the position in the psifas structure in which the error happend.
· Easy to test - componentization means that once a component works, it always works. You can easily share structures between modules without something breaking.
· Easy to extend - when the need arises, just subclass from one of the generic classes.
· Thread-safe - Psifas is fully thread safe; you can parse the same psifas in parallel threads.
· Nameless - psifases do not have names. Their names are given when they`re put in other structures. For example, several fields with different names can be of type "Bigendian 4 bytes number".
· Verifiable - Easy design of fields that are expected to contain a specific value, or one value out of a range (enums, checksums, and more..)
· Orderless dependencies - The value a field can be dependent on the values of previous or following fields.
· Dynamic dependencies (Links) - Psifases use Links to mention which other fields` values they require. For example, when a string with a dynamic length (Segment) is created, it will be created with a Link to the field that should contain its length. The Segment class is generic, and can use any Link you want.
· Work on payloads - Calculate values from the raw-buffer (the payload) that was used to evaluate other fields (usefull in checksums & crcs)
· Sorted print - When printing containers (the result of parsing structures with several fields, like a IP header), their attributes will be displayed in the order they were set (unlike python dictionaries in which the keys can be reordered).
Requirements:
· Python
What`s New in This Release: [ read full changelog ]
· major bug fixes (mostly using pylint)