mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-07-18 22:44:24 +02:00
Restructured CLI meta commands
This commit is contained in:
parent
80ca12938b
commit
3eb8b54a1a
0
cli/meta/applications/__init__.py
Normal file
0
cli/meta/applications/__init__.py
Normal file
@ -6,8 +6,6 @@ This script determines the appropriate Ansible role folder based on the provided
|
|||||||
by inspecting each role's vars/main.yml within the roles directory. By default, it assumes the
|
by inspecting each role's vars/main.yml within the roles directory. By default, it assumes the
|
||||||
roles directory is located at the project root, relative to this script's location.
|
roles directory is located at the project root, relative to this script's location.
|
||||||
|
|
||||||
Example:
|
|
||||||
./get_role_folder_cli.py --application-id my-app-id
|
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -55,7 +53,7 @@ def main():
|
|||||||
'-r', '--roles-path',
|
'-r', '--roles-path',
|
||||||
default=os.path.join(
|
default=os.path.join(
|
||||||
os.path.dirname(os.path.realpath(__file__)),
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
os.pardir, os.pardir,
|
os.pardir, os.pardir, os.pardir,
|
||||||
'roles'
|
'roles'
|
||||||
),
|
),
|
||||||
help='Path to the roles directory (default: roles/ at project root)'
|
help='Path to the roles directory (default: roles/ at project root)'
|
@ -10,7 +10,7 @@ script_dir = Path(__file__).resolve().parent
|
|||||||
repo_root = script_dir.parent.parent
|
repo_root = script_dir.parent.parent
|
||||||
sys.path.insert(0, str(repo_root))
|
sys.path.insert(0, str(repo_root))
|
||||||
|
|
||||||
from cli.meta.applications import find_application_ids
|
from cli.meta.applications.all import find_application_ids
|
||||||
|
|
||||||
def load_yaml_file(path):
|
def load_yaml_file(path):
|
||||||
try:
|
try:
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
from cli.meta.applications import find_application_ids
|
from cli.meta.applications.all import find_application_ids
|
||||||
|
|
||||||
# ensure project root is on PYTHONPATH so we can import your CLI code
|
# ensure project root is on PYTHONPATH so we can import your CLI code
|
||||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
|
||||||
|
@ -2,7 +2,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import unittest
|
import unittest
|
||||||
from cli.meta.applications import find_application_ids
|
from cli.meta.applications.all import find_application_ids
|
||||||
|
|
||||||
# ensure project root is on PYTHONPATH so we can import the CLI code
|
# ensure project root is on PYTHONPATH so we can import the CLI code
|
||||||
# project root is two levels up from this file (tests/integration -> project root)
|
# project root is two levels up from this file (tests/integration -> project root)
|
||||||
@ -53,6 +53,18 @@ class TestValidApplicationUsage(unittest.TestCase):
|
|||||||
):
|
):
|
||||||
for match in pattern.finditer(content):
|
for match in pattern.finditer(content):
|
||||||
name = match.group('name')
|
name = match.group('name')
|
||||||
|
for match in pattern.finditer(content):
|
||||||
|
# Determine the full line containing this match
|
||||||
|
start = match.start()
|
||||||
|
line_start = content.rfind('\n', 0, start) + 1
|
||||||
|
line_end = content.find('\n', start)
|
||||||
|
line = content[line_start:line_end if line_end != -1 else None]
|
||||||
|
|
||||||
|
# Skip any import or from-import lines
|
||||||
|
if line.strip().startswith(('import ', 'from ')):
|
||||||
|
continue
|
||||||
|
|
||||||
|
name = match.group('name')
|
||||||
# skip whitelisted methods/exceptions
|
# skip whitelisted methods/exceptions
|
||||||
if name in self.WHITELIST:
|
if name in self.WHITELIST:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user