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])
return desc
def getinfo(path):
def getinfo(path,options):
''' Read info.txt file and returns the content.
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 ''
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')
def crumblinks(crumbs,title,parent):
@@ -410,7 +410,7 @@ def traverse(path,crumbs,inputs,options):
f.write(filejs)
f.write(crumbstring)
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(imagestring)
f.write(filestring)
@@ -440,6 +440,8 @@ def setupoptions():
help="Sort by file modification time")
parser.add_argument("-a",action="store_false",dest="attachments",default=True,
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",
help="Name for the root gallery (Default: %(default)s)")
parser.add_argument("-w",type=int,dest="width",default=850,
@@ -461,6 +463,8 @@ def setupdefaultoptions(options):
options.clean=False
if 'force' not in options:
options.force=False
if 'infofile' not in options:
options.infofile="info.txt"
if 'gallery' not in options:
options.gallery="Gallery"
if 'link' not in options: