<commit_before>module Skr
    module Print

        class Form

            def initialize(form, code)
                @template = Template.get(form) || raise("Unable to find template for #{form}")
                @record   = @template.model.where(hash_code: code).first!
                @latex    = @template.path_for_record(@record)
                unless @latex.exist?
                    raise("Unable to find template type for record")
                end
                Lanes.logger.debug "Printing #{form} #{code} using #{@latex}"
            end

            def as_pdf
                begin
                    template.to_stringio
                rescue => e
                    Lanes.logger.warn e.log
                    raise
                end
            end

            def as_latex
                template.compile_latex
            end

            def data
                vars = {
                    @template.name.underscore => @record,
                    'root_path' => ::Skr::Print::ROOT
                }
                if @record.respond_to?(:latex_template_variables)
                    vars.merge!(@record.latex_template_variables)
                end
                vars
            end

            def template
                ErbLatex::Template.new( @latex,
                                        data: data,
                                        context: Skr::Print::Context,
                                        layout: ROOT.join('layout.tex.erb'),
                                        partials_path: ROOT.join('partials'),
                                        packages_path: ROOT.join('packages')<commit_msg>Only output log for latex errors<commit_after>module Skr
    module Print

        class Form

            def initialize(form, code)
                @template = Template.get(form) || raise("Unable to find template for #{form}")
                @record   = @template.model.where(hash_code: code).first!
                @latex    = @template.path_for_record(@record)
                unless @latex.exist?
                    raise("Unable to find template type for record")
                end
                Lanes.logger.debug "Printing #{form} #{code} using #{@latex}"
            end

            def as_pdf
                begin
                    template.to_stringio
                rescue ErbLatex::LatexError => e
                    Lanes.logger.warn e.log
                    raise
                rescue => e
                    Lanes.logger.warn e
                    raise
                end
            end

            def as_latex
                template.compile_latex
            end

            def data
                vars = {
                    @template.name.underscore => @record,
                    'root_path' => ::Skr::Print::ROOT
                }
                if @record.respond_to?(:latex_template_variables)
                    vars.merge!(@record.latex_template_variables)
                end
                vars
            end

            def template
                ErbLatex::Template.new( @latex,
                                        data: data,
                                        context: Skr::Print::Context,
                                        layout: ROOT.join('layout.tex.erb'),
                                        partials_path: ROOT.join('partials'),
                                        packages_path: ROOT.join('packages')
{'fraction_non_alphanumeric': 0.07865818392134181, 'fraction_numerical': 0.0, 'mean_word_length': 0.9731888191671421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1962945', 'n_tokens_mistral': 813, 'n_tokens_neox': 749, 'n_words': 172}