本文整理汇总了Python中exactly_lib.util.textformat.textformat_parser.TextParser类的典型用法代码示例。如果您正苦于以下问题:Python TextParser类的具体用法?Python TextParser怎么用?Python TextParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _TypeConcept
class _TypeConcept(ConceptDocumentation):
def __init__(self):
super().__init__(concepts.TYPE_CONCEPT_INFO)
self._parser = TextParser({
'program_name': formatting.program_name(program_info.PROGRAM_NAME),
'data': type_system.DATA_TYPE_CATEGORY_NAME,
'logic': type_system.LOGIC_TYPE_CATEGORY_NAME,
})
def purpose(self) -> DescriptionWithSubSections:
rest_paragraphs = self._parser.fnap(_REST_DESCRIPTION_1)
rest_paragraphs += [
_categories_list(self._list_header('{data} types'),
self._list_header('{logic} types'))
]
rest_paragraphs += self._parser.fnap(_REST_DESCRIPTION_2)
sub_sections = []
return DescriptionWithSubSections(self.single_line_description(),
SectionContents(rest_paragraphs,
sub_sections))
def _list_header(self, template_string: str) -> str:
return self._parser.format(template_string).capitalize()
def see_also_targets(self) -> List[SeeAlsoTarget]:
return list(map(lambda type_doc: type_doc.cross_reference_target(),
all_types.all_types()))
示例2: IndividualActorConstructor
class IndividualActorConstructor(ArticleContentsConstructor):
def __init__(self, actor: ActorDocumentation):
self.actor = actor
self.rendering_environment = None
format_map = {
'actor_concept': formatting.concept_(concepts.ACTOR_CONCEPT_INFO),
'act_phase': phase_names.ACT.emphasis,
}
self._parser = TextParser(format_map)
def apply(self, environment: ConstructionEnvironment) -> doc.ArticleContents:
self.rendering_environment = environment
initial_paragraphs = self._default_reporter_info()
initial_paragraphs.extend(self.actor.main_description_rest())
sub_sections = []
append_sections_if_contents_is_non_empty(
sub_sections,
[(self._parser.format('{act_phase} phase contents'), self.actor.act_phase_contents()),
(self._parser.format('Syntax of {act_phase} phase contents'), self.actor.act_phase_contents_syntax())])
sub_sections += see_also_sections(self.actor.see_also_targets(), environment)
return doc.ArticleContents(docs.paras(self.actor.single_line_description()),
doc.SectionContents(initial_paragraphs,
sub_sections))
def _default_reporter_info(self) -> List[ParagraphItem]:
from exactly_lib.definitions.entity.actors import DEFAULT_ACTOR
if self.actor.singular_name() == DEFAULT_ACTOR.singular_name:
return self._parser.fnap('This is the default {actor_concept}.')
else:
return []
示例3: CommandLineActorDocumentation
class CommandLineActorDocumentation(ActorDocumentation):
def __init__(self):
super().__init__(COMMAND_LINE_ACTOR)
self._tp = TextParser({
'phase': phase_names.PHASE_NAME_DICTIONARY,
'LINE_COMMENT_MARKER': formatting.string_constant(LINE_COMMENT_MARKER),
})
def act_phase_contents(self) -> doc.SectionContents:
return doc.SectionContents(self._tp.fnap(_ACT_PHASE_CONTENTS))
def act_phase_contents_syntax(self) -> doc.SectionContents:
documentation = ActPhaseDocumentationSyntax()
initial_paragraphs = self._tp.fnap(SINGLE_LINE_PROGRAM_ACT_PHASE_CONTENTS_SYNTAX_INITIAL_PARAGRAPH)
sub_sections = []
synopsis_section = doc_utils.synopsis_section(
invokation_variants_content(None,
documentation.invokation_variants(),
documentation.syntax_element_descriptions()))
sub_sections.append(synopsis_section)
return doc.SectionContents(initial_paragraphs, sub_sections)
def _see_also_specific(self) -> List[SeeAlsoTarget]:
return cross_reference_id_list([
conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO,
concepts.SHELL_SYNTAX_CONCEPT_INFO,
])
示例4: _SectionThatIsIdenticalToTestCasePhase
class _SectionThatIsIdenticalToTestCasePhase(TestSuiteSectionDocumentationBaseForSectionWithoutInstructions):
def __init__(self,
phase_name: str,
contents_is_inserted_before_case_contents: bool):
super().__init__(phase_name)
self._contents_is_inserted_before_case_contents = contents_is_inserted_before_case_contents
self._tp = TextParser({
'phase': self.section_info.name,
})
def contents_description(self) -> SectionContents:
return self._tp.section_contents(_CONTENTS_DESCRIPTION)
def purpose(self) -> Description:
paragraphs = self._tp.fnap(_CORRESPONDENCE_DESCRIPTION)
paragraphs += insertion_position_description(self.section_info.name,
self._contents_is_inserted_before_case_contents)
return Description(self._tp.text(_SINGLE_LINE_DESCRIPTION),
paragraphs)
@property
def see_also_targets(self) -> List[SeeAlsoTarget]:
return [
TestCasePhaseCrossReference(self.name.plain)
]
示例5: purpose
def purpose(self) -> DescriptionWithSubSections:
parse = TextParser({
'phase': phase_names.PHASE_NAME_DICTIONARY,
})
return from_simple_description(
Description(self.single_line_description(),
parse.fnap(WHAT_THE_TIMEOUT_APPLIES_TO)))
示例6: ConfigurationSectionDocumentation
class ConfigurationSectionDocumentation(TestSuiteSectionDocumentationForSectionWithInstructions):
def __init__(self,
name: str,
instruction_set: SectionInstructionSet):
super().__init__(name, instruction_set)
self._tp = TextParser({
'conf_phase': phase_names.CONFIGURATION,
})
def instructions_section_header(self) -> docs.Text:
return docs.text('Additional instructions')
def instruction_purpose_description(self) -> List[ParagraphItem]:
return []
def contents_description(self) -> docs.SectionContents:
return self._tp.section_contents(_CONTENTS_DESCRIPTION)
def purpose(self) -> Description:
paragraphs = self._tp.fnap(_PURPOSE_REST_TEXT)
paragraphs += test_case_phase_sections.insertion_position_description(self.section_info.name, True)
return Description(self._tp.text(_PURPOSE_SINGLE_LINE_DESCRIPTION_TEXT),
paragraphs)
@property
def see_also_targets(self) -> List[SeeAlsoTarget]:
return [
phase_infos.CONFIGURATION.cross_reference_target
]
示例7: SimpleProgressSuiteReporterDocumentation
class SimpleProgressSuiteReporterDocumentation(SuiteReporterDocumentation):
def __init__(self):
super().__init__(PROGRESS_REPORTER)
format_map = {
}
self._parser = TextParser(format_map)
def syntax_of_output(self) -> List[ParagraphItem]:
return self._parser.fnap(_SYNTAX_OF_OUTPUT)
def exit_code_description(self) -> List[ParagraphItem]:
return (self._parser.fnap(_EXIT_CODE_DESCRIPTION_PRELUDE) +
[self._exit_value_table(_exit_values_and_descriptions())])
def _exit_value_table(self, exit_value_and_description_list: list) -> ParagraphItem:
def _row(exit_value: ExitValue, description: str) -> List[TableCell]:
return [
cell(paras(str(exit_value.exit_code))),
cell(paras(exit_value_text(exit_value))),
cell(self._parser.fnap(description)),
]
return first_row_is_header_table(
[
[
cell(paras(misc_texts.EXIT_CODE_TITLE)),
cell(paras(misc_texts.EXIT_IDENTIFIER_TITLE)),
cell(paras('When')),
]] +
[_row(exit_value, description) for exit_value, description in exit_value_and_description_list],
' ')
示例8: FileInterpreterActorDocumentation
class FileInterpreterActorDocumentation(ActorDocumentation):
CL_SYNTAX_RENDERER = cli_program_syntax.CommandLineSyntaxRenderer()
ARG_SYNTAX_RENDERER = cli_program_syntax.ArgumentInArgumentDescriptionRenderer()
def __init__(self):
super().__init__(FILE_INTERPRETER_ACTOR)
self._tp = TextParser({
'shell_syntax_concept': formatting.concept_(concepts.SHELL_SYNTAX_CONCEPT_INFO),
'LINE_COMMENT_MARKER': formatting.string_constant(LINE_COMMENT_MARKER),
})
def act_phase_contents(self) -> doc.SectionContents:
return section_contents(self._tp.fnap(_ACT_PHASE_CONTENTS))
def act_phase_contents_syntax(self) -> doc.SectionContents:
documentation = ActPhaseDocumentationSyntax()
initial_paragraphs = self._tp.fnap(SINGLE_LINE_PROGRAM_ACT_PHASE_CONTENTS_SYNTAX_INITIAL_PARAGRAPH)
sub_sections = []
synopsis_section = doc_utils.synopsis_section(
invokation_variants_content(None,
documentation.invokation_variants(),
documentation.syntax_element_descriptions()))
sub_sections.append(synopsis_section)
return doc.SectionContents(initial_paragraphs, sub_sections)
def _see_also_specific(self) -> List[SeeAlsoTarget]:
return [
concepts.SHELL_SYNTAX_CONCEPT_INFO.cross_reference_target,
]
示例9: purpose
def purpose(self) -> DescriptionWithSubSections:
tp = TextParser({
'reporter_option': formatting.cli_option(OPTION_FOR_REPORTER),
'default_reporter': formatting.entity(reporters.DEFAULT_REPORTER.singular_name),
})
return from_simple_description(
Description(self.single_line_description(),
tp.fnap(_DESCRIPTION_REST)))
示例10: __init__
class _HierarchyGenerator:
def __init__(self, suite_help: TestSuiteHelp):
self._suite_help = suite_help
self._tp = TextParser({
'program_name': formatting.program_name(program_info.PROGRAM_NAME),
'conf_section': section_names.CONFIGURATION,
'conf_phase': phase_names.CONFIGURATION,
})
def generator(self, header: str) -> SectionHierarchyGenerator:
return h.hierarchy(
header,
paragraphs.constant(self._tp.fnap(_PRELUDE)),
[
h.child('cases-and-sub-suites',
self._cases_and_sub_suites(CASES_AND_SUB_SUITES_HEADER)
),
h.child('common-test-case-contents',
self._common_tc_contents(COMMON_CASE_CONTENTS_HEADER)
),
h.child('additional-test-case-conf',
h.leaf(
ADDITIONAL_TEST_CASE_CONFIG_HEADER,
sections.constant_contents(
docs.section_contents(self._tp.fnap(_ADDITIONAL_TEST_CASE_CONFIG))
))
),
])
def _cases_and_sub_suites(self, header: str) -> SectionHierarchyGenerator:
return h.leaf(
header,
sections.constant_contents(
docs.section_contents(self._cases_and_sub_suites_paragraphs())
)
)
def _common_tc_contents(self, header: str) -> SectionHierarchyGenerator:
return h.leaf(
header,
sections.constant_contents(
docs.section_contents(self._common_tc_contents_paragraphs())
))
def _cases_and_sub_suites_paragraphs(self) -> List[ParagraphItem]:
ret_val = self._tp.fnap(_CASES_AND_SUB_SUITES)
ret_val.append(sections_short_list(self._suite_help.test_cases_and_sub_suites_sections,
default_section_name=section_names_plain.DEFAULT_SECTION_NAME,
section_concept_name='section'))
return ret_val
def _common_tc_contents_paragraphs(self) -> List[ParagraphItem]:
ret_val = self._tp.fnap(_COMMON_TC_CONTENTS)
ret_val.append(sections_short_list(self._suite_help.test_case_phase_sections,
default_section_name=section_names_plain.DEFAULT_SECTION_NAME,
section_concept_name='section'))
return ret_val
示例11: cd_instruction_section_on_def_instruction
def cd_instruction_section_on_def_instruction() -> List[ParagraphItem]:
tp = TextParser({
'current_directory_concept': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),
'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
'rel_cd_option': formatting.cli_option(file_ref.REL_CWD_OPTION),
'path_type': formatting.keyword(types.PATH_TYPE_INFO.name.singular),
})
return tp.fnap(_CD_INSTRUCTION_SECTION_ON_DEF_INSTRUCTION)
示例12: _what_outcome_depends_on
def _what_outcome_depends_on(tp: TextParser) -> ParagraphItem:
items = [
list_item(tp.text(_OUTCOME_DEPENDENCE__STATUS),
tp.fnap(_OUTCOME_DEFAULT_STATUS)),
list_item(tp.text(_OUTCOME_DEPENDENCE__ASSERT_PHASE)),
]
return lists.HeaderContentList(items,
lists.Format(lists.ListType.ORDERED_LIST,
custom_separations=SEPARATION_OF_HEADER_AND_CONTENTS))
示例13: _EnvironmentVariableConcept
class _EnvironmentVariableConcept(ConceptDocumentation):
def __init__(self):
super().__init__(ENVIRONMENT_VARIABLE_CONCEPT_INFO)
self._tp = TextParser({
'program_name': formatting.program_name(program_info.PROGRAM_NAME),
'env_vars__plain': self.name().plural,
'env_instruction': InstructionName(instruction_names.ENV_VAR_INSTRUCTION_NAME),
'tcds_concept': formatting.concept_(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO),
})
def purpose(self) -> DescriptionWithSubSections:
return DescriptionWithSubSections(
self.single_line_description(),
docs.section_contents(
self._tp.fnap(_INITIAL_PARAGRAPHS),
[
docs.section(self._tp.text('Environment variables set by {program_name}'),
self._tp.fnap(_E_SETS_EXTRA_ENV_VARS),
[
self._variables_from_setup(),
self._variables_from_before_assert(),
])
]))
def see_also_targets(self) -> List[SeeAlsoTarget]:
ret_val = name_and_cross_ref.cross_reference_id_list([
concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO,
conf_params.HOME_CASE_DIRECTORY_CONF_PARAM_INFO,
conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO,
])
ret_val += [
phase_infos.SETUP.instruction_cross_reference_target(instruction_names.ENV_VAR_INSTRUCTION_NAME)
]
return ret_val
def _variables_from_setup(self) -> docs.Section:
return _variables_section(phase_names.SETUP,
_variables_list_paragraphs([
self._item(var_name)
for var_name in map(operator.itemgetter(0),
environment_variables.ENVIRONMENT_VARIABLES_SET_BEFORE_ACT)
]))
def _variables_from_before_assert(self) -> docs.Section:
return _variables_section(phase_names.BEFORE_ASSERT,
_variables_list_paragraphs([
self._item(var_name)
for var_name in map(operator.itemgetter(0),
environment_variables.ENVIRONMENT_VARIABLES_SET_AFTER_ACT)
]))
def _item(self, var_name: str) -> lists.HeaderContentListItem:
return docs.list_item(directory_variable_name_text(var_name),
environment_variables.ENVIRONMENT_VARIABLE_DESCRIPTION.as_description_paragraphs(
var_name))
示例14: def_instruction_rel_cd_description
def def_instruction_rel_cd_description(path_arg_name: str) -> List[ParagraphItem]:
tp = TextParser({
'current_directory_concept': formatting.concept_(
concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO),
'path_arg': path_arg_name,
'symbol_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.singular_name),
'symbols_concept': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name),
})
return tp.fnap(_DEF_INSTRUCTION_REL_CD_DESCRIPTION)
示例15: abs_or_rel_path_of_existing
def abs_or_rel_path_of_existing(file_type: str,
syntax_element: str,
relativity_root: str) -> List[ParagraphItem]:
tp = TextParser({
'file_type': file_type,
'syntax_element': syntax_element,
'relativity_root': relativity_root
})
return tp.fnap(_PATH_DESCRIPTION) + paths_uses_posix_syntax()