Example #1
0
 def description_rest(self) -> Sequence[ParagraphItem]:
     tp = TextParser({
         'STRING_SOURCE':
         formatting.syntax_element_(
             syntax_elements.STRING_SOURCE_SYNTAX_ELEMENT),
         'model':
         matcher_model.TEXT_MODEL,
     })
     return tp.fnap(_DESCRIPTION)
 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),
     })
Example #3
0
 def __init__(self, name: str):
     self.actual_file_arg = ACTUAL_PATH_ARGUMENT
     super().__init__(
         name, {
             'checked_file':
             self.actual_file_arg.name,
             'contents_matcher':
             formatting.syntax_element_(
                 syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT),
             'HARD_ERROR':
             exit_values.EXECUTION__HARD_ERROR.exit_identifier,
             'file':
             file_types.REGULAR,
         })
     self.actual_file = a.Single(a.Multiplicity.MANDATORY,
                                 self.actual_file_arg)
    def __init__(self):
        super().__init__(TypeCategory.LOGIC,
                         syntax_elements.STRING_MATCHER_SYNTAX_ELEMENT)

        self.matcher_element_name = instruction_arguments.STRING_MATCHER_PRIMITIVE_SYNTAX_ELEMENT
        self.expected_file_arg = a.Option(FILE_ARGUMENT_OPTION,
                                          _EXPECTED_PATH_NAME)
        self.string_or_here_doc_or_file_arg = StringOrHereDocOrFile(
            _EXPECTED_PATH_NAME,
            _RELATIVITY_OF_EXPECTED_PATH_NAME,
            EXPECTED_FILE_REL_OPT_ARG_CONFIG,
            the_path_of('the file that contains the expected contents.'))
        self._parser = TextParser({
            'symbol_concept': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
            'expected_file_arg': _EXPECTED_PATH_NAME,
            'any': instruction_arguments.EXISTS_QUANTIFIER_ARGUMENT,
            'every': instruction_arguments.ALL_QUANTIFIER_ARGUMENT,
            'LINE_MATCHER': instruction_arguments.LINE_MATCHER.name,
            'HERE_DOCUMENT': formatting.syntax_element_(syntax_elements.HERE_DOCUMENT_SYNTAX_ELEMENT),
            'INTEGER_COMPARISON': syntax_elements.INTEGER_COMPARISON_SYNTAX_ELEMENT.singular_name,
            'REGEX': syntax_elements.REGEX_SYNTAX_ELEMENT.singular_name,
            'full_regex_match': option_syntax.option_syntax(matcher_options.FULL_MATCH_ARGUMENT_OPTION),
            'this_type': formatting.symbol_type(types.STRING_MATCHER_TYPE_INFO.singular_name),
        })
Example #5
0
    def sub_syntax_element_definition_trees(self) -> List[SyntaxElementDescriptionTree]:
        return [
            rel_path_doc.path_element_3(PATH_OF_EXISTING_FILE_OPT_CONFIG,
                                        _TEXT_PARSER.paras(the_path_of('an existing file.')))
        ]


PATH_OF_EXISTING_FILE_OPT_CONFIG = arg_config_with_name('PATH-OF-EXISTING-FILE',
                                                        pgm_syntax_elements.REL_OPTION_ARG_CONF)

EXECUTABLE_ARG = a.Named('EXECUTABLE')

