Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requires/types: introduce expression type (expr.py) #913

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Aug 16, 2024

  1. requires/types: introduce expression type (expr.py)

    `expression` is a new requirement type that allows user to express a requirement
    in human-readable, SQL-like syntax. It has a proper grammar to allow user to write
    checks as easily digestable manner, which will improve the QOL for scenario writers
    and code reviewers. The grammar is constructed using `pyparsing` library.
    
    The current grammar supports the following constructs:
    
    - Keywords (True, False, None)
    - Constants (Integer, Float, String literal)
    - Runtime variables (Python properties)
    - Functions(len, not, file, systemd, read_ini, read_cert)
    - Arithmetic operators(sign, mul, div, add, sub, exp)
    - Comparison operators(<, <=, >, >=, ==, !=, in)
    - Logical operators(and, or, not)
    - Comments('#', '//', '/*...*/')
    
    Also, the following changes have been made:
    
    - Updated requirement_types.rst to document the new Expression requirement type.
    - Moved property resolver logic from YPropertyBase to PythonEntityResolver class.
    - Added `pyparsing` as a dependency.
    - Added unit tests for the new code, the coverage rate is 100 pct for the expr.py
    
    This patch rewrites some of the scenario checks in the new expression syntax to
    demonstrate the difference and provide examples.
    
    Signed-off-by: Mustafa Kemal Gilor <[email protected]>
    xmkg committed Aug 16, 2024
    Configuration menu
    Copy the full SHA
    a4b7750 View commit details
    Browse the repository at this point in the history