示例#1
0
    def go(self, event=None):
        # 0. check for valid entries
        #    - exit if not happy
        #    - possibly share a reason with the user
        # 1. make subfolder
        # 2. create rst
        #    - creat title
        #    - create subtitle
        #    - add beamer handout header
        #    - add author
        #    - add learning outcomes slide
        subfolder = self.get_subfolder()
        print('subfolder = ' + subfolder)
        rp = self.root_folder_box.GetValue()
        path1 = os.path.join(self.get_course_dir(), rp)
        subfolder_path = os.path.join(path1, subfolder)
        if not os.path.exists(subfolder_path):
            os.mkdir(subfolder_path)

        course = self.get_course()
        rst_name = 'ME_%s_%s.rst' % (course, subfolder)
        print('rst_name = ' + rst_name)
        rst_path = os.path.join(subfolder_path, rst_name)
        print('rst_path = ' + rst_path)

        rst_list = self.build_rst()

        txt_mixin.dump(rst_path, rst_list)
def clean_csv(pathin):
    fno, ext = os.path.splitext(pathin)
    clean_path = fno + '_clean' + ext
    myfile = txt_mixin.txt_file_with_list(pathin)

    N = len(myfile.list)
    i = 0

    pat = re.compile('.*[;"]$')

    while i < (N-1):
        line = myfile.list[i]
        q = pat.match(line)
        if q is None :
            #this line needs to be merged with the next one down
            cur_line = myfile.list.pop(i)#retrieves line and removes it from the list
            next_line = myfile.list[i]#retrieve without removing
            new_line = cur_line.rstrip() + ' ' + next_line.lstrip()
            myfile.list[i] = new_line
            N = len(myfile.list)
        else:
            i += 1



    myfile.replaceallre('(;"")+$','')
    myfile.replaceallre('^""$','')
    clean_list = filter(None, myfile.list)
    txt_mixin.dump(clean_path, clean_list)
    return clean_path, clean_list
示例#3
0
def clean_csv(pathin):
    fno, ext = os.path.splitext(pathin)
    clean_path = fno + '_clean' + ext
    myfile = txt_mixin.txt_file_with_list(pathin)

    N = len(myfile.list)
    i = 0

    pat = re.compile('.*[;"]$')

    while i < (N - 1):
        line = myfile.list[i]
        q = pat.match(line)
        if q is None:
            #this line needs to be merged with the next one down
            cur_line = myfile.list.pop(
                i)  #retrieves line and removes it from the list
            next_line = myfile.list[i]  #retrieve without removing
            new_line = cur_line.rstrip() + ' ' + next_line.lstrip()
            myfile.list[i] = new_line
            N = len(myfile.list)
        else:
            i += 1

    myfile.replaceallre('(;"")+$', '')
    myfile.replaceallre('^""$', '')
    clean_list = filter(None, myfile.list)
    txt_mixin.dump(clean_path, clean_list)
    return clean_path, clean_list
def dumpcsv(nested_list, pathout):
    listout = []
    for row in nested_list:
        str_list = [str(item) for item in row]
        row_str = ','.join(str_list)
        listout.append(row_str)
    txt_mixin.dump(pathout, listout)
def gen_judges_csv(overwrite=False):
    if not os.path.exists(csvpath):
        os.mkdir(csvpath)
    number_of_judges = 6

    categories = ['Problem Statement', \
                  'Speaking and Delievery', \
                  'Conclusions', \
                  'Slide Quality', \
                  'Prototype Quality']

    for team_name in group_names:
        listout = [team_name]
        judges_list = ['""'] + ['"Judge %i"' % (item + 1) \
                             for item in range(number_of_judges)]
        judges_row = ','.join(judges_list)
        listout.append(judges_row)
        for item in categories:
            listout.append("%s," % item)
        filename = team_name.replace(' ','_') + '.csv'
        pathout = os.path.join(csvpath, filename)
        if (not os.path.exists(pathout)) or overwrite:
            txt_mixin.dump(pathout, listout)

    return listout
