python3 compatible, not python2 anymore
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2016 Ville Rantanen
|
||||
#
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
import sys,os
|
||||
import subprocess
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
from qalbum import Qalbum
|
||||
|
||||
# (c) ville.q.rantanen@gmail.com
|
||||
@@ -39,13 +39,14 @@ def createdesc(path,list,options):
|
||||
nsum=len(list)
|
||||
for i in list:
|
||||
inpath=os.path.join(path,i)
|
||||
desc=create_description(inpath,options.format).rstrip().replace('\n','<br/>')
|
||||
desc = create_description(inpath,options.format).decode('utf-8').rstrip().replace('\n','<br/>')
|
||||
outfile.write(i+"\t"+desc+'\n')
|
||||
outfile.flush()
|
||||
print('('+str(n)+'/'+str(nsum)+') '+i+"\t"+desc)
|
||||
n+=1
|
||||
return
|
||||
|
||||
|
||||
def create_description(infile,format):
|
||||
if format=='AbsolutelyEverything':
|
||||
idargs=['identify','-verbose',infile+'[0]']
|
||||
@@ -55,6 +56,7 @@ def create_description(infile,format):
|
||||
output = idp.stdout.read()
|
||||
return output
|
||||
|
||||
|
||||
def traverse(path,options):
|
||||
''' The recursive main function to create the thumbs and seek sub folders '''
|
||||
print(path)
|
||||
@@ -68,6 +70,7 @@ def traverse(path,options):
|
||||
traverse(os.path.join(path,p),options)
|
||||
return
|
||||
|
||||
|
||||
def execute():
|
||||
''' Main execution '''
|
||||
parser=ArgumentParser()
|
||||
@@ -75,7 +78,7 @@ def execute():
|
||||
parser.add_argument("-f",action="store_true",dest="force",default=False,
|
||||
help="Force rewriting of descriptions")
|
||||
parser.add_argument("--format",type=str,dest="format",default="",
|
||||
help="""Formatting string, see: http://www.imagemagick.org/script/escape.php.
|
||||
help="""Formatting string, see: http://www.imagemagick.org/script/escape.php.
|
||||
Setting this option will override the presets""")
|
||||
parser.add_argument("-r",action="store_true",dest="recursive",default=False,
|
||||
help="Recurse in to subfolders")
|
||||
@@ -92,20 +95,20 @@ def execute():
|
||||
'%f: %wx%h %[size]',
|
||||
'%f<br/><i>%[EXIF:DateTimeOriginal] %[EXIF:ExposureTime]s F%[EXIF:FNumber]</i>',
|
||||
'AbsolutelyEverything']
|
||||
if options.preset<1:
|
||||
print "Presets:"
|
||||
if options.preset < 1:
|
||||
print("Presets:")
|
||||
for row in range(len(presets)):
|
||||
print row+1," ",presets[row]
|
||||
print(row+1," ",presets[row])
|
||||
sys.exit(0)
|
||||
if options.format=="":
|
||||
if options.preset>len(presets):
|
||||
parser.error("No such preset, list with -p 0")
|
||||
options.format=presets[options.preset-1]
|
||||
|
||||
|
||||
traverse(options.startpath,options)
|
||||
return
|
||||
|
||||
execute()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright 2016 Ville Rantanen
|
||||
#
|
||||
@@ -16,7 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from qalbum import Qalbum
|
||||
from argparse import ArgumentParser
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
|
||||
# (c) ville.q.rantanen@gmail.com
|
||||
@@ -37,6 +37,7 @@ def traverse(path,options):
|
||||
traverse(os.path.join(path,p),options)
|
||||
return
|
||||
|
||||
|
||||
def setupoptions():
|
||||
''' Setup options '''
|
||||
usage='''Usage: %(prog)s [options] folder
|
||||
@@ -62,13 +63,15 @@ folder is the root folder of the image album (defaults to current folder).'''
|
||||
options=Qalbum.setupdefaultoptions(options)
|
||||
return options
|
||||
|
||||
|
||||
def execute():
|
||||
''' Main execution '''
|
||||
options=setupoptions()
|
||||
traverse(options.startpath,options)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
execute()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
Reference in New Issue
Block a user