Skip to content

Commit 38cb76b

Browse files
authored
Merge pull request #2 from espressif/lazy-load
feat: lazy loading for constants and soc_header in bool_parser
2 parents f85b2f5 + bc14497 commit 38cb76b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

esp_bool_parser/bool_parser.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@
2525
opAssoc,
2626
)
2727

28-
from .constants import (
29-
IDF_VERSION,
30-
IDF_VERSION_MAJOR,
31-
IDF_VERSION_MINOR,
32-
IDF_VERSION_PATCH,
33-
)
34-
from .soc_header import (
35-
SOC_HEADERS,
36-
)
3728
from .utils import (
3829
InvalidInput,
3930
to_version,
@@ -82,6 +73,20 @@ def get_value(self, target: str, config_name: str) -> t.Any:
8273
if self.attr == 'IDF_TARGET':
8374
return target
8475

76+
if self.attr == 'CONFIG_NAME':
77+
return config_name
78+
79+
# for non-keyword cap words, check if it is defined in the environment variables
80+
if self.attr in os.environ:
81+
return os.environ[self.attr]
82+
83+
from .constants import (
84+
IDF_VERSION,
85+
IDF_VERSION_MAJOR,
86+
IDF_VERSION_MINOR,
87+
IDF_VERSION_PATCH,
88+
)
89+
8590
if self.attr == 'IDF_VERSION':
8691
return IDF_VERSION
8792

@@ -94,16 +99,11 @@ def get_value(self, target: str, config_name: str) -> t.Any:
9499
if self.attr == 'IDF_VERSION_PATCH':
95100
return IDF_VERSION_PATCH
96101

97-
if self.attr == 'CONFIG_NAME':
98-
return config_name
102+
from .soc_header import SOC_HEADERS
99103

100104
if self.attr in SOC_HEADERS[target]:
101105
return SOC_HEADERS[target][self.attr]
102106

103-
# for non-keyword cap words, check if it is defined in the environment variables
104-
if self.attr in os.environ:
105-
return os.environ[self.attr]
106-
107107
return 0 # default return 0 as false
108108

109109

0 commit comments

Comments
 (0)