Skip to content

Commit

Permalink
TODO: keyword removed to avoid deprecated tox trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
cavearr committed Apr 22, 2024
1 parent 7083616 commit 6ca3ce2
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions apio/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def create_ini(self, board, top_module, project_dir="", sayyes=False):
# -- Create the apio.ini from scratch
self._create_ini_file(board, top_module, ini_path, PROJECT_FILENAME)

# TODO: Deprecate prgramatic mutations of apio.ini
# TODO- Deprecate prgramatic mutations of apio.ini
def update_ini(self, top_module, project_dir):
"""Update the current init file with the given top-module"""

Expand Down Expand Up @@ -208,17 +208,18 @@ def read(self):

if "env" not in config_parser.sections():
message = (
f"Project file {PROJECT_FILENAME}"
f"does not have an [env] section."
)
f"Project file {PROJECT_FILENAME}"
f"does not have an [env] section."
)
print(message)
sys.exit(1)

# Parse attributes in the env section.
parsed_attributes = set()
self.board = self._parse_board(config_parser, parsed_attributes)
self.top_module = self._parse_top_module(config_parser,
parsed_attributes)
self.top_module = self._parse_top_module(
config_parser, parsed_attributes
)
self.exe_mode = self._parse_exe_mode(config_parser, parsed_attributes)

# Verify that the project file (api.ini) doesn't contain additional
Expand All @@ -228,13 +229,14 @@ def read(self):
message = (
f"Project file {PROJECT_FILENAME} contains"
f" an unknown attribute '{attribute}'."
)
)
print(message)
sys.exit(1)

@staticmethod
def _parse_board(config_parser: ConfigParser,
parsed_attributes: set[str]) -> str:
def _parse_board(
config_parser: ConfigParser, parsed_attributes: set[str]
) -> str:
"""Parse the configured board from the project
file parser and add the keys used
to parsed_attributes.
Expand All @@ -250,8 +252,9 @@ def _parse_board(config_parser: ConfigParser,
return board

@staticmethod
def _parse_top_module(config_parser: ConfigParser,
parsed_attributes: set[str]) -> str:
def _parse_top_module(
config_parser: ConfigParser, parsed_attributes: set[str]
) -> str:
"""Read the configured top-module from the project file
parser and add the keys used
to parsed_attributes.
Expand All @@ -261,15 +264,18 @@ def _parse_top_module(config_parser: ConfigParser,
parsed_attributes.add("top-module")
top_module = config_parser.get("env", "top-module")
if not top_module:
click.secho(f"Warning! invalid {PROJECT_FILENAME} "
f"project file", fg="yellow")
click.secho(
f"Warning! invalid {PROJECT_FILENAME} " f"project file",
fg="yellow",
)
click.secho("No 'top-module' in [env] section. Assuming 'main'.")
return 'main'
return "main"
return top_module

@staticmethod
def _parse_exe_mode(config_parser: ConfigParser,
parsed_attributes: set[str]) -> str:
def _parse_exe_mode(
config_parser: ConfigParser, parsed_attributes: set[str]
) -> str:
"""Read the configured exe mode from the
project file parser and add the keys used
to parsed_attributes.
Expand All @@ -280,9 +286,10 @@ def _parse_exe_mode(config_parser: ConfigParser,
parsed_attributes.add("exe-mode")
exe_mode = config_parser.get("env", "exe-mode", fallback="default")
if exe_mode not in {"default", "native"}:
print(f"Error: invalid {PROJECT_FILENAME}"
"project file")
print("Optional attribute 'exe-mode' should have"
" the value 'default' or 'native'.")
print(f"Error: invalid {PROJECT_FILENAME}" "project file")
print(
"Optional attribute 'exe-mode' should have"
" the value 'default' or 'native'."
)
sys.exit(1)
return exe_mode

0 comments on commit 6ca3ce2

Please sign in to comment.