From 8629d492f37c1a986cc2c0033bd1f1a16e48f80c Mon Sep 17 00:00:00 2001 From: q Date: Tue, 27 May 2014 19:44:27 +0300 Subject: [PATCH] fixing print command --- image_list.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/image_list.py b/image_list.py index 62426d4..607ea23 100755 --- a/image_list.py +++ b/image_list.py @@ -1,4 +1,5 @@ #!/usr/bin/python +from __future__ import print_function import sys import os import re @@ -48,7 +49,7 @@ def setup_options(): "RD AspectRatioDiff.,Shp SharpnessIndex.") parser.add_argument("--viewer",type=str,dest="viewer",default=None, help="Program to view images, %%f refers to filename(s)."+ - "If '1', defaults to: 'geeqie -l %f'") + "If '1', defaults to: 'geeqie -l %%f'") parser.add_argument("-x",action="append",dest="exclude",default=[], help="Exclude folder name from the lists. This option may be issued several times.") parser.add_argument('startpath', action="store",default='.', nargs='?') @@ -93,7 +94,7 @@ def delete_files(files): print("now delling") for hash in files: for f in hash[1]: - print f[0] + print(f[0]) os.remove(f[0]) return @@ -152,11 +153,11 @@ def add_single(conn,filename,change=False,hash=None,minsize=0): if change: db.execute("UPDATE list SET date=?, portrait=?, hash=?, width=? ,height=? \ WHERE file=?",(ftime,portrait,hash,dims[0],dims[1],filename)) - print "changing: %(f)s (%(x)sx%(y)s)" % {'f':filename, 'x':dims[0], 'y':dims[1]} + print("changing: %(f)s (%(x)sx%(y)s)" % {'f':filename, 'x':dims[0], 'y':dims[1]}) else: db.execute("INSERT INTO list(file,date,portrait,hash,width,height)\ VALUES(?,?,?,?,?,?)",(filename,ftime,portrait,hash,dims[0],dims[1])) - print "adding: %(f)s (%(x)sx%(y)s)" % {'f':filename, 'x':dims[0], 'y':dims[1]} + print("adding: %(f)s (%(x)sx%(y)s)" % {'f':filename, 'x':dims[0], 'y':dims[1]}) return def random_lists(sqlfile): @@ -242,8 +243,8 @@ def append_colors(sqlfile): if dirname!=dirname_old: dirname_old=dirname filename=row[0] - print "colors: %(f)s (%(r)s %(g)s %(b)s)" % {'f':filename, 'r':colors[0][0], - 'g':colors[0][1], 'b':colors[0][2]} + print("colors: %(f)s (%(r)s %(g)s %(b)s)" % {'f':filename, 'r':colors[0][0], + 'g':colors[0][1], 'b':colors[0][2]}) i+=1 if (i%50==0): conn.commit(); @@ -370,7 +371,7 @@ def append_fingerprints(sqlfile): dirname_old=dirname filename=row[0] i+=1 - print "%(nr)i %(f)s" % {'f':filename, 'nr':i} + print("%(nr)i %(f)s" % {'f':filename, 'nr':i}) if (i%50==0): conn.commit(); conn.commit() @@ -489,7 +490,7 @@ def find_fingerprint_nearest(opts): print("No measurements found") sys.exit(1) if this[1]==thr: - print("No similar images for "+cmp+", up to threshold "+str(thr)) + print("No similar images for "+cmp+", up to threshold "+str(thr), file=sys.stderr) return file_len=str(max(len(cmp), len(this[0]))) print( ('{: <'+file_len+'} {: ^4} {: ^4} {: ^4} {: ^4} {: ^5}x{: ^5}').format("File","SD","CD","RD","Shp","W","H")) @@ -520,7 +521,7 @@ def append_sharpness(sqlfile): dirname_old=dirname filename=row[0] i+=1 - print "%(nr)i %(f)s %(s)f" % {'f':filename, 'nr':i,'s':sp} + print("%(nr)i %(f)s %(s)f" % {'f':filename, 'nr':i,'s':sp}) if (i%50==0): conn.commit(); conn.commit() @@ -585,7 +586,7 @@ def confirm(prompt=None, resp=False): if not ans: return resp if ans not in ['y', 'Y', 'n', 'N']: - print 'please enter y or n.' + print('please enter y or n.') continue if ans == 'y' or ans == 'Y': return True @@ -631,7 +632,7 @@ def print_structure(files): #print(hash[0]) i=1 for f in hash[1]: - print "%(i)d: (%(x)dx%(y)d):%(f)s " % {'i':i, 'f':f[0], 'x':f[1], 'y':f[2]} + print("%(i)d: (%(x)dx%(y)d):%(f)s " % {'i':i, 'f':f[0], 'x':f[1], 'y':f[2]}) i+=1 return @@ -642,7 +643,7 @@ def print_dup_structure(files,opts): fnames=[] for f in hash[1]: fnames.append(' "'+f[0]+'"') - print "%(i)d:%(n)d:%(f)s " % {'i':i, 'n':len(fnames), 'f':",".join(fnames)} + print("%(i)d:%(n)d:%(f)s " % {'i':i, 'n':len(fnames), 'f':",".join(fnames)}) if opts.viewer: fnames=[x[0] for x in hash[1]] subprocess.call(opts.viewer.replace('%f', " ".join(fnames)), shell=True)