_TEXT_PARSER = TextParser({
    'program_name': formatting.program_name(program_info.PROGRAM_NAME),
    'string_type': formatting.keyword(types.STRING_TYPE_INFO.name.singular),
    'string_se': formatting.syntax_element_(syntax_elements.STRING_SYNTAX_ELEMENT),
    'list_type': formatting.keyword(types.LIST_TYPE_INFO.name.singular),
    'list_se': formatting.syntax_element_(syntax_elements.LIST_SYNTAX_ELEMENT),
    'path_type': formatting.keyword(types.PATH_TYPE_INFO.name.singular),
    'path_se': formatting.syntax_element_(syntax_elements.PATH_SYNTAX_ELEMENT),
    'program_type': formatting.keyword(types.PROGRAM_TYPE_INFO.name.singular),
    'symbol': formatting.concept_(concepts.SYMBOL_CONCEPT_INFO),
    'hds': formatting.concept_(concepts.HOME_DIRECTORY_STRUCTURE_CONCEPT_INFO),
    'SYMBOL_REFERENCE_SYNTAX_ELEMENT': formatting.syntax_element_(syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT),
    'TRANSFORMATION': instruction_arguments.STRING_TRANSFORMATION_ARGUMENT.name,
    'define_symbol': instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME,
    'TEXT_UNTIL_END_OF_LINE': instruction_arguments.TEXT_UNTIL_END_OF_LINE_ARGUMENT.name,
    'SYMBOL_NAME': formatting.syntax_element_(syntax_elements.SYMBOL_NAME_SYNTAX_ELEMENT),
    'THE_PYTHON_INTERPRETER': program_info.PYTHON_INTERPRETER_WHICH_CAN_RUN_THIS_PROGRAM,
    'PATH_OF_EXISTING_FILE': PATH_OF_EXISTING_FILE_OPT_CONFIG.argument_syntax_name,
    'ARGUMENT': formatting.syntax_element(pgm_syntax_elements.ARGUMENT_SYNTAX_ELEMENT_NAME.name),
Example #6
0
 types.STRING_TYPE_INFO.name,
 'PROGRAM':
 syntax_elements.PROGRAM_SYNTAX_ELEMENT.singular_name,
 'symbol':
 concepts.SYMBOL_CONCEPT_INFO.name,
 'hds':
 concepts.HDS_CONCEPT_INFO.name,
 'TRANSFORMATION':
 string_transformer.STRING_TRANSFORMATION_ARGUMENT.name,
 'define_symbol':
 formatting.InstructionName(
     instruction_names.SYMBOL_DEFINITION_INSTRUCTION_NAME),
 'instruction':
 concepts.INSTRUCTION_CONCEPT_INFO.name,
 'SYMBOL_NAME':
 formatting.syntax_element_(syntax_elements.SYMBOL_NAME_SYNTAX_ELEMENT),
 'ARGUMENT':
 formatting.syntax_element(
     syntax_elements.PROGRAM_ARGUMENT_SYNTAX_ELEMENT.singular_name),
 'SHELL_COMMAND_LINE':
 formatting.syntax_element_(
     syntax_elements.SHELL_COMMAND_LINE_SYNTAX_ELEMENT),
 'EOL':
 defs.END_OF_LINE,
 'executable_file':
 formatting.misc_name_with_formatting(misc_texts.EXECUTABLE_FILE),
 'FAIL':
 exit_values.EXECUTION__FAIL.exit_identifier,
 'shell_command':
 formatting.misc_name_with_formatting(misc_texts.SHELL_COMMAND),
 'relativity':
Example #7
0

def _symbol_reference() -> InvokationVariant:
    return invokation_variant_from_args([
        syntax_elements.SYMBOL_REFERENCE_SYNTAX_ELEMENT.single_mandatory,
    ],
        _TEXT_PARSER.fnap(_SYMBOL_REFERENCE_DESCRIPTION)
    )


PATH_OF_EXISTING_FILE_OPT_CONFIG = arg_config_with_name('PATH-OF-EXISTING',
                                                        pgm_syntax_elements.EXE_FILE_REL_OPTION_ARG_CONF)

_TEXT_PARSER = TextParser({
    'string_type': types.STRING_TYPE_INFO.name,
    'string_se': formatting.syntax_element_(syntax_elements.STRING_SYNTAX_ELEMENT),
    'list_type': types.LIST_TYPE_INFO.name,
    'list_se': formatting.syntax_element_(syntax_elements.LIST_SYNTAX_ELEMENT),
    'path_type': types.PATH_TYPE_INFO.name,
    'path_se': formatting.syntax_element_(syntax_elements.PATH_SYNTAX_ELEMENT),
    'rich_string_se': syntax_elements.RICH_STRING_SYNTAX_ELEMENT.singular_name,
    'A_ref_to_symbol_w_string_conversion': types.a_ref_to_a_symbol_w_string_conversion__sentence(),
    'soft_quote': syntax_descriptions.SOFT_QUOTE_NAME,
    'symbol': concepts.SYMBOL_CONCEPT_INFO.name,
    'SYMBOLIC_LINKS_ARE_FOLLOWED': misc_texts.SYMBOLIC_LINKS_ARE_FOLLOWED,
    'dir_file_type': file_types.DIRECTORY,
    'regular_file_type': file_types.REGULAR,
    'Note': headers.NOTE_LINE_HEADER,
})

_MAIN__DESCRIPTION = """\
Example #8
0
from exactly_lib.definitions import formatting
from exactly_lib.definitions.entity import syntax_elements
from exactly_lib.help.entities.syntax_elements.contents_structure import syntax_element_documentation
from exactly_lib.util.textformat.textformat_parser import TextParser

_MAIN_DESCRIPTION_REST = """\
A {SYNTAX_ELEMENT} is passed as a single string to the operating system's shell,
so all features of the shell can be used.


Us of the shell is of course not portable since it
depends on the current operating system environment's shell.


On POSIX, the shell defaults to /bin/sh.

On Windows, the COMSPEC environment variable specifies the default shell.
"""

_TEXT_PARSER = TextParser({
    'SYNTAX_ELEMENT': formatting.syntax_element_(syntax_elements.SHELL_COMMAND_LINE_SYNTAX_ELEMENT)

})
DOCUMENTATION = syntax_element_documentation(None,
                                             syntax_elements.SHELL_COMMAND_LINE_SYNTAX_ELEMENT,
                                             _TEXT_PARSER.fnap(_MAIN_DESCRIPTION_REST),
                                             [],
                                             [],
                                             [])