def main(*args): parser = argparse.ArgumentParser( description="Remove an entry from the login table", prog=__file__.split("/")[-1]) parser.add_argument("login_query", nargs="*", help='run "lazy --help-queries" for help with these') args = parser.parse_args(args) table_rows = read_login_table() queried_rows = query_table(args.login_query, table_rows) def modify_single_entry(table, index): table[index] = None def modify_multiple_entries(table): return None table_rows = user_modify_table( table_rows, queried_rows, MODULE_ACTION_VERB, modify_single_entry, modify_multiple_entries, ) write_login_table(table_rows)
def main(*args): parser = argparse.ArgumentParser( description='Remove an entry from the login table', prog=__file__.split("/")[-1]) parser.add_argument('login_query', nargs='*', help='run "lazy --help-queries" for help with these') parser.add_argument('-t', '--tags', nargs='+', help='tags to write to login entry') args = parser.parse_args(args) table_rows = read_login_table() queried_rows = query_table(args.login_query, table_rows) tags = args.tags if args.tags else get_tags_from_user_input() tags = standardize_tags(tags) def modify_single_entry(table, index): table[index][2] = tags def modify_multiple_entries(table): def modify_tags_if_match_login_query(row): if all([query in row for query in args.login_query]): row[2] = tags return list(map(modify_tags_if_match_login_query, table)) table_rows = user_modify_table(table_rows, queried_rows, MODULE_ACTION_VERB, modify_single_entry, modify_multiple_entries) write_login_table(table_rows)
def main(*args): parser = argparse.ArgumentParser( description='Remove an entry from the login table', prog=__file__.split("/")[-1]) parser.add_argument('login_query', nargs='*', help='run "lazy --help-queries" for help with these') args = parser.parse_args(args) table_rows = read_login_table() queried_rows = query_table(args.login_query, table_rows) def modify_single_entry(table, index): del table[index] def modify_multiple_entries(table): return list( filter( lambda row: not all( [query in row for query in args.login_query]), table)) table_rows = user_modify_table(table_rows, queried_rows, MODULE_ACTION_VERB, modify_single_entry, modify_multiple_entries, prompt_for_confirmation=True) write_login_table(table_rows)
def main(*args): parser = argparse.ArgumentParser( description='Remove an entry from the login table', prog=__file__.split("/")[-1]) parser.add_argument('tag', help='tag to add to login entry') parser.add_argument('login_query', nargs='*', help='run "lazy --help-queries" for help with these') args = parser.parse_args(args) table_rows = read_login_table() queried_rows = query_table(args.login_query, table_rows) def modify_single_entry(table, index): if args.tag not in table[index][2]: table[index][2] = add_tag_to_field(table[index][2], args.tag) def modify_multiple_entries(table): def modify_tags_if_match_login_query(row): if all([query in row for query in args.login_query]): row[2] = add_tag_to_field(row[2], args.tag) return list(map(modify_tags_if_match_login_query, table)) table_rows = user_modify_table(table_rows, queried_rows, MODULE_ACTION_VERB, modify_single_entry, modify_multiple_entries) write_login_table(table_rows)
def main(*args): parser = argparse.ArgumentParser( description="Add an entry into the login table", prog=__file__.split("/")[-1]) parser.add_argument( "platform", metavar="platform", nargs="?", help="platform for this login (e.g. spotify)", ) parser.add_argument( "login", metavar="login", nargs="?", help="username/email/identifier for this login", ) parser.add_argument("-t", "--tags", nargs="+", help="tags to help query this login quickly") parser.add_argument("-r", "--ruleset", nargs="?", help="custom ruleset for password generation") parser.add_argument( "-nc", "--no-confirm", nargs="?", help="don't prompt to confirm if the generated password works", ) args = parser.parse_args(args) table_rows = read_login_table() platform = input("Platform: ") if not args.platform else args.platform login = input("Login: "******"A login entry '{}' for platform '{}' already exists. Overwrite it? " "[y/n] ".format(login, platform)) if overwrite: del table_rows[i] break else: print("Aborting.") exit() tags = ", ".join(args.tags) if args.tags else "" if not args.ruleset: annoying_rules = user_input_answer( "Does this platform have specific password rules? (ex. no symbols) [y/n] " ) if annoying_rules: ruleset = ruleset_from_user_answers(1) else: ruleset = "luds.16" else: validate_ruleset(args.ruleset) ruleset = args.ruleset if not args.no_confirm: confirm = user_input_answer( "Would you like to ensure this login's password works, before adding it? " "[y/n] ") if confirm: works, password_generation_counter = False, 1 while not works: print("Try this password: "******"Did this password work? [y/n] ") if not works: password_generation_counter += 1 ruleset = ruleset_from_user_answers( password_generation_counter) table_rows.append([platform, login, tags, ruleset]) write_login_table(table_rows) print("Successfully created login '{}' for platform '{}'".format( login, platform))