def generate_list(**kwargs):
    """
    :kwargs: startweight, exceptionals
    """
    list_of_exceptionals = []
    initial_strategy = Quasicone.Strategy.initial()

    for mu, quasicone in enumerate(Quasicone.Iterator.iterator()):
        # print 'list_of_exceptionals line 24', mu, '\n', quasicone
        new_instance = \
            Apply_strategy(quasicone, initial_strategy, startweight=kwargs['startweight'])
        #print 'new_instance', new_instance
        new_instance.enumerator.append(mu)
        _logger.debug('new_instance.successful: {} -> \n {}'.format(
            new_instance.successful, new_instance._C
        ))
        if new_instance.successful: pass # do nothing
        else: list_of_exceptionals.append(new_instance)

    from utils import to_file
    to_file(list_of_exceptionals, kwargs['exceptionals'])

    import TeX
    filename = 'quasicones_rank{}.tex'.format( str(Quasicone.Iterator.n - 1) )
    TeX.to_file(TeX.Quasicones_to_TeX(list_of_exceptionals), filename)
def generate_list(**kwargs):
    T = MapTree(**kwargs)
    T.run()
    #To_File(T.Tree)
    #Output_as_Graph(Tree_to_TeX(T.Tree))
    #print "len(MapTree.list_of_successful): ",  len(MapTree.list_of_successful)
    #print(T)


    count = 0
    list_of_unsolved = []
    for C_init in MapTree.list_of_C_init:
        #if C_init not in MapTree.list_of_successful:
            #if C_init not in list_of_unsolved:
        count += 1
        C = p.array(C_init)
        #print count, ". \n", C, " defect: ".ljust(9), Q.Defect(C)
        list_of_unsolved.append(C)

    #this part prints the tree as a graph
    #from Tree_to_TikZ_Graph import *
    #inputfile = "tree_for_graph_r4"
    #with open(inputfile, "r") as file: Tree = pickle.load(file)
    ##print(Tree)
    #print(Output_as_Graph(Tree_to_TeX(Tree)))


    list_of_unsolved_array = [p.array(C_init) for C_init in list_of_unsolved]
    #as file with Python-list

    from utils import to_file
    outputfile = 'unsolved_after_TreeMap.pi'
    to_file(list_of_unsolved_array, outputfile)

    #as TeX-formatted output
    import TeX
    filename = 'unsolved_after_TreeMap.tex'
    TeX.to_file(TeX.Quasicones_to_TeX(list_of_unsolved_array), filename)
import pickle
import sys
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-i", "--input", dest="input")
parser.add_option("-o", "--output", dest="output")
(options, args) = parser.parse_args()

inputfile = options.input
outputfile = options.output

if inputfile:
    file = open(inputfile, "r")
    in_list_of_Quasicones = pickle.load(file)
    file.close()

import TeX
TeX.to_file(TeX.Quasicones_to_TeX(in_list_of_Quasicones), outputfile)