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 hierarchy(header: str, suite_help: TestSuiteHelp) -> SectionHierarchyGenerator: tp = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'executable_name': program_info.PROGRAM_NAME, 'suite_program_mode': SUITE_COMMAND, 'reporter_concept': formatting.concept_(concepts.SUITE_REPORTER_CONCEPT_INFO), 'cases': section_names.CASES, 'suites': section_names.SUITES, 'ALL_PASS': exit_values.ALL_PASS.exit_identifier, 'generic_section': SectionName('NAME'), }) def section_of_parsed(contents: str) -> SectionContentsConstructor: return sections.constant_contents( docs.section_contents(tp.fnap(contents)) ) return h.hierarchy( header, children=[ h.child('introduction', h.leaf('Introduction', section_of_parsed(_INTRODUCTION)) ), h.child('structure', structure.root('Structure', suite_help) ), h.child('file-syntax', h.leaf('File syntax', section_of_parsed(_FILE_SYNTAX)) ), h.child('outcome', outcome.root('Outcome')), ])
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 __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: tp = TextParser({ 'cd_concept': formatting.concept(self.singular_name()), 'CD': self.acronym(), 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'sds_concept': formatting.concept_(concepts.SDS_CONCEPT_INFO), 'act_sub_dir': SUB_DIRECTORY__ACT + '/', 'path_type': formatting.symbol_type_(types.PATH_TYPE_INFO), 'act_phase': phase_names.ACT.emphasis, 'rel_cd_option': formatting.cli_option(path.REL_CWD_OPTION), 'cd_instruction': InstructionName(instruction_names.CHANGE_DIR_INSTRUCTION_NAME), 'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'os_process': misc_texts.OS_PROCESS_NAME, }) return DescriptionWithSubSections( self.single_line_description(), SectionContents( tp.fnap(_INITIAL_PARAGRAPHS), [ docs.section( tp.text(_USING_THE_CD_HEADER), tp.fnap(_USING_THE_CD) ), docs.section( tp.text(_DESCRIPTION_DEF_INSTRUCTION_HEADER), cd_instruction_section_on_def_instruction() ), ] ))
def hierarchy(header: str, suite_help: TestSuiteHelp) -> SectionHierarchyGenerator: tp = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'executable_name': program_info.PROGRAM_NAME, 'suite_program_mode': SUITE_COMMAND, 'reporter_concept': formatting.concept_(concepts.SUITE_REPORTER_CONCEPT_INFO), 'cases': section_names.CASES, 'suites': section_names.SUITES, 'ALL_PASS': exit_values.ALL_PASS.exit_identifier, 'generic_section': SectionName('NAME'), }) def section_of_parsed(contents: str) -> SectionContentsConstructor: return sections.constant_contents( docs.section_contents(tp.fnap(contents))) return h.hierarchy( header, children=[ h.child('introduction', h.leaf('Introduction', section_of_parsed(_INTRODUCTION))), h.child('structure', structure.root('Structure', suite_help)), h.child('file-syntax', h.leaf('File syntax', section_of_parsed(_FILE_SYNTAX))), h.child('outcome', outcome.root('Outcome')), ])
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 __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 __init__(self): super().__init__(concepts.SANDBOX_CONCEPT_INFO) self._tp = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'phase': phase_names.PHASE_NAME_DICTIONARY, 'instruction': AnyInstructionNameDictionary(), 'cwd': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO), 'cd_instruction': InstructionName(CHANGE_DIR_INSTRUCTION_NAME), 'keep_sandbox_option': formatting.cli_option(command_line_options.OPTION_FOR_KEEPING_SANDBOX_DIRECTORY), })
def _new_argument_parser(commands: Dict[str, str]) -> argparse.ArgumentParser: def command_description(n_d) -> str: return '%s - %s' % (n_d[0], n_d[1]) command_descriptions = '\n'.join(map(command_description, commands.items())) ret_val = argparse.ArgumentParser( prog=program_info.PROGRAM_NAME, description='Runs an {pgm} test case or test suite.'.format( pgm=formatting.program_name(program_info.PROGRAM_NAME))) ret_val.add_argument('--version', action='version', version='%(prog)s ' + program_info.VERSION) ret_val.add_argument( 'file', metavar='[FILE|COMMAND]', type=str, help="""A test case file, or one of the commands {commands}. {command_descriptions} """.format( commands=grammar_options_syntax.alternatives_list(commands.keys()), command_descriptions=command_descriptions)) ret_val.add_argument( short_and_long_option_syntax.short_syntax( opt.OPTION_FOR_KEEPING_SANDBOX_DIRECTORY__SHORT), short_and_long_option_syntax.long_syntax( opt.OPTION_FOR_KEEPING_SANDBOX_DIRECTORY__LONG), default=False, action="store_true", help=TEXT_PARSER.format(KEEPING_SANDBOX_OPTION_DESCRIPTION)) ret_val.add_argument( short_and_long_option_syntax.long_syntax( opt.OPTION_FOR_EXECUTING_ACT_PHASE__LONG), default=False, action="store_true", help=TEXT_PARSER.format(EXECUTING_ACT_PHASE_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax( common_opts.OPTION_FOR_ACTOR__LONG), metavar=common_opts.ACTOR_OPTION_ARGUMENT, nargs=1, help=TEXT_PARSER.format(ACTOR_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax( opt.OPTION_FOR_SUITE__LONG), metavar=opt.SUITE_OPTION_METAVAR, nargs=1, help=TEXT_PARSER.format(SUITE_OPTION_DESCRIPTION)) ret_val.add_argument( short_and_long_option_syntax.long_syntax( opt.OPTION_FOR_PREPROCESSOR__LONG), metavar=opt.PREPROCESSOR_OPTION_ARGUMENT, nargs=1, help=TEXT_PARSER.format(PREPROCESSOR_OPTION_DESCRIPTION)) return ret_val
def __init__(self): super().__init__(concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO) self._tp = TextParser({ 'HDS': formatting.concept_(concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO), 'phase': phase_names.PHASE_NAME_DICTIONARY, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO), 'symbols': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name), 'conf_params': formatting.concept(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name), 'PATH': syntax_elements.PATH_SYNTAX_ELEMENT.singular_name, })
def __init__(self): super().__init__(concepts.TYPE_CONCEPT_INFO) self._parser = TextParser({ 'type': concepts.TYPE_CONCEPT_INFO.name, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'string_type': types.STRING_TYPE_INFO.name, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, })
def __init__(self): super().__init__(SYMBOL_CONCEPT_INFO) list_symbol_name = 'LIST_SYMBOL' file_trans_symbol_name = 'REPLACE_ID' symbol_names = [ list_symbol_name, file_trans_symbol_name, ] self._parser = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': SYMBOL_CONCEPT_INFO.name, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'symbol_name_syntax_element': syntax_elements.SYMBOL_NAME_SYNTAX_ELEMENT.argument.name, 'define_symbol': formatting.InstructionName( instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'symbol_name_syntax': syntax_descriptions.SYMBOL_NAME_SYNTAX_DESCRIPTION, 'def': instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME, 'string_type_in_text': types.STRING_TYPE_INFO.name, 'string_type': types.VALUE_TYPE_2_TYPES_INFO_DICT[ValueType.STRING].identifier, 'list_type': types.VALUE_TYPE_2_TYPES_INFO_DICT[ValueType.LIST].identifier, 'file_trans_type': types.VALUE_TYPE_2_TYPES_INFO_DICT[ ValueType.STRING_TRANSFORMER].identifier, 'max_type_width': max( map(lambda type_info: len(type_info.identifier), types.VALUE_TYPE_2_TYPES_INFO_DICT.values())), 'LIST_SYMBOL': list_symbol_name, 'FILE_TRANS_SYMBOL': file_trans_symbol_name, 'max_symbol_name_width': max(map(len, symbol_names)), 'ref_syntax_of_symbol_name': symbol_reference_syntax_for_name('symbol_name'), 'exists_file': instruction_names.TEST_CASE_STATUS_INSTRUCTION_NAME, 'stdout': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'transformed': string_transformer.STRING_TRANSFORMATION_ARGUMENT, })
def __init__(self): self.executable = a.Named(command_line_actor.EXECUTABLE) self.argument = a.Named(command_line_actor.ARGUMENT) self.command = a.Constant(command_line_actor.COMMAND) fm = { 'EXECUTABLE': self.executable.name, 'ARGUMENT': self.argument.name, 'actor': formatting.concept_(concepts.ACTOR_CONCEPT_INFO), 'act_phase': phase_names.ACT.emphasis, 'shell_syntax_concept': formatting.concept_(concepts.SHELL_SYNTAX_CONCEPT_INFO), 'program_name': formatting.program_name(program_info.PROGRAM_NAME), } super().__init__(TextParser(fm))
def __init__(self): self.text_parser = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'case_home_directory': formatting.conf_param_(conf_params.HOME_CASE_DIRECTORY_CONF_PARAM_INFO), 'act_home_directory': formatting.concept_(conf_params.HOME_ACT_DIRECTORY_CONF_PARAM_INFO), 'act_sub_dir': sds.SUB_DIRECTORY__ACT, 'tmp_sub_dir': sds.PATH__TMP_USER, 'result_sub_dir': sds.SUB_DIRECTORY__RESULT, 'sandbox': concepts.SANDBOX_CONCEPT_INFO.name, 'conf_param': concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.name, } ) self.all_variables_dict = dict(ENVIRONMENT_VARIABLES_SET_BEFORE_ACT + ENVIRONMENT_VARIABLES_SET_AFTER_ACT)
def __init__(self): self._tp = TextParser({ 'test_case_file': 'helloworld.case', 'EXECUTABLE_PROGRAM': PROGRAM_NAME, 'program_name': formatting.program_name(PROGRAM_NAME), 'action_to_check': 'helloworld', 'ATC': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO), 'CONTENTS_EQUALS_ARGUMENT': EQUALS_ARGUMENT, 'INT_EQUALS_OPERATOR': comparators.EQ.name, 'act': phase_names.ACT, 'assert': phase_names.ASSERT, 'PASS': exit_values.EXECUTION__PASS.exit_identifier, 'FAIL': exit_values.EXECUTION__FAIL.exit_identifier, 'stdout_instruction': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'exit_code_instruction': instruction_names.EXIT_CODE_INSTRUCTION_NAME, })
def __init__(self, setup: Setup): self._setup = setup self._tp = TextParser({ 'phase': setup.phase_names, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name.singular, 'instructions': concepts.INSTRUCTION_CONCEPT_INFO.name.plural, 'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.singular_name, 'act_phase': phase_infos.ACT.name, 'symbol': concepts.SYMBOL_CONCEPT_INFO.name.singular, 'symbols': concepts.SYMBOL_CONCEPT_INFO.name.plural, 'cli_option_for_preprocessor': formatting.cli_option(OPTION_FOR_PREPROCESSOR), 'an_error_in_source': misc_texts.SYNTAX_ERROR_NAME.singular_determined, 'directive': concepts.DIRECTIVE_CONCEPT_INFO.name, 'including': formatting.keyword(directives.INCLUDING_DIRECTIVE_INFO.singular_name), })
def _new_argument_parser(commands: Dict[str, str]) -> argparse.ArgumentParser: def command_description(n_d) -> str: return '%s - %s' % (n_d[0], n_d[1]) command_descriptions = '\n'.join(map(command_description, commands.items())) ret_val = argparse.ArgumentParser(prog=program_info.PROGRAM_NAME, description='Runs an {pgm} test case or test suite.'.format( pgm=formatting.program_name(program_info.PROGRAM_NAME))) ret_val.add_argument('--version', action='version', version='%(prog)s ' + program_info.VERSION) ret_val.add_argument('file', metavar='[FILE|COMMAND]', type=str, help="""A test case file, or one of the commands {commands}. {command_descriptions} """.format(commands=grammar_options_syntax.alternatives_list(commands.keys()), command_descriptions=command_descriptions)) ret_val.add_argument(short_and_long_option_syntax.short_syntax(opt.OPTION_FOR_KEEPING_SANDBOX_DIRECTORY__SHORT), short_and_long_option_syntax.long_syntax(opt.OPTION_FOR_KEEPING_SANDBOX_DIRECTORY__LONG), default=False, action="store_true", help=TEXT_PARSER.format(KEEPING_SANDBOX_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax(opt.OPTION_FOR_EXECUTING_ACT_PHASE__LONG), default=False, action="store_true", help=TEXT_PARSER.format(EXECUTING_ACT_PHASE_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax( common_opts.OPTION_FOR_ACTOR__LONG), metavar=common_opts.ACTOR_OPTION_ARGUMENT, nargs=1, help=TEXT_PARSER.format(ACTOR_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax(opt.OPTION_FOR_SUITE__LONG), metavar=opt.SUITE_OPTION_METAVAR, nargs=1, help=TEXT_PARSER.format(SUITE_OPTION_DESCRIPTION)) ret_val.add_argument(short_and_long_option_syntax.long_syntax(opt.OPTION_FOR_PREPROCESSOR__LONG), metavar=opt.PREPROCESSOR_OPTION_ARGUMENT, nargs=1, help=TEXT_PARSER.format(PREPROCESSOR_OPTION_DESCRIPTION)) return ret_val
def __init__(self): self.text_parser = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'hds_case_directory': formatting.conf_param_( conf_params.HDS_CASE_DIRECTORY_CONF_PARAM_INFO), 'hds_act_directory': formatting.concept_(conf_params.HDS_ACT_DIRECTORY_CONF_PARAM_INFO), 'act_sub_dir': sds.SUB_DIRECTORY__ACT, 'tmp_sub_dir': sds.PATH__TMP_USER, 'result_sub_dir': sds.SUB_DIRECTORY__RESULT, 'sandbox': concepts.SDS_CONCEPT_INFO.name, 'conf_param': concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.name, }) self.all_variables_dict = dict(SYMBOLS_SET_BEFORE_ACT + SYMBOLS_SET_AFTER_ACT)
def __init__(self): self._tp = TextParser({ 'phase': phase_names.PHASE_NAME_DICTIONARY, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'ATC': concepts.ACTION_TO_CHECK_CONCEPT_INFO.singular_name, 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, 'directive': concepts.DIRECTIVE_CONCEPT_INFO.name, 'actor': concepts.ACTOR_CONCEPT_INFO.name, 'exit_code': misc_texts.EXIT_CODE, 'exit_identifier': misc_texts.EXIT_IDENTIFIER, 'act_phase': phase_infos.ACT.name, 'cli_option_for_preprocessor': formatting.cli_option(OPTION_FOR_PREPROCESSOR), 'an_error_in_source': misc_texts.SYNTAX_ERROR_NAME.singular_determined, 'including': formatting.keyword( directives.INCLUDING_DIRECTIVE_INFO.singular_name), 'stdout': misc_texts.STDOUT, 'execution': processing.STEP_EXECUTION, 'validation': processing.STEP_VALIDATION, 'preprocessing': processing.STEP_PRE_PROCESSING, })
def __init__(self): self._tp = TextParser({ 'test_case_file': 'helloworld.case', 'EXECUTABLE_PROGRAM': PROGRAM_NAME, 'program_name': formatting.program_name(PROGRAM_NAME), 'action_to_check': 'helloworld', 'ATC': formatting.concept_(concepts.ACTION_TO_CHECK_CONCEPT_INFO), 'CONTENTS_EQUALS_ARGUMENT': EQUALS_ARGUMENT, 'INT_EQUALS_OPERATOR': comparators.EQ.name, 'act': phase_names.ACT, 'assert': phase_names.ASSERT, 'PASS': exit_values.EXECUTION__PASS.exit_identifier, 'FAIL': exit_values.EXECUTION__FAIL.exit_identifier, 'stdout_instruction': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'exit_code_instruction': instruction_names.EXIT_CODE_INSTRUCTION_NAME, 'executable_file': formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE), 'console_style': std_tags.CONSOLE_TEXT, 'HERE_DOCUMENT_MARKER_PREFIX': string.HERE_DOCUMENT_MARKER_PREFIX, 'MARKER': 'EOF', })
def __init__(self): super().__init__(concepts.HDS_CONCEPT_INFO) self._tp = TextParser({ 'HDS': concepts.HDS_CONCEPT_INFO.acronym, 'hds_concept': formatting.concept_(concepts.HDS_CONCEPT_INFO), 'phase': phase_names.PHASE_NAME_DICTIONARY, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO), 'symbols': formatting.concept(concepts.SYMBOL_CONCEPT_INFO.plural_name), 'conf_params': formatting.concept( concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO.plural_name), 'PATH': syntax_elements.PATH_SYNTAX_ELEMENT.singular_name, 'Note': headers.NOTE_LINE_HEADER, })
def __init__(self): super().__init__(concepts.INSTRUCTION_CONCEPT_INFO) self._tp = TextParser({ 'instruction': self.name(), 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': concepts.SYMBOL_CONCEPT_INFO.name, 'def': InstructionName( instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'act': phase_infos.ACT.name, 'atc': concepts.ACTION_TO_CHECK_CONCEPT_INFO.name, 'assert': phase_infos.ASSERT.name, 'cleanup': phase_infos.CLEANUP.name, 'shell_command_line': formatting.misc_name_with_formatting( misc_texts.SHELL_COMMAND_LINE), })
def purpose(self) -> DescriptionWithSubSections: tp = TextParser({ 'cd_concept': formatting.concept(self.singular_name()), 'CD': self.acronym(), 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'sds_concept': formatting.concept_(concepts.SANDBOX_CONCEPT_INFO), 'act_sub_dir': SUB_DIRECTORY__ACT + '/', 'path_type': formatting.symbol_type_(types.PATH_TYPE_INFO), 'act_phase': phase_names.ACT.syntax, 'rel_cd_option': formatting.cli_option(file_ref.REL_CWD_OPTION), 'cd_instruction': InstructionName(instruction_names.CHANGE_DIR_INSTRUCTION_NAME), 'run_instruction': InstructionName(instruction_names.RUN_INSTRUCTION_NAME), 'shell_instruction': InstructionName(instruction_names.SHELL_INSTRUCTION_NAME), 'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'os_process': misc_texts.OS_PROCESS_NAME, }) return DescriptionWithSubSections( self.single_line_description(), SectionContents( tp.fnap(_INITIAL_PARAGRAPHS), [ docs.section( tp.text(_USING_THE_CD_HEADER), tp.fnap(_USING_THE_CD) ), docs.section( tp.text(_DESCRIPTION_DEF_INSTRUCTION_HEADER), cd_instruction_section_on_def_instruction() ), ] ))
def description(self) -> DescriptionWithSubSections: text = '{}s help system.'.format(formatting.program_name(program_info.PROGRAM_NAME)) return DescriptionWithSubSections(docs.text(text), empty_section_contents())
def root(header: str) -> generator.SectionHierarchyGenerator: tp = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'conf_param': formatting.concept_(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO), 'tcds_concept': formatting.concept_(concepts.TCDS_CONCEPT_INFO), 'TCDS': concepts.TCDS_CONCEPT_INFO.acronym, 'SDS': concepts.SDS_CONCEPT_INFO.acronym, 'sds_concept': formatting.concept_(concepts.SDS_CONCEPT_INFO), 'Sds_concept_header': concepts.SDS_CONCEPT_INFO.singular_name.capitalize(), 'sds_single_line_description': concepts.SDS_CONCEPT_INFO.single_line_description_str.capitalize(), 'HDS': concepts.HDS_CONCEPT_INFO.acronym, 'hds_concept': formatting.concept_(concepts.HDS_CONCEPT_INFO), 'Hds_concept_header': concepts.HDS_CONCEPT_INFO.singular_name.capitalize(), 'hds_single_line_description': concepts.HDS_CONCEPT_INFO.single_line_description_str.capitalize(), 'conf_phase': phase_names.CONFIGURATION, 'act_phase': phase_names.ACT, 'act_hds_conf_param': formatting.conf_param(test_case_file_structure.HDS_ACT_INFO.identifier), 'path_type': types.PATH_TYPE_INFO.name, 'symbol_concept': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO), 'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'os_process': misc_texts.OS_PROCESS_NAME, 'env_var': concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.name, 'timeout': concepts.TIMEOUT_CONCEPT_INFO.name, 'timeout_instruction': InstructionName(instruction_names.TIMEOUT_INSTRUCTION_NAME), 'type': concepts.TYPE_CONCEPT_INFO.name, 'instruction': concepts.INSTRUCTION_CONCEPT_INFO.name, 'relativity': formatting.concept(misc_texts.RELATIVITY.singular), 'relativities': formatting.concept(misc_texts.RELATIVITY.plural), 'cd': formatting.emphasis(instruction_names.CHANGE_DIR_INSTRUCTION_NAME), 'env': formatting.emphasis(instruction_names.ENV_VAR_INSTRUCTION_NAME), 'CD': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO), }) def const_paragraphs_child(local_target_name: str, header_: str, paragraphs_: List[ParagraphItem]) -> generator.SectionHierarchyGenerator: return h.child(local_target_name, h.leaf(header_, sections.constant_contents(section_contents(paragraphs_))) ) return h.hierarchy( header, children=[ h.child_hierarchy( 'dir-structure', 'Directory structure and Current directory', paragraphs.constant(tp.fnap(_DS_CD_PREAMBLE)), [ const_paragraphs_child( 'sds', concepts.SDS_CONCEPT_INFO.singular_name.capitalize() + ' and Current directory', tp.fnap(_SDS_AND_CD) ), const_paragraphs_child( 'hds', concepts.HDS_CONCEPT_INFO.singular_name.capitalize(), tp.fnap(_HDS), ), const_paragraphs_child( 'file-ref', 'File references', tp.fnap(_FILE_REFERENCES) ), h.leaf_not_in_toc( see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_dir_struct_see_also_targets()) )), ] ), h.child_hierarchy( 'symbols', concepts.SYMBOL_CONCEPT_INFO.plural_name.capitalize(), paragraphs.constant(tp.fnap(_SYMBOLS)), [ h.leaf_not_in_toc( see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_symbols_see_also_targets()) )) ] ), h.child_hierarchy( 'os-proc', tp.text(misc_texts.OS_PROCESS_ENVIRONMENT_SECTION_HEADER), paragraphs.constant(tp.fnap(_OS_PROC_INTRO)), [ const_paragraphs_child( 'cd', 'Current directory', tp.fnap(_OS_PROC_CURRENT_DIRECTORY), ), const_paragraphs_child( 'env-vars', tp.format('{env_var:s/u}'), environment_variable.common_description(), ), const_paragraphs_child( 'timeout', 'Timeout', tp.fnap(_OS_PROC_TIMEOUT), ), h.leaf_not_in_toc( see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_os_process_see_also_targets()) ) ), ], ), ] )
from xml.etree.ElementTree import Element, SubElement from exactly_lib import program_info from exactly_lib.definitions import formatting from exactly_lib.definitions.entity import all_entity_types from exactly_lib.help import std_tags from exactly_lib.util.textformat.rendering.html.utils import ElementPopulator, ComplexElementPopulator PAGE_TITLE = 'Reference Manual for %s' % formatting.program_name( program_info.PROGRAM_NAME) TOC_TITLE = 'Table of Contents' _CSS_CLASSES = { 'toc': std_tags.TOC_SECTION, 'entity': std_tags.ENTITY, 'section': std_tags.SECTION, 'syntax_text': std_tags.SYNTAX_TEXT, 'console_class': std_tags.CONSOLE_TEXT, 'enum_constant': std_tags.ENUM_CONSTANT, 'text_as_header': std_tags.TEXT_AS_HEADER, 'actor_entity': all_entity_types.ACTOR_ENTITY_TYPE_NAMES.identifier, 'concept_entity': all_entity_types.CONCEPT_ENTITY_TYPE_NAMES.identifier, 'type_entity': all_entity_types.TYPE_ENTITY_TYPE_NAMES.identifier, } ELEMENT_STYLES_ = """\ pre {{ background-color : #EEFFCC; padding: 7px; border: 1px solid #cEdFaC; }}
'home_act_env_var': environment_variables.ENV_VAR_HOME_ACT, 'home_case_env_var': environment_variables.ENV_VAR_HOME_CASE, 'home_env_var_with_replacement_precedence': HOME_ENV_VAR_WITH_REPLACEMENT_PRECEDENCE, }) prologue = text_parser.fnap(_WITH_REPLACED_TCDS_PATHS_PROLOGUE) variables_list = [docs.simple_header_only_list(map(directory_variable_name_text, sorted(environment_variables.ALL_REPLACED_ENV_VARS)), docs.lists.ListType.ITEMIZED_LIST)] return SectionContents(prologue + variables_list) def with_replaced_env_vars_see_also() -> Sequence[SeeAlsoTarget]: return [ concepts.ENVIRONMENT_VARIABLE_CONCEPT_INFO.cross_reference_target, ] SINGLE_LINE_DESCRIPTION = """\ Every occurrence of a string that matches the absolute path of a {TCDS} directory is replaced with the name of the corresponding symbol/environment variable. """.format(program_name=program_name(program_info.PROGRAM_NAME), TCDS=concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO.acronym) _WITH_REPLACED_TCDS_PATHS_PROLOGUE = """\ If {home_case_env_var} and {home_act_env_var} are equal, then paths will be replaced with {home_env_var_with_replacement_precedence}. Paths that are replaced: """
def description(self) -> DescriptionWithSubSections: text = '{}s help system.'.format( formatting.program_name(program_info.PROGRAM_NAME)) return DescriptionWithSubSections(docs.text(text), empty_section_contents())
def file_ref_contents_description(case_or_suite_string: str) -> List[ParagraphItem]: tp = TextParser({ 'case': case_or_suite_string, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), }) return tp.fnap(_TEXT)
def synopsises(self) -> List[cli_syntax.Synopsis]: return [ test_case_cli_syntax.synopsis(), test_suite_cli_syntax.synopsis(), symbol_cli_syntax.synopsis_general(), _help_toc_synopsis(), _html_help_synopsis(), _simple_argument_synopsis(), ] def argument_descriptions(self) -> List[cli_syntax.DescribedArgument]: return [] _SINGLE_LINE_DESCRIPTION = ('Runs an ' + formatting.program_name(program_info.PROGRAM_NAME) + ' test case, test suite, or displays help.') def _help_toc_synopsis() -> cli_syntax.Synopsis: return _help_synopsis(help_arguments.help_help(), 'Help on the {} command.'.format(HELP_COMMAND)) def _html_help_synopsis() -> cli_syntax.Synopsis: return _help_synopsis(help_arguments.html_doc(), 'Outputs all available help as html.') def _simple_argument_synopsis() -> cli_syntax.Synopsis: help_arg = arg.Single(arg.Multiplicity.MANDATORY,
def _program_name() -> str: return formatting.program_name(program_info.PROGRAM_NAME)
def _reference_paragraphs(self) -> List[ParagraphItem]: from exactly_lib.impls.types.string_transformer.names import FILTER_TRANSFORMER_NAME from exactly_lib.definitions.primitives.file_or_dir_contents import EMPTINESS_CHECK_ARGUMENT from exactly_lib.impls.types.string_matcher.matcher_options import EQUALS_ARGUMENT from exactly_lib.impls.types.string_source.defs import FILE_OPTION from exactly_lib.definitions.path import REL_symbol_OPTION part_2_parser = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'symbol': formatting.concept_(SYMBOL_CONCEPT_INFO), 'def': instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME, 'string_type_in_text': types.STRING_TYPE_INFO.name, 'string_type': types.VALUE_TYPE_2_TYPES_INFO_DICT[ValueType.STRING].identifier, 'plain_string': misc_texts.PLAIN_STRING, 'list_type': types.VALUE_TYPE_2_TYPES_INFO_DICT[ValueType.LIST].identifier, 'max_type_width': max( map( lambda value_type: len(types.VALUE_TYPE_2_TYPES_INFO_DICT[ value_type].identifier), [ValueType.LIST, ValueType.STRING])), 'ref_syntax_of_symbol_name': symbol_reference_syntax_for_name('SYMBOL_NAME'), 'stdout': instruction_names.CONTENTS_OF_STDOUT_INSTRUCTION_NAME, 'transformed': string_transformer.WITH_TRANSFORMED_CONTENTS_OPTION, 'filter_transformer': FILTER_TRANSFORMER_NAME, 'not': logic.NOT_OPERATOR_NAME, 'empty': EMPTINESS_CHECK_ARGUMENT, 'equals': EQUALS_ARGUMENT, 'file_option': option_syntax.option_syntax(FILE_OPTION), 'rel_option': REL_symbol_OPTION, 'ref_syntax_of_dir_name_symbol': symbol_reference_syntax_for_name('DIR_NAME_SYMBOL'), 'ref_syntax_of_base_name_symbol': symbol_reference_syntax_for_name('BASE_NAME_SYMBOL'), 'ref_syntax_of_2nd_element_symbol': symbol_reference_syntax_for_name( syntax_elements.STRING_SYNTAX_ELEMENT.singular_name + '_SYMBOL'), 'special_syntax_with_invalid_symbol_name': symbol_reference_syntax_for_name('NOT/A_VALID_SYMBOL_NAME'), 'special_syntax_with_valid_symbol_name_but_invalid_delimiter': symbol_reference_syntax_for_name('VALID_SYMBOL_NAME')[:-1], 'special_syntax_with_invalid_space': symbol_reference_syntax_for_name('VALID_SYMBOL_NAME '), }) ret_val = self._parser.fnap(_REFERENCE_1) ret_val.append(_symbol_reference_syntax_table()) ret_val += part_2_parser.fnap(_REFERENCE_2) return ret_val
def apply(self, parent: Element): version = SubElement(parent, 'p') version.text = formatting.program_name( program_info.PROGRAM_NAME) + ' version ' + program_info.VERSION SubElement(parent, 'hr')
def path_contents_description(case_or_suite_string: str) -> List[ParagraphItem]: tp = TextParser({ 'case': case_or_suite_string, 'program_name': formatting.program_name(program_info.PROGRAM_NAME), }) return tp.fnap(_TEXT)
_TEXT_PARSER.fnap(_PYTHON_INTERPRETER_DESCRIPTION) ) def system_program(arguments: List[a.ArgumentUsage]) -> InvokationVariant: return invokation_variant_from_args( [ a.Single(a.Multiplicity.MANDATORY, a.Constant(pgm_syntax_elements.SYSTEM_PROGRAM_TOKEN) ), a.Single(a.Multiplicity.MANDATORY, syntax_elements.STRING_SYNTAX_ELEMENT.argument ), ] + arguments, _TEXT_PARSER.paras(misc_texts.SYSTEM_PROGRAM_DESCRIPTION) ) _TEXT_PARSER = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'THE_PYTHON_INTERPRETER': program_info.PYTHON_INTERPRETER_WHICH_CAN_RUN_THIS_PROGRAM, }) _PYTHON_INTERPRETER_DESCRIPTION = """\ {THE_PYTHON_INTERPRETER} Since {program_name} is written in Python, the Python interpreter is guaranteed to be available on the system. """
def root(header: str) -> generator.SectionHierarchyGenerator: tp = TextParser({ 'program_name': formatting.program_name(program_info.PROGRAM_NAME), 'conf_param': formatting.concept_(concepts.CONFIGURATION_PARAMETER_CONCEPT_INFO), 'tcds_concept': formatting.concept_(concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO), 'TCDS': concepts.TEST_CASE_DIRECTORY_STRUCTURE_CONCEPT_INFO.acronym, 'SDS': concepts.SANDBOX_CONCEPT_INFO.acronym, 'sds_concept': formatting.concept_(concepts.SANDBOX_CONCEPT_INFO), 'Sds_concept_header': concepts.SANDBOX_CONCEPT_INFO.singular_name.capitalize(), 'sds_single_line_description': concepts.SANDBOX_CONCEPT_INFO.single_line_description_str.capitalize(), 'HDS': concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.acronym, 'hds_concept': formatting.concept_(concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO), 'Hds_concept_header': concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.singular_name.capitalize(), 'hds_single_line_description': concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.single_line_description_str.capitalize(), 'conf_phase': phase_names.CONFIGURATION, 'act_phase': phase_names.ACT, 'act_home_conf_param': formatting.conf_param(test_case_file_structure.HDS_ACT_INFO.identifier), 'data': type_system.DATA_TYPE_CATEGORY_NAME, 'path_type': formatting.term(types.PATH_TYPE_INFO.singular_name), 'symbol_concept': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO), 'def_instruction': InstructionName(instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME), 'os_process': misc_texts.OS_PROCESS_NAME, 'time_out_conf_param': formatting.conf_param_(conf_params.TIMEOUT_CONF_PARAM_INFO), 'relativity': formatting.concept(misc_texts.RELATIVITY.singular), 'relativities': formatting.concept(misc_texts.RELATIVITY.plural), 'cd': formatting.emphasis(instruction_names.CHANGE_DIR_INSTRUCTION_NAME), 'env': formatting.emphasis(instruction_names.ENV_VAR_INSTRUCTION_NAME), 'CD': formatting.concept_(concepts.CURRENT_WORKING_DIRECTORY_CONCEPT_INFO), }) def const_paragraphs_child(local_target_name: str, header_: str, paragraphs_: List[ParagraphItem]) -> generator.SectionHierarchyGenerator: return h.child(local_target_name, h.leaf(header_, sections.constant_contents(section_contents(paragraphs_))) ) return h.hierarchy( header, children=[ h.child_hierarchy( 'dir-structure', 'Directory structure and Current directory', paragraphs.constant(tp.fnap(_DS_CD_PREAMBLE)), [ const_paragraphs_child( 'sds', concepts.SANDBOX_CONCEPT_INFO.singular_name.capitalize() + ' and Current directory', tp.fnap(_SDS_AND_CD) ), const_paragraphs_child( 'hds', concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO.singular_name.capitalize(), tp.fnap(_HDS), ), const_paragraphs_child( 'file-ref', 'File references', tp.fnap(_FILE_REFERENCES) ), h.child('see-also', h.with_not_in_toc( h.leaf( see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_dir_struct_see_also_targets()) ))) ), ] ), h.child_hierarchy( 'symbols', concepts.SYMBOL_CONCEPT_INFO.plural_name.capitalize(), paragraphs.constant(tp.fnap(_SYMBOLS)), [ h.with_not_in_toc( h.child_leaf( 'see-also', see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_symbols_see_also_targets()) )) ) ] ), h.child_hierarchy( 'os-proc', tp.text('{os_process} environment'), paragraphs.constant(tp.fnap(_OS_PROC_INTRO)), [ const_paragraphs_child( 'cd', 'Current directory', tp.fnap(_OS_PROC_CURRENT_DIRECTORY), ), const_paragraphs_child( 'env-vars', 'Environment variables', tp.fnap(_OS_PROC_ENVIRONMENT_VARIABLES), ), const_paragraphs_child( 'timeout', 'Timeout', tp.fnap(_OS_PROC_TIMEOUT), ), h.with_not_in_toc( h.child_leaf( 'see-also', see_also.SEE_ALSO_TITLE, see_also.SeeAlsoSectionContentsConstructor( see_also.items_of_targets(_os_process_see_also_targets()) ))) , ], ), ] )