reorganization, and output filename for SimpleWeb

This commit is contained in:
q
2015-12-20 12:31:29 +02:00
parent 810d485755
commit 9869257aaa
18 changed files with 16 additions and 15 deletions

View File

@@ -1 +1 @@
../FolderFlat ../files/FolderFlat

View File

@@ -1 +1 @@
../FolderSplit.py ../files/FolderSplit.py

View File

@@ -1 +1 @@
../reporting/diskfree-tracker ../files/diskfree-tracker

View File

@@ -1 +1 @@
../file_list.py ../files/file_list.py

View File

@@ -1 +1 @@
../fimplate.py ../files/fimplate.py

View File

@@ -1 +1 @@
../image_list.py ../files/image_list.py

View File

@@ -1 +1 @@
../mvregex ../files/mvregex

View File

@@ -1 +1 @@
../rm_bg ../files/rm_bg

View File

View File

@@ -1,22 +1,23 @@
#!/usr/bin/python #!/usr/bin/python
# coding=utf-8 # coding=utf-8
''' A script that creates index.html indexes for a folder. ''' A script that creates an index for a folder.
''' '''
import os,sys,time import os,sys,time
import urllib import urllib
INDEXFILE='index.html'
def setup(): def setup():
''' Setup the command line options ''' ''' Setup the command line options '''
from argparse import ArgumentParser from argparse import ArgumentParser
parser=ArgumentParser() parser=ArgumentParser()
parser.add_argument("-f",action="store_true",dest="overwrite",default=False, parser.add_argument("-f",action="store_true",dest="overwrite",default=False,
help="Overwrite existing "+INDEXFILE) help="Overwrite existing index file.")
parser.add_argument("-H",action="store_true",dest="hidden",default=False, parser.add_argument("-H",action="store_true",dest="hidden",default=False,
help="Show hidden files") help="Show hidden files")
parser.add_argument("-t",type=str,dest="title",default=None, parser.add_argument("-t",type=str,dest="title",default=None,
help="Name for the title (Default: Folder name)") help="Name for the title (Default: Folder name)")
parser.add_argument("-o",type=str,dest="filename",default="index.html",
help="Output filename (Default: index.html)")
parser.add_argument("-p",action="store_false",dest="parent",default=True, parser.add_argument("-p",action="store_false",dest="parent",default=True,
help="Do no print .. link for parent folder.") help="Do no print .. link for parent folder.")
parser.add_argument("startpath",type=str,action="store",default=os.path.abspath('.'),nargs='?', parser.add_argument("startpath",type=str,action="store",default=os.path.abspath('.'),nargs='?',
@@ -29,15 +30,15 @@ def setup():
def generate_index(opts): def generate_index(opts):
for path,dirs,files in os.walk(opts.startpath): for path,dirs,files in os.walk(opts.startpath):
if INDEXFILE in files: if opts.filename in files:
if not opts.overwrite: if not opts.overwrite:
print(INDEXFILE+" exists") print(opts.filename+" exists")
sys.exit(1) sys.exit(1)
files = [ f for f in files if f != INDEXFILE] files = [ f for f in files if f != opts.filename]
if not opts.hidden: if not opts.hidden:
files = [ f for f in files if not f.startswith(".")] files = [ f for f in files if not f.startswith(".")]
dirs = [ d for d in dirs if not d.startswith(".")] dirs = [ d for d in dirs if not d.startswith(".")]
f=open(os.path.join(path,INDEXFILE),'wt') f=open(os.path.join(path,opts.filename),'wt')
dirs.sort() dirs.sort()
files.sort() files.sort()
f.write(get_header(opts.title)) f.write(get_header(opts.title))