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

30
main.py
View File

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

View File

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

View File

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