示例#6
0
    def to_maxima(self, filename=None):
        float_pat = re.compile('\.0+(?![0-9])')
        outlines = ['showtime:all$']
        out = outlines.append
        out('showtime:all$')
        out('nolabels:true$')
        out('grind:true$')

        for i, Ui in enumerate(self.Ui_list):
            Ui_sympy = sage_utils.sage_matrix_to_sympy(Ui)
            name = 'U%i' % i
            Ui_line = sympy_utils.matrix_to_Maxima_string(Ui_sympy,name)
            Ui_line_clean = float_pat.sub('',Ui_line)
            outlines.append(Ui_line_clean)

        Usys_line = self.Usys_Maxima()
        out(Usys_line)

        outlines.extend(maxima_bv)
        
        if filename is not None:
            import txt_mixin
            txt_mixin.dump(filename, outlines)

        return outlines
def dumpcsv(nested_list, pathout):
    listout = []
    for row in nested_list:
        str_list = [str(item) for item in row]
        row_str = ','.join(str_list)
        listout.append(row_str)
    txt_mixin.dump(pathout, listout)
示例#8
0
    def save(self, filename, freqvect, notes=[], delim=',', fmt='%0.15g'):
       """save freqvect, mag, dBmag, phase and possibly coh to a file.
       input and output labels will be added to begining of file.
       Notes will also be added with comment signs to the begining:

       #notes line 1
       #notes line 2
       #input:
       #output:
       """
       import txt_mixin   
       listout = []
       out = listout.append
       
       if notes:
          for line in notes:
             out('#' + line)

       out('#input: %s' % self.input)
       out('#output: %s' % self.output)

       mylabels = ['freq (Hz)', 'mag', 'dBmag', 'phase']
       data = numpy.column_stack([freqvect, self.mag, self.dBmag(), self.phase])
       big_list = txt_mixin.array_and_labels_to_spreadsheet_string(data, \
                                                                   delim=delim, \
                                                                   fmt=fmt, \
                                                                   labels=mylabels)
       listout.extend(big_list)
       txt_mixin.dump(filename, listout)
       return big_list
示例#9
0
 def to_Maxima(self, pathout, attrlist=['U0'], num_bodes=2, \
               base_mod_name='maxima_bode', ND=True, **kwargs):
     """Create a Maxima batch file for the system.  attrlist is a
     list of strings referring to the element matrices.  The
     elements of attrlist should be in order, starting with U0 and
     stopping at U_n."""
     #consider adding ratdenom and ratnumer
     mylist = txt_mixin.txt_list()
     out = mylist.append
     out('showtime:all$')
     out('nolabels:true$')
     #ratvars(mubz,EIbz,Lbz,abz,betabz,c1bz,c2bz,c3bz,c4bz,s)$
     out('grind:true$')
     for attr in attrlist:
         U = getattr(self, attr)
         Uline = sympy_utils.matrix_to_Maxima_string(U,attr)
         out(Uline)
     Usys_line = self.Usys_Maxima(attrlist)
     out(Usys_line)
     mylist.extend(maxima_bv)
     bode_lines = self.Maxima_bodes(ND=ND, **kwargs)
     mylist.extend(bode_lines)
     save_lines = self.save_Maxima_bodes_to_Fortran(num_bodes, \
                                                    base_mod_name, \
                                                    ND=ND)
     mylist.extend(save_lines)
     self.maxima_list = mylist
     txt_mixin.dump(pathout, mylist)
示例#10
0
def gen_judges_csv(overwrite=False):
    if not os.path.exists(csvpath):
        os.mkdir(csvpath)
    number_of_judges = 6

    categories = ['Problem Statement', \
                  'Speaking and Delievery', \
                  'Conclusions', \
                  'Slide Quality', \
                  'Prototype Quality']

    for team_name in group_names:
        listout = [team_name]
        judges_list = ['""'] + ['"Judge %i"' % (item + 1) \
                             for item in range(number_of_judges)]
        judges_row = ','.join(judges_list)
        listout.append(judges_row)
        for item in categories:
            listout.append("%s," % item)
        filename = team_name.replace(' ', '_') + '.csv'
        pathout = os.path.join(csvpath, filename)
        if (not os.path.exists(pathout)) or overwrite:
            txt_mixin.dump(pathout, listout)

    return listout
