Exemple #1
0
    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("incorrect number of arguments")
    target = args[0]
    target = os.path.abspath(target)
    if os.path.splitext(target)[1] == "":
        target_dir = target
        target = os.path.join(target, "index.html")
    else:
        target_dir = os.path.dirname(target)
    if not os.path.isdir(target_dir):
        os.makedirs(target_dir)
    params = {"target_dir": target_dir,
              "target": target,
              "title": options.title,
              "description": options.description,
              "copy_images": options.copy_images,
              "allthumbs": options.allthumbs,
              "thumbwidth": options.thumbwidth,
              "thumbheight": options.thumbheight,
              "packed": False,
              "paged": options.paged,
              "header_lines": options.header_lines,
              "sortable": False,
              "header": None}
    items = []
    for line in unicode_csv_reader(codecs.getreader('utf8')(sys.stdin), delimiter=" "):
        items.append(line)
    maker = WebpageMaker({"items": items, "params": params})
    maker.make()
Exemple #2
0
#!/usr/bin/env python

import sys, os
from webpagemaker import WebpageMaker

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print >> sys.stderr, "Usage: %s JSONFILE" % sys.argv[0]
        sys.exit(2)
    jsonfile = sys.argv[1]
    if not os.path.exists(jsonfile):
        print >> sys.stderr, "Missing json : %s" % jsonfile
        sys.exit(1)
    try:
        import ujson as json
    except ImportError:
        import json
    jsondata = json.load(open(jsonfile))
    maker = WebpageMaker(jsondata)
    urls = maker.make()
    jsonout = "%s_urls.json" % jsonfile.replace(".json", "")
    json.dump(urls, open(jsonout, "w"))
Exemple #3
0
    target = args[0]
    target = os.path.abspath(target)
    if os.path.splitext(target)[1] == "":
        target_dir = target
        target = os.path.join(target, "index.html")
    else:
        target_dir = os.path.dirname(target)
    if not os.path.isdir(target_dir):
        os.makedirs(target_dir)
    params = {
        "target_dir": target_dir,
        "target": target,
        "title": options.title,
        "description": options.description,
        "copy_images": options.copy_images,
        "allthumbs": options.allthumbs,
        "thumbwidth": options.thumbwidth,
        "thumbheight": options.thumbheight,
        "packed": False,
        "paged": options.paged,
        "header_lines": options.header_lines,
        "sortable": False,
        "header": None
    }
    items = []
    for line in unicode_csv_reader(codecs.getreader('utf8')(sys.stdin),
                                   delimiter=" "):
        items.append(line)
    maker = WebpageMaker({"items": items, "params": params})
    maker.make()
Exemple #4
0
#!/usr/bin/env python

import sys, os
from webpagemaker import WebpageMaker

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print >> sys.stderr, "Usage: %s JSONFILE" % sys.argv[0]
        sys.exit(2)
    jsonfile = sys.argv[1]
    if not os.path.exists(jsonfile):
        print >> sys.stderr, "Missing json : %s" % jsonfile
        sys.exit(1)
    try:
        import ujson as json
    except ImportError:
        import json
    jsondata = json.load(open(jsonfile))
    maker = WebpageMaker(jsondata, packing={'packed': True, 'pack_width': 842})
    maker.make()