def do_latex_files(self): go = push_lines_from_files(*self.latex_files) master = pipe( splitmerge(identity, lines_to_toplevel), splitmerge(latex_labels_for_per_iac, identity), splitmerge( lambda t: pipe(neutralize_verb_tag, splitmerge(find_implements, find_doneby), t), identity), self.add_all_indirect_iacs, splitmerge(identity, paragraphs), tag_iac_paragraphs, self.write_the_iac_files) go(prime(master))
def summon_file_for_iac(iac): f = file(os.path.join(directory_name, iac), 'w') print >> f, "\\section{%s: %s}" % (iac, iac_titles[iac]) print >> f, "\\label{iac-%s}" % iac return prime(pipe( LatexEmitter(iac), prime(lines_to_file(f)(None))))
def testThreeMemberPipe(self): s = Sink() sg = prime(s()) p = prime(pipe(add(1), mul(3), sg)) p.send(4) # add(1) happens first -> 5 # then mul(3) -> 15 self.assertEqual(s.values, [15])
def autoindex(target): all = [ class_definition, class_include, class_bracket_quoted_include, define_definition, define_use, file_use, ] return pipe(*(all + [target]))
def do_puppet_files(self): go = push_lines_from_files(*self.puppet_files) input_stage = splitmerge( identity, lambda t: pipe(sort_comments, invert_comments, t)) label_stage = lambda t: pipe( splitmerge(identity, labels_for_files(self.nToStrip), labels_for_modules(self.nToStrip)), buffer_labels_till_first_latex_line, autoindex, t) add_written_reqs = splitmerge(find_implements, find_doneby, find_bydefault, identity) do_policy_output = lambda t: pipe(drop_tagged('line'), LatexEmitter('policy'), lines_to_file(self.policy_output), t) per_iac_output = lambda t: pipe( # grab both implements (from upstream) and paragraphs splitmerge(identity, paragraphs), splitmerge(puppet_labels_for_per_iac(self.nToStrip), identity), tag_iac_paragraphs, self.write_iac_files_pipe_entry, t) master = pipe( splitmerge( identity, lambda t: pipe(take_tagged('new_file'), log('reading', logging.DEBUG), null, t)), input_stage, label_stage, add_written_reqs, self.add_all_indirect_iacs, splitmerge(self.write_exec_summary_splitmerge_entry, per_iac_output, do_policy_output), lambda t: null(t)) go(prime(master))
def prepare(self): self.log.debug('There are %d LaTeX files', len(self.latex_files)) self.log.debug('There are %d Puppet files', len(self.puppet_files)) self.write_the_iac_files = prime( latex_to_files_in(self.per_iac_output_dir, ia_controls.names)(None)) # since the latex_to_files_in doesn't emit messages, it doesn't matter # what comes after it in the pipe; but pipe expects to call something # with one argument self.write_iac_files_pipe_entry = lambda t: self.write_the_iac_files self.write_exec_summary = prime( pipe(executive_summary(ia_controls.names), LatexEmitter('exec_summary'), lines_to_file(self.exec_summary_output), None)) self.write_exec_summary_splitmerge_entry = \ lambda t: self.write_exec_summary find_each_indirect_iacs = [ find_ia_control_tags( name, meaning, ia_controls.for_system_profile[meaning.profile_id]) for (name, meaning) in self.checklists.items() ] self.add_all_indirect_iacs = splitmerge(*(find_each_indirect_iacs + [identity]))
def testTwoMemberPipe(self): s = Sink() sg = prime(s()) p = prime(pipe(add(1), sg)) p.send(3) self.assertEqual(s.values, [4])
def testOneMemberPipe(self): s = Sink() # pipe will call s() to get generator object p = prime(pipe(s)) p.send(3) self.assertEqual(s.values, [3])