summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Robinson <joe@lc8n.com>2020-11-08 15:20:07 +0000
committerJoe Robinson <joe@lc8n.com>2020-11-08 15:20:07 +0000
commitf3ef5e6f63baad99f61eef6c6d28eaba335263a9 (patch)
tree8755f7d10439119fa1df80c3e1c5f4431e14a6f0
parent0a7d38d339b4f1bc7c1dbb3297f8be4578fcdb70 (diff)
parent82f9ed3048e62452caa5afdb957cc1b7f950f5ab (diff)
Merge branch 'master' into 'master'
Upgrade to python3 and ignore the config in git See merge request CarpNet/saucypy!1
-rw-r--r--.gitignore1
-rwxr-xr-x[-rw-r--r--]saucypy28
2 files changed, 15 insertions, 14 deletions
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
index 42dd9f2..3ed0f9d 100644..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]])
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."
+ 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()