示例#11
0
    def go(self, event=None):
        # 0. check for valid entries
        #    - exit if not happy
        #    - possibly share a reason with the user
        # 1. make subfolder
        # 2. create rst
        #    - creat title
        #    - create subtitle
        #    - add beamer handout header
        #    - add author
        #    - add learning outcomes slide
        subfolder = self.get_subfolder()
        print('subfolder = ' + subfolder)
        rp = self.root_folder_box.GetValue()
        path1 = os.path.join(self.get_course_dir(), rp)
        subfolder_path = os.path.join(path1, subfolder)
        if not os.path.exists(subfolder_path):
            os.mkdir(subfolder_path)

        course = self.get_course()
        rst_name = 'ME_%s_%s.rst' % (course, subfolder)
        print('rst_name = ' + rst_name)
        rst_path = os.path.join(subfolder_path, rst_name)
        print('rst_path = ' + rst_path)

        rst_list = self.build_rst()

        txt_mixin.dump(rst_path, rst_list)
示例#12
0
 def process_all_rows(self):
     self.build_out_paths()
     rwkos.make_dir(self.folderout)
     
     for i in range(self.N):
         curlist = self.process_one_row(i)
         outpath = self.out_paths[i]
         txt_mixin.dump(outpath, curlist)
示例#13
0
 def create_one_rst(self, title='Outline'):
     #make this create only if it doens't exist!!!
     rstname = title.lower() + '.rst'
     rstpath = os.path.join(self.exclude_path, rstname)
     if not os.path.exists(rstpath):
         mylist = copy.copy(rst_list)
         mylist.replaceall('@@TITLE@@', title)
         txt_mixin.dump(rstpath, mylist)
def save_G(G,N=None):
    if N is None:
        N = get_N()
    mylist = get_list(N)
    new_lines = G_to_text(G, N)
    mylist.append('')
    mylist.extend(new_lines)
    txt_mixin.dump(saved_path, mylist)
    return N
    def html_report_not_in(self, filename):
        self._build_html_header()
        self.html = self.html_header

        for photo_i in self.photos_not_in:
            self.html_one_photo(photo_i)

        self.html.append('</TABLE>')
        self.html.append('</html>')
        txt_mixin.dump(filename, self.html)
示例#16
0
    def __init__(self, filename):
        self.filename = filename
        listin = load_bb_csv(filename)

        fno, ext = os.path.splitext(filename)
        outname = fno + '_clean' + ext

        clean_list = clean_bb_csv_list(listin)
        txt_mixin.dump(outname, clean_list)

        self.db = txt_database.db_from_file(outname)
示例#17
0
    def __init__(self, filename):
        self.filename = filename
        listin = load_bb_csv(filename)

        fno, ext = os.path.splitext(filename)
        outname = fno + '_clean' + ext

        clean_list = clean_bb_csv_list(listin)
        txt_mixin.dump(outname, clean_list)
        
        self.db = txt_database.db_from_file(outname)
示例#18
0
    def generate_worksheet(self):
        biglist = []

        for j in range(self.M):
            rowlist = self.gen_row()
            biglist.extend(rowlist)
            biglist.extend(['', '\\\\', ''])

        hl_list = self.get_header_list()
        body_list = hl_list + biglist + tail_list

        txt_mixin.dump(self.filename, body_list)

        return body_list
示例#19
0
 def create_rst2gimp_rst(self, force=0):
     rstname = 'outline.rst'
     rstpath = os.path.join(self.exclude_path, rstname)
     if not os.path.exists(rstpath) or force:
         mylist = ['']
         mydec = rst_creator.rst_section_level_2()
         #date_stamp = self.create_date_stamp_logo()
         date_stamp = self.create_date_stamp_section()
         mylist.extend(date_stamp)
         sections = ['Outline', 'Announcements', 'Reminders']
         for section in sections:
             mylist.append('')
             mylist.extend(mydec(section))
             mylist.append('')
             txt_mixin.dump(rstpath, mylist)
示例#20
0
def cse_to_file(expr_list, filename, outlabels, funcname, inputs=[], ws=" " * 4, headerfile=None, replace_dict={}):
    line0 = "from __future__ import division"
    line1 = "from scipy import *"
    line2 = "def " + funcname + "(" + ", ".join(inputs) + "):"
    preamble = [line0, line1, "", line2]
    mylist = []
    if headerfile:
        headerlist = txt_mixin.read(headerfile)
        mylist.extend(headerlist)
    mylist.extend(cse_to_txtlist(expr_list, outlabels, ws=ws))
    if replace_dict:
        mylist = txt_mixin.txt_list(mylist)
        for key, value in replace_dict.iteritems():
            mylist.replaceall(key, value)
    mylist = preamble + mylist  # don't do the search and replace in the
    # preamble
    txt_mixin.dump(filename, mylist)
示例#21
0
 def copy_announcements_rst2gimp(self, debug=0):
     if not hasattr(self, 'prev_lecture_path'):
         print('not copying previous lecture stuff')
         return
     prev_exclude_path = os.path.join(self.prev_lecture_path, \
                                      'exclude')
     prev_outline_path = os.path.join(prev_exclude_path,
                                      'outline.rst')
     prev_filein = rst_utils.rst_file(prev_outline_path)
     cur_outline_path = os.path.join(self.exclude_path, 'outline.rst')
     cur_rst = rst_utils.rst_file(cur_outline_path)
     prev_ann_list = prev_filein.get_section_contents('Announcements')
     if prev_ann_list is not None:
         list2 = [item.strip() for item in prev_ann_list]
         filt_list = filter(None, list2)
         if filt_list:
             cur_rst.replace_section('Reminders', prev_ann_list)
     txt_mixin.dump(cur_outline_path, cur_rst.list)
示例#22
0
 def copy_announcements_forward(self, debug=0):
     prev_exclude_path = os.path.join(self.prev_lecture_path, \
                                      'exclude')
     announce_path = os.path.join(prev_exclude_path,
                                  'announcements.rst')
     filein = txt_mixin.txt_file_with_list(announce_path)
     listout = copy.copy(rst_list)
     listout.replaceall('@@TITLE@@', 'Reminders')
     if debug:
         print('pathin = ' + announce_path)
         print('listin = ' + str(filein.list))
     if len(filein.list) > 3:
         listout.extend(filein.list[3:])
     new_exclude_path = os.path.join(self.lecture_path, 'exclude')
     pathout = os.path.join(new_exclude_path, 'reminders.rst')
     if debug:
         print('pathout = ' + pathout)
     txt_mixin.dump(pathout, listout)
示例#23
0
    def gen_all_module_lines(self, input_dict_name='params', filename=None):
        outlines = ['from __future__ import division', \
                    'from numpy import *', \
                    '']

        ## func_fmt = 'def z%i(' + input_dict_name + '):'
        func_line = 'def z_mat(%s):' % input_dict_name
        ws = ' '*4
        assignment_lines_raw = self.gen_assignment_lines()
        assignment_lines = [ws + line for line in assignment_lines_raw]

        func_lines = [func_line]
        func_lines.extend(assignment_lines)
        self.gen_z_mat()
        cse_lines = sage_utils.cse_sage_sympy(self.z_mat)
        cse_lines_clean = [ws + line.replace('Matrix([','array([') for line in cse_lines]
        func_lines.extend(cse_lines_clean)
        outlines.extend(func_lines)


        ## for i, z in enumerate(self.zi_list):
        ##     j = i + 1
        ##     func_line = func_fmt % j
        ##     func_lines = [func_line]
        ##     func_lines.extend(assignment_lines)
        ##     self.gen_z_mat()
        ##     #cse_lines = sage_utils.cse_sage_sympy(z)
        ##     cse_lines = sage_utils.cse_sage_sympy(self.z_mat)
        ##     cse_lines_clean = [ws + line.replace('Matrix([','array([') for line in cse_lines]
        ##     func_lines.extend(cse_lines_clean)
        ##     func_lines.append('')
        ##     func_lines.append('')

        ##     outlines.extend(func_lines)

        while not outlines[-1]:
            outlines.pop(-1)


        if filename is not None:
            import txt_mixin
            txt_mixin.dump(filename, outlines)
            
        return outlines
示例#24
0
def cse_to_file(expr_list, filename, outlabels, funcname, \
                inputs=[], ws=' '*4, headerfile=None, \
                replace_dict={}):
    line0 = 'from __future__ import division'
    line1 = 'from scipy import *'
    line2 = 'def '+funcname +'(' + ', '.join(inputs) + '):'
    preamble = [line0, line1, '', line2]
    mylist = []
    if headerfile:
        headerlist = txt_mixin.read(headerfile)
        mylist.extend(headerlist)
    mylist.extend(cse_to_txtlist(expr_list, outlabels, ws=ws))
    if replace_dict:
        mylist = txt_mixin.txt_list(mylist)
        for key, value in replace_dict.iteritems():
            mylist.replaceall(key,value)
    mylist = preamble + mylist#don't do the search and replace in the
                              #preamble
    txt_mixin.dump(filename, mylist)
