From 1567fb40ea138f55f2178cd877d92d753e8b6ce6 Mon Sep 17 00:00:00 2001 From: Heiko Joerg Schick Date: Tue, 5 Sep 2023 20:43:08 +0200 Subject: [PATCH] White space clean up and simplification of get_os_friendly_name. --- yolo.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/yolo.py b/yolo.py index 67bf8b0..01b8fd0 100755 --- a/yolo.py +++ b/yolo.py @@ -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