Skip to content

Commit

Permalink
Merge pull request #421 from zapta/develop
Browse files Browse the repository at this point in the history
Deleted the command 'apio init'.
  • Loading branch information
Obijuan authored Sep 23, 2024
2 parents fb1b0e0 + 4991ef7 commit 7771131
Show file tree
Hide file tree
Showing 32 changed files with 39 additions and 404 deletions.
11 changes: 0 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@
//-- Testing the Blackice
"cwd": "${workspaceFolder}/test-examples/BlackIce/01-LEDs-buttons"
},
{
"name": "Apio init",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"args": ["init", "-s"],
"console": "internalConsole",
"justMyCode": true,
//-- Change to the folder with the example to test
"cwd": "${workspaceFolder}/test-examples/Alhambra-II/ledon"
},
{
"name": "Apio examples",
"type": "debugpy",
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ The command ``apio system -i`` (not released yet as of Sep 2024) shows the sourc
```
$ apio system -i
Platform: darwin_arm64
Source: /Users/user/projects/apio_dev/repo/apio
Package: /Users/user/projects/apio_dev/repo/apio
```
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ lint: ## Lint and static-check
lint-test: ### Lint test scripts
python -m pylint test/conftest.py
python -m pylint test/test_apio.py
python -m pylint test/code_commands/test_build.py
python -m pylint test/commands/test_build.py

test-one: ## Execute a test script
pytest -v -s test/code_commands/test_build.py::test_build_complete1
pytest -v -s test/commands/test_build.py::test_build_complete1

tox: ## Run tox
python -m tox
Expand All @@ -40,4 +40,4 @@ install: ## Install the tool locally
flit install

tests: ## Execute ALL the tests
pytest apio test
pytest apio test
2 changes: 1 addition & 1 deletion apio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def reformat_apio_help(original_help: str) -> str:
# -- Select setup commands by the order they are listed here.
setup_help = select_commands_help(
command_lines,
["create", "modify", "drivers", "install", "uninstall", "init"],
["create", "modify", "drivers", "install", "uninstall"],
)

# -- Select utility commands by the order they are listed here.
Expand Down
3 changes: 2 additions & 1 deletion apio/commands/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
\b
Examples:
apio example --list # List all examples
apio example -f icezum/leds # Fetch example files
apio example -s icezum/leds # Fetch example directory
apio examples -d icezum # Fetch all board examples
apio examples -d icezum/leds # Fetch a single board example
"""


Expand Down
94 changes: 0 additions & 94 deletions apio/commands/init.py

This file was deleted.

4 changes: 2 additions & 2 deletions apio/managers/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def process_arguments(
"Option 1: Pass it as a parameter\n"
" `--top-module <top module name>`\n\n"
"Option 2: Insert in the ini file\n"
" `apio init --top-module <top-module>`\n",
" `apio modify --top-module <top-module>`\n",
fg="yellow",
)

Expand Down Expand Up @@ -363,7 +363,7 @@ def perror_insuficient_arguments():
" 2) Specify the directory of a project with an apio.ini file\n"
" `--project-dir <projectdir>\n"
" 3) Create a project file apio.ini manually or using\n"
" `apio init --board <boardname>`\n"
" `apio create --board <boardname>`\n"
" 4) Execute your command with the flag\n"
" `--board <boardname>`",
fg="yellow",
Expand Down
19 changes: 9 additions & 10 deletions apio/managers/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
# -- Error messages
EXAMPLE_NOT_FOUND_MSG = """
Warning: this example does not exist
Use `apio examples -l` for listing all the available examples"""
Use `apio examples -l` to list all the available examples"""

USAGE_EXAMPLE = """
To fetch example files:
apio examples -f example-name
EXAMPLE_OF_USE_CAD = """
Example of use:
apio examples -f icezum/leds
Copy the leds example files to the current directory\n"""
apio examples -f icesum/leds
EXAMPLE_DIR_FILE = """
To get an example, use the command:
apio examples -d/-f name"""
Type 'apio examples -h' for more details.
"""


class Examples:
Expand Down Expand Up @@ -129,9 +130,7 @@ def list_examples(self):
click.secho(f"Total: {len(examples)}")

# -- Print more info about the examples
click.secho(EXAMPLE_DIR_FILE, fg="green")
click.secho(EXAMPLE_OF_USE_CAD, fg="green")
click.secho()
click.secho(USAGE_EXAMPLE, fg="green")
return 0

def copy_example_dir(self, example: str, project_dir: Path, sayno: bool):
Expand Down
142 changes: 0 additions & 142 deletions apio/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,78 +39,6 @@ def __init__(self, project_dir: Path):
self.top_module: str = None
self.native_exe_mode: bool = None

def create_sconstruct_deprecated(self, arch=None, sayyes=False):
"""Creates a default SConstruct file"""

sconstruct_name = "SConstruct"
sconstruct_path = self.project_dir / sconstruct_name
local_sconstruct_path = (
util.get_path_in_apio_package("resources") / arch / sconstruct_name
)

if sconstruct_path.exists():
# -- If sayyes, skip the question
if sayyes:
self._copy_sconstruct_file_deprecated(
sconstruct_name,
sconstruct_path,
local_sconstruct_path,
)
else:
click.secho(
f"Warning: {sconstruct_name} file already exists",
fg="yellow",
)

if click.confirm("Do you want to replace it?"):
self._copy_sconstruct_file_deprecated(
sconstruct_name,
sconstruct_path,
local_sconstruct_path,
)
else:
click.secho("Abort!", fg="red")

else:
self._copy_sconstruct_file_deprecated(
sconstruct_name, sconstruct_path, local_sconstruct_path
)

def create_ini_deprecated(self, board, top_module, sayyes=False):
"""Creates a new apio project file"""

# -- Build the filename
ini_path = self.project_dir / PROJECT_FILENAME

# Check board
boards = Resources().boards
if board not in boards.keys():
click.secho(f"Error: no such board '{board}'", fg="red")
sys.exit(1)

# -- The apio.ini file already exists...
if ini_path.is_file():

# -- Warn the user, unless the flag sayyes is active
if not sayyes:
click.secho(
f"Warning: {PROJECT_FILENAME} file already exists",
fg="yellow",
)

# -- Ask for confirmation
replace = click.confirm("Do you want to replace it?")

# -- User say: NO! --> Abort
if not replace:
click.secho("Abort!", fg="red")
return

# -- Create the apio.ini from scratch
self._create_ini_file_deprecated(
board, top_module, ini_path, PROJECT_FILENAME
)

@staticmethod
def create_ini(project_dir, board, top_module, sayyes=False) -> bool:
"""Creates a new apio project file. Returns True if ok."""
Expand Down Expand Up @@ -157,38 +85,6 @@ def create_ini(project_dir, board, top_module, sayyes=False) -> bool:
)
return True

