def append_to_document(self, doc: Document, doc_answers: Enumerate) -> None: variable_dict = {} for variable in self.variables: variable_dict[variable.symbol] = variable.value parsed_text = QuestionParser(**variable_dict).parse(self.text) with doc.create(Section(parsed_text)): doc.append('Respuesta: ') doc.append(LineBreak()) doc_answers.add_item('Respuesta de pregunta abierta')
def append_to_document(self, doc: Document, doc_answers: Enumerate) -> None: variable_dict = {} for variable in self.variables: variable_dict[variable.symbol] = variable.value parsed_text = QuestionParser(**variable_dict).parse(self.text) with doc.create(Section(parsed_text)): doc.append(bold('Verdadero\t\tFalso')) expr = BooleanParser(**variable_dict).parse(self.expression) doc_answers.add_item('VERDADERO' if expr else 'FALSO')
def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") enum = Enumerate() enum.add_item(s="item") enum.append("append") desc = Description() desc.add_item(label="label", s="item") desc.append("append")
def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") repr(itemize) enum = Enumerate(enumeration_symbol=r"\alph*)", options={'start': 172}) enum.add_item(s="item") enum.add_item(s="item2") enum.append("append") repr(enum) desc = Description() desc.add_item(label="label", s="item") desc.append("append") repr(desc)
def section_1_introduction(): sec = Subsection(title='Introduction') sec.append( NoEscape( 'Calculation documented herein follows Annex B in ' '"Eurocode 1: Actions on structures – Part 1-2: General actions – Actions on structures exposed to fire" ' '(BS EN 1991-1-2). This method allows the determination of (a) the maximum temperatures of a compartment ' 'fire; (b) the size and temperatures of the flame from openings; and (c) the thermal radiation and ' 'convection parameters.\\par')) sec.append( NoEscape( 'This method considers steady-state conditions for various parameters and is only valid when the following ' 'conditions are met:')) section_1_enumerate_1 = Enumerate() section_1_enumerate_1.add_item( NoEscape( 'Fire load $q_{fd}$ is greater than 200 ${MJ}\\cdot m^{-2}$; and' )) section_1_enumerate_1.add_item( NoEscape( 'The size of the fire compartment should not exceed 70 $m$ in length, 18 $m$ in width and 5 $m$ in height.' )) sec.append(section_1_enumerate_1) sec.append(NoEscape('\\par')) sec.append( NoEscape( 'Units, symbols and abbreviations are consistent with the referenced document unless stated.\\par' )) sec.append( NoEscape( 'Numerical values shown in this document are rounded as appropriate for readability, however, calculations ' 'are carried out based on the actual values.\\par')) sec.append( NoEscape( 'This assessment is specific to \\textit{no forced draught} condition in accordance with ' 'Clause B.4.1 in BS EN 1991-1-2.')) return sec
def append_to_document(self, doc: Document, doc_answers: Enumerate): variable_dict = {} for variable in self.variables: variable_dict[variable.symbol] = variable.value question_parser = QuestionParser(**variable_dict) parsed_text = question_parser.parse(self.text) correct_answer = question_parser.parse(self.correct_answer) answers = list( map(question_parser.parse, map(lambda x: x.answer, self.dummy_questions))) random.shuffle(answers) correct_pos = random.randint(0, len(answers)) answers.insert(correct_pos, correct_answer) with doc.create(Section(parsed_text)): with doc.create( Enumerate(enumeration_symbol=r'\alph*) ', options={'start': 1})) as enum: for answer in answers: enum.add_item(answer) doc_answers.add_item(chr(ord('a') + correct_pos))
def test_lists(): # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") repr(itemize) empty_itemize = Itemize() assert empty_itemize.dumps() == '' repr(empty_itemize) enum = Enumerate() enum.add_item(s="item") enum.append("append") repr(enum) desc = Description() desc.add_item(label="label", s="item") desc.append("append") repr(desc)
a = Axis(data=None, options=None) p = Plot(name=None, func=None, coordinates=None, options=None) # Utils escape_latex(s='') fix_filename(path='') dumps_list(l=[], escape=False, token='\n') bold(s='') italic(s='') verbatim(s='', delimiter='|') # Lists itemize = Itemize() itemize.add_item(s="item") itemize.append("append") enum = Enumerate() enum.add_item(s="item") enum.append("append") desc = Description() desc.add_item(label="label", s="item") desc.append("append")
def fromEnumerate(self, s: Enumerate): tokens = [self.fromTokenLine(c) for c in s.buffer] ui = TEnum() for line in tokens: ui.add_item(line) return ui
def de_enumerate(s: env.Enumerate): tokens = [de_line(c) for c in s.children] ui = TEnum() for line in tokens: ui.add_item(line) return ui