示例#25
0
    def generate_worksheet(self):
        # generate x0 - x4 as first row
        # and x5 - x9 as the second row
        # then generate random rows
        biglist = []

        row0 = self.gen_specified_row([0, 1, 2, 3, 4])
        biglist.extend(row0)
        biglist.extend(['', '\\\\', ''])
        row1 = self.gen_specified_row([5, 6, 7, 8, 9])
        biglist.extend(row1)
        biglist.extend(['', '\\\\', ''])

        for j in range(self.M - 2):
            rowlist = self.gen_row()
            biglist.extend(rowlist)
            biglist.extend(['', '\\\\', ''])

        header_list = self.get_header_list()
        body_list = header_list + biglist + tail_list

        txt_mixin.dump(self.filename, body_list)

        return body_list
示例#26
0
 def save(self):
     self.build_filename()
     exclude_dir = os.path.join(self.lecture_path, 'exclude')
     self.outpath = os.path.join(exclude_dir, self.filename)
     self.exclude_dir = exclude_dir
     txt_mixin.dump(self.outpath, self.list)
示例#27
0
 def save(self):
     if not hasattr(self,'list'):
         self.build_list()
     pathout = os.path.join(unison_path, self.filename)
     txt_mixin.dump(pathout, self.list)
 def save(self, pathout):
     self.reassemble()
     txt_mixin.dump(pathout, self.linesout)
示例#29
0
def make_class_list(csvlist, extra_col_labels=None, \
                    fmt_str=None, vrule='\\rule{0pt}{14pt}', \
                    hrule=None, headerpath=None, outpath=None, \
                    course='', semester='', section='', \
                    students_per_page=20):

    last_names, first_names = _get_names(csvlist)

    labels = ['Last Name', 'First Name']
    if extra_col_labels is not None:
        labels.extend(extra_col_labels)

    if fmt_str is None:
        N = len(labels)
        fmt_str = '|l' * N + '|'

    if headerpath is None:
        if os.path.exists('header.tex'):
            headerpath = 'header.tex'
        else:
            headerpath = '/Users/rkrauss/git/report_generation/class_list_header.tex'

    headerline = '\\input{%s}' % headerpath
    startline = '\\begin{tabular}{%s}' % fmt_str
    latex_out = [headerline]
    out = latex_out.append
    out('\\pagestyle{fancy}')
    ws = ' ' * 4
    out(ws + '\\lhead{%s}' % course)
    out(ws + '\\rhead{%s}' % semester)
    out(ws + '\\chead{%s}' % section)
    out(ws + '\\rfoot{\\thepage}')
    out(ws + '\\lfoot{Ryan Krauss}')
    out(ws + '\\cfoot{}')
    out('\\renewcommand{\headrulewidth}{0pt}')
    out('\\begin{document}')
    out(startline)
    out('\\hline')

    label_row = list_to_table_row(labels)

    out(label_row)
    out('\\hline')

    if extra_col_labels is None:
        Nec = 0
    else:
        Nec = len(extra_col_labels)

    Nstudents = len(last_names)
    ilist = range(Nstudents)

    for i, last, first in zip(ilist, last_names, first_names):
        if (i % 2) == 0:
            out('\\rowcolor[gray]{0.9}')
        curlist = [last, first]
        if hrule is None:
            eclist = [''] * Nec
        else:
            eclist = [hrule] * Nec
        curlist += eclist
        last = curlist[-1]
        last += ' ' + vrule
        curlist[-1] = last
        currow = list_to_table_row(curlist)
        out(currow)
        out('\\hline')

        if i == students_per_page:
            out('\\end{tabular}')
            out('')
            out(startline)
            out('\\hline')
            out(label_row)
            out('\\hline')

    out('\\end{tabular}')
    out('\\end{document}')

    if outpath is not None:
        txt_mixin.dump(outpath, latex_out)

    return latex_out
示例#30
0
 def save_rst(self):
     self.get_rst_name()
     txt_mixin.dump(self.outpath, self.rst)
