#!/usr/bin/env python # -*- coding: utf-8 -*- # Import the code needed to manage files. import os #...for parsing the arguments. import argparse #...for the logging. import logging as lg # Import the JSON library. import json if __name__ == "__main__": print("*") print("*==================================*") print("* CERN@school - cluster page maker *") print("*==================================*") # Get the datafile path from the command line parser = argparse.ArgumentParser() parser.add_argument("inputPath", help="Path to the JSON file describing the clusters.") #parser.add_argument("outputPath", help="The path for the output files.") parser.add_argument("-v", "--verbose", help="Increase output verbosity", action="store_true") args = parser.parse_args() ## The path to the data file. inputpath = args.inputPath # Set the logging level to DEBUG. if args.verbose: level=lg.DEBUG else: level=lg.INFO # Configure the logging. lg.basicConfig(filename='log_pagemaker.txt', filemode='w', level=level) print("*") print("* Input path : '%s'" % (inputpath)) print("*") ## The kluster JSON filename. jfname = inputpath + "/klusters.json" if not os.path.exists(jfname): raise IOError("NO_EXIST") exit() ## The JSON filename. jf = open(jfname, "r") ## The JSON data. jd = json.load(jf) jf.close() #print json.dumps(jd, indent=4) s = "" s += "\n" s += "\n" s += "
\n" s += "Radius | %6.2f | \n" % (kl['radius_uw']) s += "
Size | %d | \n" % (kl['size']) s += "
On the edge? | %s | \n" % (kl['isedgekluster']) s += "