Added option to use variable info file

This commit is contained in:
q
2013-07-07 12:13:53 +03:00
parent e1b5ac679b
commit 2a8c1e6c6c

View File

@@ -310,12 +310,12 @@ def getdescriptions(path,list):
desc[i]=stripquotes.sub('',row[1]) desc[i]=stripquotes.sub('',row[1])
return desc return desc
def getinfo(path): def getinfo(path,options):
''' Read info.txt file and returns the content. ''' Read info.txt file and returns the content.
Missing info file returns empty string. ''' Missing info file returns empty string. '''
if not os.path.exists(os.path.join(path,'info.txt')): if not os.path.exists(os.path.join(path,options.infofile)):
return '' return ''
reader = open(os.path.join(path,'info.txt'),'r') reader = open(os.path.join(path,options.infofile),'r')
return unicode(reader.read(),encoding="utf8",errors="ignore").encode('ascii','xmlcharrefreplace') return unicode(reader.read(),encoding="utf8",errors="ignore").encode('ascii','xmlcharrefreplace')
def crumblinks(crumbs,title,parent): def crumblinks(crumbs,title,parent):
@@ -410,7 +410,7 @@ def traverse(path,crumbs,inputs,options):
f.write(filejs) f.write(filejs)
f.write(crumbstring) f.write(crumbstring)
f.write(pathstring) f.write(pathstring)
f.write('<div id="imagecontainer">'+getinfo(path)+'</div>') f.write('<div id="imagecontainer">'+getinfo(path,options)+'</div>')
f.write('<div id="desccontainer"></div>') f.write('<div id="desccontainer"></div>')
f.write(imagestring) f.write(imagestring)
f.write(filestring) f.write(filestring)
@@ -440,6 +440,8 @@ def setupoptions():
help="Sort by file modification time") help="Sort by file modification time")
parser.add_argument("-a",action="store_false",dest="attachments",default=True, parser.add_argument("-a",action="store_false",dest="attachments",default=True,
help="Disable attachments") help="Disable attachments")
parser.add_argument("-i",type=str,dest="infofile",default="info.txt",
help="File name for info files in all folders. (Default: %(default)s)")
parser.add_argument("-g",type=str,dest="gallery",default="Gallery", parser.add_argument("-g",type=str,dest="gallery",default="Gallery",
help="Name for the root gallery (Default: %(default)s)") help="Name for the root gallery (Default: %(default)s)")
parser.add_argument("-w",type=int,dest="width",default=850, parser.add_argument("-w",type=int,dest="width",default=850,
@@ -461,6 +463,8 @@ def setupdefaultoptions(options):
options.clean=False options.clean=False
if 'force' not in options: if 'force' not in options:
options.force=False options.force=False
if 'infofile' not in options:
options.infofile="info.txt"
if 'gallery' not in options: if 'gallery' not in options:
options.gallery="Gallery" options.gallery="Gallery"
if 'link' not in options: if 'link' not in options: