# Path: nucio.py
# def lineItemIterator(fh, filter_func=trueFunc):
#     '''Takes a file handle and returns a list of the split line
#     Will also take a filter function to filter out lines before they
#     are split
#     '''
#     filtered = ifilter( filter_func, fh)
#     return imap(str.split, filtered)
# 
# def fileIterator(filename, itemIterator, open_func=open):
#     '''Handles the life cyle of a file,
#        The itemIterator will be passed the 
#        opened file handle
#     '''
#     with open_func(filename) as fh:
#         for item in itemIterator(fh):
#             yield item


import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
from itertools import imap
from matplotlib.backends.backend_pdf import PdfPages
from nucio import lineItemIterator, fileIterator
from args import parseArgs, getHelpStr, CLArgument
#!/usr/bin/env python


mpl.use('Agg')



description = ("Usage: plot_hist.py [options] input.txt\n\n"
               "Plot histograms from file (usually Jellyfish)\n"
               "First col is occ, second col is count\n")

argument_list = [
    ["minx","minx", int, 0,"minimum x axis value"],
    ["maxx", "maxx", int, -1,"maximum x axis value"],
    ["miny","miny", int, 0,"minimum y axis value"],
    ["maxy","maxy", int, -1,"maximmum y axis value"],
    ["out","out", str, "out.pdf", "output file name (default out.pdf)"],
    ["title","title", str, "", "Title for graph"]]

arguments = map(CLArgument._make, argument_list)

(p_args, args_remaining) = parseArgs(sys.argv[1:], arguments)

if not len(args_remaining) == 1:

# Path: nucio.py
# def lineItemIterator(fh, filter_func=trueFunc):
#     '''Takes a file handle and returns a list of the split line
#     Will also take a filter function to filter out lines before they
#     are split
#     '''
#     filtered = ifilter( filter_func, fh)
#     return imap(str.split, filtered)
# 
# def fileIterator(filename, itemIterator, open_func=open):
#     '''Handles the life cyle of a file,
#        The itemIterator will be passed the 
#        opened file handle
#     '''
#     with open_func(filename) as fh:
#         for item in itemIterator(fh):
#             yield item


# Path: plot_hist.py
import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
from itertools import imap
from matplotlib.backends.backend_pdf import PdfPages
from nucio import lineItemIterator, fileIterator
from args import parseArgs, getHelpStr, CLArgument

#!/usr/bin/env python


mpl.use('Agg')



description = ("Usage: plot_hist.py [options] input.txt\n\n"
               "Plot histograms from file (usually Jellyfish)\n"
               "First col is occ, second col is count\n")

argument_list = [
    ["minx","minx", int, 0,"minimum x axis value"],
    ["maxx", "maxx", int, -1,"maximum x axis value"],
    ["miny","miny", int, 0,"minimum y axis value"],
    ["maxy","maxy", int, -1,"maximmum y axis value"],
    ["out","out", str, "out.pdf", "output file name (default out.pdf)"],
    ["title","title", str, "", "Title for graph"]]

arguments = map(CLArgument._make, argument_list)

(p_args, args_remaining) = parseArgs(sys.argv[1:], arguments)

if not len(args_remaining) == 1:

    sys.exit(getHelpStr(description, arguments) + "\n")