示例#31
0
    biglist = []

    extra_space = False

    for j in range(M):
        rowlist = gen_row(N, extra_space=extra_space, symbol=symbol, \
                          mymax=mymax)
        biglist.extend(rowlist)
        biglist.extend(['', '\\\\', ''])
        extra_space = True

    header_list = self.get_header_list()
    body_list = header_list + biglist + tail_list

    txt_mixin.dump(filename, body_list)

    return body_list


class worksheet_generator(object):
    def __init__(self, filename, M=6, N=5, mymax=20, max_A=10, \
                 symbol='+', title="Math Sheet", **kwargs):
        # should worksheet_generator use max_A and max_B to be the
        # base class?
        self.filename = filename
        self.M = M
        self.N = N
        self.mymax = mymax
        self.max_A = max_A
        self.symbol = symbol
示例#32
0
 def save_summary_latex(self, pathout=None):
     if pathout is None:
         pathout = self._build_pathout('stats')
     if not hasattr(self, 'summary_latex'):
         self.Build_Summary_Latex()
     txt_mixin.dump(pathout, self.summary_latex)
            latex_out.append('\\pagebreak')

        latex_out.extend(cur_item.to_latex(blanknames=False))
        latex_out.extend(AP.summary_row(ave, num_exceeds, \
                                        num_meets, num_does_not))
        ## for pname in project_names[0:1]:
        ##     cur_group = group(pname, group_list, alts=alts)
        ##     cur_group.()
        ##     cur_group.insert_grades_into_bb(bb)
        #--------------------------------
##         bb.InsertColFromList(cur_group.lastnames, 'Team Factor', \
##                              cur_group.team_factors, splitnames=0, \
##                              verbosity=1)
    #bb.run('combined_grades_out.csv')
    new_rows = [ave_row, exceeds_row, meets_row, does_not_row, total_row]
    for item in new_rows:
        bb.alldata.append(item)

    latex_out.append('\\end{document}')
    #texout = 'assessment_report_no_names.tex'
    texout = 'assessment_report.tex'
    texoutpath = os.path.join(assessment_folder, texout)
    txt_mixin.dump(texoutpath, latex_out)
    bb.save(csvoutpath)

    #big_summary_out_name = 'assessment_summary_482_484_%s_%s.csv' % (prev_year_str, year_str)
    big_summary_out_name = 'assessment_summary_482_%s_verify.csv' % year_str
    big_summary_path = os.path.join(assessment_folder, big_summary_out_name)
    dumpcsv(big_spreadsheet_list, big_summary_path)

        if i > 0:
            latex_out.append('\\pagebreak')

        latex_out.extend(cur_item.to_latex(blanknames=False))
        latex_out.extend(AP.summary_row(ave, num_exceeds, \
                                        num_meets, num_does_not))
        ## for pname in project_names[0:1]:
        ##     cur_group = group(pname, group_list, alts=alts)
        ##     cur_group.()
        ##     cur_group.insert_grades_into_bb(bb)
        #--------------------------------
##         bb.InsertColFromList(cur_group.lastnames, 'Team Factor', \
##                              cur_group.team_factors, splitnames=0, \
##                              verbosity=1)
#bb.run('combined_grades_out.csv')
    new_rows = [ave_row, exceeds_row, meets_row, does_not_row, total_row]
    for item in new_rows:
        bb.alldata.append(item)

    latex_out.append('\\end{document}')
    #texout = 'assessment_report_no_names.tex'
    texout = 'assessment_report.tex'
    texoutpath = os.path.join(assessment_folder, texout)
    txt_mixin.dump(texoutpath, latex_out)
    bb.save(csvoutpath)

    #big_summary_out_name = 'assessment_summary_482_484_%s_%s.csv' % (prev_year_str, year_str)
    big_summary_out_name = 'assessment_summary_482_%s_verify.csv' % year_str
    big_summary_path = os.path.join(assessment_folder, big_summary_out_name)
    dumpcsv(big_spreadsheet_list, big_summary_path)
