White space clean up and simplification of get_os_friendly_name.

This commit is contained in:
Heiko Joerg Schick
2023-09-05 20:43:08 +02:00
parent dece99ba87
commit 1567fb40ea
+12 -12
View File
@@ -116,13 +116,11 @@ def get_os_friendly_name():
os_name = platform.system()
if os_name == "Linux":
return "Linux/"+distro.name(pretty=True)
elif os_name == "Windows":
return os_name
os_name = "Linux/" + distro.name(pretty=True)
elif os_name == "Darwin":
return "Darwin/macOS"
else:
return os_name
os_name = "Darwin/macOS"
return os_name
def call_open_ai(config, shell, query):
"""
@@ -166,7 +164,9 @@ def check_for_markdown(response):
Odd corner case, sometimes ChatCompletion returns markdown
"""
if response.count("```",2):
print(colored("The proposed command contains markdown, so I did not execute the response directly: \n", 'red')+response)
print(colored(
"The proposed command contains markdown, response not executed directly: \n", 'red'
) + response)
sys.exit(-1)
def missing_posix_display():
@@ -229,21 +229,21 @@ def main():
parser = argparse.ArgumentParser(
description='AI bot that translates your question to a command.'
)
parser.add_argument('text', nargs='+',
parser.add_argument('text', nargs='+',
help='A sequence of strings')
parser.add_argument("-s", "--safety", action='store_true',
parser.add_argument("-s", "--safety", action='store_true',
help='Enable safety mode (only useful when safety is off)')
parser.add_argument("-c", "--config", action='store_true',
parser.add_argument("-c", "--config", action='store_true',
help='Print current configuration')
args = parser.parse_args()
user_prompt = " ".join(args.text)
ask_flag = args.safety
config = read_yaml_config()
set_openai_api_key(config)
if (args.config):
if args.config:
print_config(config)
# Unix based SHELL (/bin/bash, /bin/zsh), otherwise assuming it's Windows