本文整理汇总了Python中exactly_lib.util.textformat.textformat_parser.TextParser.fnap方法的典型用法代码示例。如果您正苦于以下问题:Python TextParser.fnap方法的具体用法?Python TextParser.fnap怎么用?Python TextParser.fnap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exactly_lib.util.textformat.textformat_parser.TextParser
的用法示例。
在下文中一共展示了TextParser.fnap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimpleProgressSuiteReporterDocumentation
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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],
' ')
示例2: _TypeConcept
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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()))
示例3: CommandLineActorDocumentation
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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: FileInterpreterActorDocumentation
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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,
]
示例5: __init__
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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
示例6: _EnvironmentVariableConcept
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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))
示例7: _TcdsConcept
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
class _TcdsConcept(ConceptDocumentation):
def __init__(self):
super().__init__(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO)
self._tp = TextParser({
'program_name': formatting.program_name(program_info.PROGRAM_NAME),
'path_type': formatting.entity_(types.PATH_TYPE_INFO)
})
def purpose(self) -> DescriptionWithSubSections:
rest_paragraphs = []
sub_sections = []
rest_paragraphs += self._tp.fnap(_MAIN_DESCRIPTION_REST)
rest_paragraphs += self._dir_structure_list()
rest_paragraphs += self._tp.fnap(_MAIN_DESCRIPTION_LAST)
return DescriptionWithSubSections(self.single_line_description(),
SectionContents(rest_paragraphs, sub_sections))
def see_also_targets(self) -> List[SeeAlsoTarget]:
return [
concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.cross_reference_target,
concepts.SANDBOX_CONCEPT_INFO.cross_reference_target,
syntax_elements.PATH_SYNTAX_ELEMENT.cross_reference_target,
]
def _dir_structure_list(self) -> List[docs.ParagraphItem]:
items = [
self._dir_structure_item(concept, tc_dir_infos)
for concept, tc_dir_infos in _DIR_STRUCTURES
]
return [
docs.simple_list_with_space_between_elements_and_content(items, lists.ListType.ITEMIZED_LIST)
]
def _dir_structure_item(self,
dir_structure: SingularAndPluralNameAndCrossReferenceId,
tc_dir_infos: List[TcDirInfo],
) -> lists.HeaderContentListItem:
contents = [
docs.para(dir_structure.single_line_description),
self._dirs_list(tc_dir_infos)
]
return docs.list_item(dir_structure.singular_name.capitalize(),
contents)
def _dirs_list(self, tc_dir_infos: List[TcDirInfo]) -> docs.ParagraphItem:
return docs.first_column_is_header_table([
self._dir_row(tc_dir_info)
for tc_dir_info in tc_dir_infos
])
def _dir_row(self, tc_dir_info: TcDirInfo) -> List[docs.TableCell]:
return [
docs.text_cell(tc_dir_info.informative_name),
docs.text_cell(tc_dir_info.single_line_description_str),
]
示例8: __init__
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
class FileContentsCheckerHelp:
def __init__(self,
instruction_name: str,
checked_file: str,
initial_args_of_invokation_variants: List[a.ArgumentUsage]):
self._checked_file = checked_file
self.instruction_name = instruction_name
self.initial_args_of_invokation_variants = initial_args_of_invokation_variants
self._tp = TextParser({
'checked_file': checked_file,
'contents_matcher': formatting.syntax_element_(syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT),
'action_to_check': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO),
'program_type': formatting.symbol_type_(types.PROGRAM_TYPE_INFO),
})
def invokation_variants__file(self, actual_file: a.Named) -> List[InvokationVariant]:
actual_file_arg = a.Single(a.Multiplicity.MANDATORY,
actual_file)
return [
invokation_variant_from_args(
[actual_file_arg] + file_contents_checker_arguments__non_program(),
self._tp.fnap(_MAIN_INVOKATION__FILE__SYNTAX_DESCRIPTION)),
]
def invokation_variants__stdout_err(self, program_option: a.OptionName) -> List[InvokationVariant]:
return [
invokation_variant_from_args(
file_contents_checker_arguments__non_program(),
self._tp.fnap(_MAIN_INVOKATION__STDOUT_ERR_ACTION_TO_CHECK__SYNTAX_DESCRIPTION)
),
invokation_variant_from_args(
file_contents_checker_arguments__program(program_option),
self._tp.fnap(_MAIN_INVOKATION__STDOUT_ERR_PROGRAM__SYNTAX_DESCRIPTION)
),
]
@staticmethod
def see_also_targets__file() -> List[SeeAlsoTarget]:
return cross_reference_id_list([
syntax_elements.PATH_SYNTAX_ELEMENT,
syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT,
])
@staticmethod
def see_also_targets__std_out_err() -> List[SeeAlsoTarget]:
return cross_reference_id_list([
syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT,
syntax_elements.PROGRAM_SYNTAX_ELEMENT,
concepts.ACTION_TO_CHECK_CONCEPT_INFO,
])
示例9: IndividualActorConstructor
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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 []
示例10: _act_examples
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
def _act_examples(tp: TextParser) -> sections.SectionConstructor:
return sections.section(
docs.text('Examples'),
sections.constant_contents(
docs.section_contents(tp.fnap(_ACT_EXAMPLES))
)
)
示例11: _SectionThatIsIdenticalToTestCasePhase
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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)
]
示例12: purpose
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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)))
示例13: ConfigurationSectionDocumentation
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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
]
示例14: purpose
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
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)))
示例15: NullActorDocumentation
# 需要导入模块: from exactly_lib.util.textformat.textformat_parser import TextParser [as 别名]
# 或者: from exactly_lib.util.textformat.textformat_parser.TextParser import fnap [as 别名]
class NullActorDocumentation(ActorDocumentation):
def __init__(self):
super().__init__(actors.NULL_ACTOR)
format_map = {
'null': actors.NULL_ACTOR.singular_name,
'actor': ACTOR_CONCEPT_INFO.name.singular,
}
self._parser = TextParser(format_map)
def main_description_rest(self) -> List[ParagraphItem]:
return self._parser.fnap(_MAIN_DESCRIPTION_REST)
def act_phase_contents(self) -> SectionContents:
return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS))
def act_phase_contents_syntax(self) -> SectionContents:
return section_contents(self._parser.fnap(_ACT_PHASE_CONTENTS_SYNTAX))