示例#35
0
def csv_to_latex_table(csvlist, labels=None, extra_col_labels=None, \
                       fmt_str=None, vrule='\\rule{0pt}{14pt}', \
                       hrule=None, headerpath=None, outpath=None, \
                       items_per_page=20, delim=',', \
                       lhead='', rhead='', chead='', \
                       lfoot='', rfoot='', cfoot='', \
                       just_tabular=False):#cfoot='\\thepage'
    import copy
    csvlist = copy.copy(csvlist)
    
    if labels is None:
        labels = csvlist.pop(0)

    if type(labels) == str:
        if delim is not None:
            labels = labels.split(delim)

    if extra_col_labels is not None:
        labels.extend(extra_col_labels)

    if fmt_str is None:
        N = len(labels)
        fmt_str = '|l' * N + '|'


    startline = '\\begin{tabular}{%s}' % fmt_str

    if just_tabular:
        latex_out = [startline]
    else:
        latex_out = csv_header(headerpath, \
                               lhead=lhead, rhead=rhead, chead=chead, \
                               lfoot=lfoot, rfoot=rfoot, cfoot=cfoot)
        latex_out.append(startline)

    out = latex_out.append
            
    out('\\hline')

    label_row = list_to_table_row(labels)


    out(label_row)
    out('\\hline')

    if extra_col_labels is None:
        Nec = 0
    else:
        Nec = len(extra_col_labels)


    for i, row in enumerate(csvlist):
        if type(row) == str:
            if delim is None:
                row = [row]
            else:
                row = row.split(delim)
        if (i % 2) == 0:
            out('\\rowcolor[gray]{0.9}')
        curlist = row
        if hrule is None:
            eclist = ['']*Nec
        else:
            eclist = [hrule]*Nec
        curlist += eclist
        last = curlist[-1]
        last += ' ' + vrule
        curlist[-1] = last
        currow = list_to_table_row(curlist)
        out(currow)
        out('\\hline')

        if i == items_per_page:
            out('\\end{tabular}')
            out('')
            out('\\pagebreak')
            out(startline)
            out('\\hline')
            out(label_row)
            out('\\hline')

    out('\\end{tabular}')

    if not just_tabular:
        out('\\end{document}')

    if outpath is not None:
        txt_mixin.dump(outpath, latex_out)

    return latex_out
示例#36
0
def make_class_list(
    csvlist,
    extra_col_labels=None,
    fmt_str=None,
    vrule="\\rule{0pt}{14pt}",
    hrule=None,
    headerpath=None,
    outpath=None,
    course="",
    semester="",
    section="",
    students_per_page=20,
):

    last_names, first_names = _get_names(csvlist)

    labels = ["Last Name", "First Name"]
    if extra_col_labels is not None:
        labels.extend(extra_col_labels)

    if fmt_str is None:
        N = len(labels)
        fmt_str = "|l" * N + "|"

    if headerpath is None:
        if os.path.exists("header.tex"):
            headerpath = "header.tex"
        else:
            headerpath = "/Users/rkrauss/git/report_generation/class_list_header.tex"

    headerline = "\\input{%s}" % headerpath
    startline = "\\begin{tabular}{%s}" % fmt_str
    latex_out = [headerline]
    out = latex_out.append
    out("\\pagestyle{fancy}")
    ws = " " * 4
    out(ws + "\\lhead{%s}" % course)
    out(ws + "\\rhead{%s}" % semester)
    out(ws + "\\chead{%s}" % section)
    out(ws + "\\rfoot{\\thepage}")
    out(ws + "\\lfoot{Ryan Krauss}")
    out(ws + "\\cfoot{}")
    out("\\renewcommand{\headrulewidth}{0pt}")
    out("\\begin{document}")
    out(startline)
    out("\\hline")

    label_row = list_to_table_row(labels)

    out(label_row)
    out("\\hline")

    if extra_col_labels is None:
        Nec = 0
    else:
        Nec = len(extra_col_labels)

    Nstudents = len(last_names)
    ilist = range(Nstudents)

    for i, last, first in zip(ilist, last_names, first_names):
        if (i % 2) == 0:
            out("\\rowcolor[gray]{0.9}")
        curlist = [last, first]
        if hrule is None:
            eclist = [""] * Nec
        else:
            eclist = [hrule] * Nec
        curlist += eclist
        last = curlist[-1]
        last += " " + vrule
        curlist[-1] = last
        currow = list_to_table_row(curlist)
        out(currow)
        out("\\hline")

        if i == students_per_page:
            out("\\end{tabular}")
            out("")
            out(startline)
            out("\\hline")
            out(label_row)
            out("\\hline")

    out("\\end{tabular}")
    out("\\end{document}")

    if outpath is not None:
        txt_mixin.dump(outpath, latex_out)

    return latex_out