def update_ini_deprecated(self, top_module):
"""Update the current init file with the given top-module"""

# -- Build the filename
ini_path = self.project_dir / PROJECT_FILENAME

# -- Check if the apio.ini file exists
if not ini_path.is_file():
click.secho(
"No apio.ini file. You should first create it:\n"
" apio init --board <boardname>\n",
fg="red",
)
return

# -- Read the current apio.ini file
config = ConfigParser()
config.read(ini_path)

# -- Set the new top-mddule
self.top_module = top_module
config.set("env", "top-module", top_module)

# -- Write the apio ini file
with open(ini_path, "w", encoding="utf-8") as inifile:
config.write(inifile)

click.secho(
f"File '{PROJECT_FILENAME}' has been successfully updated!",
fg="green",
)

@staticmethod
def modify_ini_file(
project_dir: Path, board: Optional[str], top_module: Optional[str]
Expand Down Expand Up @@ -239,44 +135,6 @@ def modify_ini_file(
)
return True

@staticmethod
def _create_ini_file_deprecated(board, top_module, ini_path, ini_name):
click.secho(f"Creating {ini_name} file ...")
with open(ini_path, "w", encoding="utf8") as file:
config = ConfigParser()
config.add_section("env")

# Set the required attributes.
config.set("env", "board", board)
config.set("env", "top-module", top_module)

# -- Write the apio ini file
config.write(file)
click.secho(
f"File '{ini_name}' has been successfully created!",
fg="green",
)

@staticmethod
def _copy_sconstruct_file_deprecated(
sconstruct_name, sconstruct_path, local_sconstruct_path
):
click.secho(f"Creating {sconstruct_name} file ...")

# -- Define the target sconstruct file to create
with sconstruct_path.open(mode="w", encoding="utf8") as sconstruct:
# -- Open the original sconstruct file
with local_sconstruct_path.open(
encoding="utf8"
) as local_sconstruct:
# -- Copy the src to the target file
sconstruct.write(local_sconstruct.read())

click.secho(
f"File '{sconstruct_name}' has been successfully created!",
fg="green",
)

def read(self):
"""Read the project config file"""

Expand Down
6 changes: 3 additions & 3 deletions apio/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

# -- Info message
BOARDS_MSG = (
"""
Use `apio init --board <boardname>` to create a new apio """
"""project for that board\n"""
"\nUse `apio create --board <boardname>` to create a new apio "
"project for that board\n"
)


# ---------- RESOURCES
RESOURCES_DIR = "resources"
# ---------------------------------------
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7771131

Please sign in to comment.