From 0f873a2813ba9ab3996613f135686f9286aff5a0 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 8 Nov 2020 13:26:19 +0000 Subject: Add git ignore and fix for python3 --- .gitignore | 1 + saucypy | 0 2 files changed, 1 insertion(+) create mode 100644 .gitignore mode change 100644 => 100755 saucypy diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af9c753 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +saucypy.json diff --git a/saucypy b/saucypy old mode 100644 new mode 100755 -- cgit v1.2.3 From 1f78fbb8eb651472cd9056e9ec17282026fba4fc Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 8 Nov 2020 13:33:45 +0000 Subject: Fix filter() calls that need to return a list --- saucypy | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/saucypy b/saucypy index 42dd9f2..efe24c7 100755 --- a/saucypy +++ b/saucypy @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python import difflib import json @@ -28,7 +28,7 @@ def main(): options, args = parse_args() if options.version: - print VERSION + print (VERSION) sys.exit( 0 ) try: @@ -41,36 +41,36 @@ def main(): entries[key] = value matches = find( key, entries ) if len( matches ) > 1: - exact_match = filter( lambda x: x == key, matches ) + exact_match = list(filter( lambda x: x == key, matches)) if exact_match: - print "There is already an item named " + key + print ("There is already an item named " + key) else: json.dump( entries, open( ENTRIES_FILE, "w" ), indent = 4, sort_keys = True ) - print key + ": " + value + " added" + print (key + ": " + value + " added") elif options.count: - print "Entries: {0}".format( len( entries.keys() ) ) + print ("Entries: {0}".format( len( entries.keys() ) )) else: if not args: - print "Expected a search argument, got nothing." + print ("Expected a search argument, got nothing.") sys.exit( 1 ) matches = find( args[0], entries ) if len( matches ) > 1: - exact_match = filter( lambda x: x == args[0], matches ) + exact_match = list(filter( lambda x: x == args[0], matches)) if exact_match: - print entries[exact_match[0]].encode("utf-8") + print (entries[exact_match[0]].encode("utf-8")) elif options.index is not None: try: - print entries[matches[options.index]].encode("utf-8") + print (entries[matches[options.index]].encode("utf-8")) except IndexError: - print "Match index out of range." + print ("Match index out of range.") sys.exit( 1 ) else: - print "Matches (use -i option to pick one) -> {0}".format( ", ".join( "{0}: {1}".format( i, m ) for i, m in enumerate( matches ) ) ) + print ("Matches (use -i option to pick one) -> {0}".format( ", ".join( "{0}: {1}".format( i, m ) for i, m in enumerate( matches ) ) )) elif matches: - print entries[matches[0]] + print (entries[matches[0]]) else: - print "No match found." + print ("No match found.") if __name__ == "__main__": main() -- cgit v1.2.3 From 82f9ed3048e62452caa5afdb957cc1b7f950f5ab Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 8 Nov 2020 13:37:31 +0000 Subject: Stop encoding --- saucypy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/saucypy b/saucypy index efe24c7..3ed0f9d 100755 --- a/saucypy +++ b/saucypy @@ -58,10 +58,10 @@ def main(): if len( matches ) > 1: exact_match = list(filter( lambda x: x == args[0], matches)) if exact_match: - print (entries[exact_match[0]].encode("utf-8")) + print (entries[exact_match[0]]) elif options.index is not None: try: - print (entries[matches[options.index]].encode("utf-8")) + print (entries[matches[options.index]]) except IndexError: print ("Match index out of range.") sys.exit( 1 ) -- cgit v1.2.3