示例#37
0
 def save(self):
     if not hasattr(self, 'list'):
         self.build_list()
     pathout = os.path.join(unison_path, self.filename)
     txt_mixin.dump(pathout, self.list)
 def save_team_rst(self, outpath):
     self.outpath = outpath
     txt_mixin.dump(outpath, self.team_rst)
 def save(self):
     self.build_filename()
     exclude_dir = os.path.join(self.lecture_path, 'exclude')
     self.outpath = os.path.join(exclude_dir, self.filename)
     self.exclude_dir = exclude_dir
     txt_mixin.dump(self.outpath, self.list)
示例#40
0
 def save(self, filename):
     txt_mixin.dump(filename, self.md_list)
示例#41
0
 def save_analysis_latex(self, pathout=None):
     if pathout is None:
         pathout = self._build_pathout('item_analysis')
     if not hasattr(self, 'analysis_latex'):
         self.Build_Analysis_Latex()
     txt_mixin.dump(pathout, self.analysis_latex)
        ave_row.append(ave)
        exceeds_row.append(num_exceeds)
        meets_row.append(num_meets)
        does_not_row.append(num_does_not)
        total_row.append(total)

        if i > 0:
            latex_out.append('\\pagebreak')

        latex_out.extend(parsed_item.to_latex())
        latex_out.extend(summary_row(ave, num_exceeds, \
                                     num_meets, num_does_not))
        ## for pname in project_names[0:1]:
        ##     cur_group = group(pname, group_list, alts=alts)
        ##     cur_group.()
        ##     cur_group.insert_grades_into_bb(bb)
        #--------------------------------
##         bb.InsertColFromList(cur_group.lastnames, 'Team Factor', \
##                              cur_group.team_factors, splitnames=0, \
##                              verbosity=1)
    #bb.run('combined_grades_out.csv')
    new_rows = [ave_row, exceeds_row, meets_row, does_not_row, total_row]
    for item in new_rows:
        bb.alldata.append(item)

    latex_out.append('\\end{document}')
    texout = 'assessment_report_no_names.tex'
    txt_mixin.dump(texout, latex_out)
    #bb.save(csvoutpath)
示例#43
0
 def save(self, outpath):
     txt_mixin.dump(outpath, self.list_out)
示例#44
0
 def save_summary_latex(self, pathout=None):
     if pathout is None:
         pathout = self._build_pathout('stats')
     if not hasattr(self, 'summary_latex'):
         self.Build_Summary_Latex()
     txt_mixin.dump(pathout, self.summary_latex)
示例#45
0
 def save_team_rst(self, outpath):
     self.outpath = outpath
     txt_mixin.dump(outpath, self.team_rst)
示例#46
0
 def save_analysis_latex(self, pathout=None):
     if pathout is None:
         pathout = self._build_pathout('item_analysis')
     if not hasattr(self, 'analysis_latex'):
         self.Build_Analysis_Latex()
     txt_mixin.dump(pathout, self.analysis_latex)
示例#47
0
 def save(self, filename):
     txt_mixin.dump(filename, self.md_list)
示例#48
0
        ave_row.append(ave)
        exceeds_row.append(num_exceeds)
        meets_row.append(num_meets)
        does_not_row.append(num_does_not)
        total_row.append(total)

        if i > 0:
            latex_out.append('\\pagebreak')

        latex_out.extend(parsed_item.to_latex())
        latex_out.extend(summary_row(ave, num_exceeds, \
                                     num_meets, num_does_not))
        ## for pname in project_names[0:1]:
        ##     cur_group = group(pname, group_list, alts=alts)
        ##     cur_group.()
        ##     cur_group.insert_grades_into_bb(bb)
        #--------------------------------
##         bb.InsertColFromList(cur_group.lastnames, 'Team Factor', \
##                              cur_group.team_factors, splitnames=0, \
##                              verbosity=1)
#bb.run('combined_grades_out.csv')
    new_rows = [ave_row, exceeds_row, meets_row, does_not_row, total_row]
    for item in new_rows:
        bb.alldata.append(item)

    latex_out.append('\\end{document}')
    texout = 'assessment_report_no_names.tex'
    txt_mixin.dump(texout, latex_out)
    #bb.save(csvoutpath)