import sys import process_known_hosts import write_file def main(): # TODO: Handle errors # TODO: Add a switch for whether you want to include IPs with open(sys.argv[1], 'r') as f: try: known_host_entries = process_known_hosts.process_file(f) except Exception as err: print('Error: %s' % err, file=sys.stderr) sys.exit(1) # Convert to the entry format for .sshwot files entries = [] for known_hosts_entry in known_host_entries: entries.append(process_known_hosts.known_hosts_to_entry(known_hosts_entry)) # Write to stdout by default # TODO: Add a way to change it # We use sys.stdout.buffer instead of just sys.stdout because we # are writing binary data write_file.write(sys.stdout.buffer, entries) if __name__ == '__main__': main()