From 1aaa425da1673d372823dc912bedbeff0ea4424c Mon Sep 17 00:00:00 2001 From: Renato Alves Date: Thu, 17 Mar 2016 13:28:52 +0100 Subject: [PATCH] If only one profile exists, select it without prompting --- firefox_decrypt.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/firefox_decrypt.py b/firefox_decrypt.py index 6e676cd..c24d1eb 100755 --- a/firefox_decrypt.py +++ b/firefox_decrypt.py @@ -380,17 +380,23 @@ def ask_section(profiles): for section in profiles.sections(): if section.startswith("Profile"): sections[str(i)] = profiles.get(section, "Path") + i += 1 else: continue - i += 1 - choice = None - while choice not in sections: - sys.stderr.write("Select the Firefox profile you wish to decrypt\n") - for i in sorted(sections): - sys.stderr.write("{0} -> {1}\n".format(i, sections[i])) - sys.stderr.flush() - choice = raw_input("Choice: ") + # If only one menu entry exists, use it without prompting + if i == 2: + choice = "1" + + else: + choice = None + while choice not in sections: + sys.stderr.write("Select the Firefox profile you wish to decrypt\n") + for i in sorted(sections): + sys.stderr.write("{0} -> {1}\n".format(i, sections[i])) + sys.stderr.flush() + + choice = raw_input("Choice: ") final_choice = sections[choice] LOG.debug("Profile selection matched %s", final_choice)