Support Python versions from 3.8 to 3.12 & change inquirer library

This commit is contained in:
EC2 Default User 2024-08-12 08:38:43 +00:00
parent df4b264145
commit 7cf3646cc0
3 changed files with 21 additions and 27 deletions

32
main.py
View File

@ -1,39 +1,33 @@
import json
from pprint import pprint
from PyInquirer import prompt, style_from_dict, Token
from InquirerLib import prompt
from InquirerLib.InquirerPy.utils import InquirerPyKeybindings
from InquirerLib.InquirerPy.base import Choice
from colorama import Style, Fore
from utils import *
import services
custom_style_2 = style_from_dict(
{
Token.Separator: "#6C6C6C",
Token.QuestionMark: "#FF9D00 bold",
# Token.Selected: '', # default
Token.Selected: "#5F819D",
Token.Pointer: "#FF9D00 bold",
Token.Instruction: "", # default
Token.Answer: "#5F819D bold",
Token.Question: "",
}
)
prompt_key_bindings: InquirerPyKeybindings = {
"toggle-all-true": [{"key": "a"}],
"toggle-all-false": [{"key": "A"}],
"toggle-all": [{"key": "i"}],
}
def ask_services_to_enable(bp):
cli_questions = [
{
"type": "checkbox",
"message": "Select AWS Services to inspect",
"message": "Select AWS Services to inspect.",
"name": "services",
"choices": [
{"name": k, "checked": bool(v["enabled"])} for k, v in bp.items()
Choice(service_name, enabled=bool(v["enabled"]))
for service_name, v in bp.items()
],
}
]
answers = prompt(questions=cli_questions, style=custom_style_2)
answers = prompt(questions=cli_questions, keybindings=prompt_key_bindings)
for service in bp.keys():
bp[service]["enabled"] = service in answers["services"]
return bp

View File

@ -1,7 +1,8 @@
from pydantic import BaseModel
from typing import List
class RuleCheckResult(BaseModel):
passed: bool
compliant_resources: list[str]
non_compliant_resources: list[str]
compliant_resources: List[str]
non_compliant_resources: List[str]

View File

@ -1,15 +1,14 @@
annotated-types==0.7.0
boto3==1.34.153
botocore==1.34.153
boto3==1.34.158
botocore==1.34.158
colorama==0.4.6
InquirerLib==0.0.2
jmespath==1.0.1
prompt-toolkit==1.0.14
pfzy==0.3.4
prompt_toolkit==3.0.47
pydantic==2.8.2
pydantic_core==2.20.1
Pygments==2.18.0
PyInquirer==1.0.3
python-dateutil==2.9.0.post0
regex==2024.7.24
s3transfer==0.10.2
six==1.16.0
typing_extensions==4.12.2