Przeglądaj źródła

Fix typo and naming format for extensions

Sergei Silnov 6 lat temu
rodzic
commit
5e6aae3e04

+ 3 - 3
tools/idf.py

@@ -593,8 +593,8 @@ def init_cli(verbose_output=None):
     all_actions = {}
     # Load extensions from components dir
     idf_py_extensions_path = os.path.join(os.environ["IDF_PATH"], "tools", "idf_py_actions")
-    extra_pathes = os.environ.get("IDF_EXTRA_ACTIONS_PATH", "").split(';')
-    extension_dirs = [idf_py_extensions_path] + extra_pathes
+    extra_paths = os.environ.get("IDF_EXTRA_ACTIONS_PATH", "").split(';')
+    extension_dirs = [idf_py_extensions_path] + extra_paths
     extensions = {}
 
     for directory in extension_dirs:
@@ -604,7 +604,7 @@ def init_cli(verbose_output=None):
 
         sys.path.append(directory)
         for _finder, name, _ispkg in sorted(iter_modules([directory])):
-            if name.startswith('idf_'):
+            if name.endswith('_ext'):
                 extensions[name] = import_module(name)
 
     for name, extension in extensions.items():

+ 2 - 1
tools/idf_py_actions/README.md

@@ -1,5 +1,6 @@
 # idf.py extensions
-Python modules (subdirectories and files) in this directory named `idf_[your_extension]` will be loaded as idf.py extensions.
+Python modules (subdirectories and files) in this directory named `[your_extension]_ext` will be loaded as idf.py extensions.
+If you want to provide extra extensions just provide `;` separated list of directories with extensions in  `IDF_EXTRA_ACTIONS_PATH`. Extensions will be loaded in alphanumeric order.
 Command line arguments parsing and extension mechanism is implemented on top of [Click](https://click.palletsprojects.com/en/5.x/) (versions >=5.0 are supported).
 
 They should define a function `action_extensions(base_actions, project_path)` where:

+ 0 - 0
tools/idf_py_actions/contstants.py → tools/idf_py_actions/constants.py


+ 1 - 1
tools/idf_py_actions/idf_01_core_actions.py → tools/idf_py_actions/core_ext.py

@@ -4,7 +4,7 @@ import sys
 
 import click
 
-from idf_py_actions.contstants import GENERATOR_CMDS, GENERATOR_VERBOSE, SUPPORTED_TARGETS
+from idf_py_actions.constants import GENERATOR_CMDS, GENERATOR_VERBOSE, SUPPORTED_TARGETS
 from idf_py_actions.errors import FatalError
 from idf_py_actions.global_options import global_options
 from idf_py_actions.tools import ensure_build_directory, idf_version, merge_action_lists, realpath, run_tool

+ 0 - 0
tools/idf_py_actions/idf_02_serial_actions.py → tools/idf_py_actions/serial_ext.py


+ 1 - 1
tools/idf_py_actions/tools.py

@@ -3,7 +3,7 @@ import re
 import subprocess
 import sys
 
-from .contstants import GENERATORS
+from .constants import GENERATORS
 from .errors import FatalError
 
 

+ 0 - 0
tools/test_idf_py/extra_path/idf_some_module.py → tools/test_idf_py/extra_path/some_ext.py


+ 0 - 0
tools/test_idf_py/test_idf_extensions/idf_test_extension/__init__.py → tools/test_idf_py/test_idf_extensions/test_ext/__init__.py


+ 0 - 0
tools/test_idf_py/test_idf_extensions/idf_test_extension/test_extension.py → tools/test_idf_py/test_idf_extensions/test_ext/test_extension.py


+ 2 - 2
tools/test_idf_py/test_idf_py.py

@@ -32,8 +32,8 @@ except ImportError:
 
 current_dir = os.path.dirname(os.path.realpath(__file__))
 idf_py_path = os.path.join(current_dir, '..', 'idf.py')
-extension_path = os.path.join(current_dir, 'test_idf_extensions', 'idf_test_extension')
-link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'idf_test_extension')
+extension_path = os.path.join(current_dir, 'test_idf_extensions', 'test_ext')
+link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'test_ext')
 
 
 class TestExtensions(unittest.TestCase):