How xowap/easy-leasy works
Main Components
• DSL Input & Parser Module: This corresponds to the _parser.py file. It takes the multi-line DSL expressions (which can include import, let, and return statements) and converts them into the internal representation.
• Core TimeSet Abstraction: Represented in _base.py where the BaseTimeSet class is defined. This class serves as the parent for different time set implementations.
• Operations Module: Found in _operations.py, it implements the logic behind set operators (union, intersection, difference) that combine individual time set components.
• Scalars and Specific Time Components: In _scalars.py, submodules like HourRange, Day, Month, and the Always/Never classes are defined to encapsulate specific time rules.
• Testing Components: Although external to the core system, the tests directory (including test_operations.py, test_parser.py, test_scalars.py) verifies the correctness of each module.
• The “Parser” component (module _parser.py) processes the DSL input and produces an abstract syntax tree (AST) or directly instantiates one or more subclasses of BaseTimeSet.
• Data flows from the Parser into the “Core TimeSet” component (module _base.py) which provides the common interface for query methods like value_at and next_change.
• The “Scalar Components” (from _scalars.py) implement the concrete time components (like HourRange, Day, Month, Always, Never) that are used by the BaseTimeSet to represent actual time periods.
Important Architectural Patterns
• Modularity: Each module (parser, base, operations, scalars) represents a well-defined part of the DSL processing and time-set evaluation.
• Composability: The time set objects are designed to be composed using mathematical set operations, which is a central design principle.
• API Abstraction: Through the BaseTimeSet and its subclasses, the library isolates DSL parsing from time evaluation, facilitating a clear separation of concerns.
Specific Elements
• Next, represent the “Parser” component to handle language constructs such as “from … import …”, “let … be when …”, and “return …”.
• Then branch to the “Core TimeSet System”, which is subdivided into abstract classes (BaseTimeSet) and its concrete implementations from both the Scalar and Operations modules.
• Optionally, add a “Testing” block that ensures each of these components functions correctly.