Skip to content

Commit

Permalink
ref: replace if_parser with esp_bool_parser package
Browse files Browse the repository at this point in the history
  • Loading branch information
horw committed Jan 7, 2025
1 parent 49f4aed commit a88fa72
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 415 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ repos:
- types-toml
- pytest
- argcomplete>=3
- esp-bool-parser
- repo: https://github.com/hfudev/rstfmt
rev: v0.1.4
hooks:
Expand Down
14 changes: 13 additions & 1 deletion idf_build_apps/manifest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0

"""
Manifest file
"""

from esp_bool_parser import register_addition_attribute

from .manifest import FolderRule


def folder_rule_attr(target, **kwargs):
_ = kwargs
return 1 if target in FolderRule.DEFAULT_BUILD_TARGETS else 0


register_addition_attribute('INCLUDE_DEFAULT', folder_rule_attr)
240 changes: 0 additions & 240 deletions idf_build_apps/manifest/if_parser.py

This file was deleted.

10 changes: 4 additions & 6 deletions idf_build_apps/manifest/manifest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import logging
import os
import pickle
import typing as t
from hashlib import sha512

from esp_bool_parser import parse_bool_expr
from esp_bool_parser.bool_parser import BoolStmt
from pyparsing import (
ParseException,
)
Expand All @@ -23,18 +25,14 @@
from ..yaml import (
parse,
)
from .if_parser import (
BOOL_EXPR,
BoolStmt,
)

LOGGER = logging.getLogger(__name__)


class IfClause:
def __init__(self, stmt: str, temporary: bool = False, reason: t.Optional[str] = None) -> None:
try:
self.stmt: BoolStmt = BOOL_EXPR.parseString(stmt)[0]
self.stmt: BoolStmt = parse_bool_expr(stmt)
except (ParseException, InvalidIfClause) as ex:
raise InvalidIfClause(f'Invalid if clause: {stmt}. {ex}')

Expand Down
Loading

0 comments on commit a88fa72

Please sign in to comment.