コード例 #1
0
def src_rel_opt_conf(rel_option_types: AbstractSet[RelOptionType],
                     default_option: RelOptionType,
                     ) -> RelOptionsConfiguration:
    return RelOptionsConfiguration(PathRelativityVariants(
        set(rel_option_types),
        True),
        default_option)
コード例 #2
0
def arg_config_for_rel_symbol_config(
    relativity_variants: PathRelativityVariants,
    default: RelOptionType = None
) -> RelOptionArgumentConfigurationWoSuffixRequirement:
    if default is None:
        default = list(relativity_variants.rel_option_types)[0]
    return RelOptionArgumentConfigurationWoSuffixRequirement(
        RelOptionsConfiguration(relativity_variants, default),
        'argument_syntax_name')
コード例 #3
0
def argument_config__read(
        argument_syntax_name: str, phase_is_after_act: bool,
        default: RelOptionType) -> RelOptionArgumentConfiguration:
    return RelOptionArgumentConfiguration(RelOptionsConfiguration(
        relativity_variants(phase_is_after_act),
        default,
    ),
                                          argument_syntax_name,
                                          path_suffix_is_required=True)
コード例 #4
0
ファイル: change_dir.py プロジェクト: emilkarlen/exactly
def relativity_options(is_after_act_phase: bool) -> RelOptionArgumentConfiguration:
    accepted = [RelOptionType.REL_ACT,
                RelOptionType.REL_TMP,
                RelOptionType.REL_CWD]
    if is_after_act_phase:
        accepted.append(RelOptionType.REL_RESULT)
    variants = PathRelativityVariants(set(accepted), True)
    return RelOptionArgumentConfiguration(RelOptionsConfiguration(variants,
                                                                  RelOptionType.REL_CWD),
                                          _DIR_ARGUMENT.name,
                                          True)
コード例 #5
0
    def runTest(self):
        # ARRANGE #

        to_upper_transformer = StringTransformerSymbolContext.of_primitive(
            'TRANSFORMER_SYMBOL',
            string_transformers.to_uppercase(),
        )

        src_file = fs.File('src-file.txt', 'contents of source file')
        src_file_rel_conf = conf_rel_hds(RelHdsOptionType.REL_HDS_CASE)

        expected_contents = src_file.contents.upper()

        path_relativity_variants = PathRelativityVariants({src_file_rel_conf.relativity}, True)
        checker = integration_check.checker(RelOptionsConfiguration(path_relativity_variants,
                                                                    src_file_rel_conf.relativity))

        src_file_symbol = ConstantSuffixPathDdvSymbolContext(
            'SRC_FILE_SYMBOL',
            src_file_rel_conf.relativity,
            src_file.name,
            path_relativity_variants,
        )
        string_source_syntax = string_source_abs_stx.TransformedStringSourceAbsStx(
            string_source_abs_stx.StringSourceOfFileAbsStx(src_file_symbol.abstract_syntax),
            to_upper_transformer.abstract_syntax,
        )
        symbol_table = SymbolContext.symbol_table_of_contexts([
            src_file_symbol,
            to_upper_transformer,
        ])

        # ACT & ASSERT #
        checker.check__abs_stx__layouts__std_source_variants__wo_input(
            self,
            OptionallyOnNewLine(string_source_syntax),
            arrangement_w_tcds(
                symbols=symbol_table,
                hds_contents=src_file_rel_conf.populator_for_relativity_option_root__hds(
                    DirContents([src_file]))
            ),
            MultiSourceExpectation.of_prim__const(
                asrt_string_source.pre_post_freeze__matches_str__const(
                    expected_contents,
                    may_depend_on_external_resources=True,
                ),
                symbol_references=asrt.matches_sequence([
                    src_file_symbol.reference_assertion__path_or_string,
                    to_upper_transformer.reference_assertion,
                ]),
            ),
        )
コード例 #6
0
def arg_config_with_all_accepted_and_default(
    default: RelOptionType
) -> RelOptionArgumentConfigurationWoSuffixRequirement:
    return RelOptionArgumentConfigurationWoSuffixRequirement(
        RelOptionsConfiguration(PathRelativityVariants(RelOptionType, True),
                                default), 'argument_syntax_name')
コード例 #7
0
                 RelOptionArgumentConfigurationWoSuffixRequirement,
                 source_file_path: Optional[Path] = None):
        self.source = source
        self.rel_option_argument_configuration = rel_option_argument_configuration
        self.source_file_path = source_file_path

    def for_path_suffix_required(self, value: bool) -> Arrangement:
        return Arrangement(
            self.source,
            self.rel_option_argument_configuration.config_for(value),
            self.source_file_path)


ARBITRARY_REL_OPT_ARG_CONF = RelOptionArgumentConfigurationWoSuffixRequirement(
    RelOptionsConfiguration(
        PathRelativityVariants({RelOptionType.REL_ACT}, True),
        RelOptionType.REL_ACT), 'argument_syntax_name')

ARG_CONFIG_FOR_ALL_RELATIVITIES = RelOptionArgumentConfigurationWoSuffixRequirement(
    RelOptionsConfiguration(PathRelativityVariants(RelOptionType, True),
                            RelOptionType.REL_HDS_CASE),
    'argument_syntax_name')


def arg_config_with_all_accepted_and_default(
    default: RelOptionType
) -> RelOptionArgumentConfigurationWoSuffixRequirement:
    return RelOptionArgumentConfigurationWoSuffixRequirement(
        RelOptionsConfiguration(PathRelativityVariants(RelOptionType, True),
                                default), 'argument_syntax_name')
コード例 #8
0
def all_rel_options_config(default: RelOptionType) -> RelOptionsConfiguration:
    return RelOptionsConfiguration(
        PathRelativityVariants(ALL_REL_OPTIONS, True), default)
コード例 #9
0
    RELATIVITIES__READ__AFTER_ACT, True)


def relativity_variants(phase_is_after_act: bool) -> PathRelativityVariants:
    return (RELATIVITY_VARIANTS__READ__AFTER_ACT
            if phase_is_after_act else RELATIVITY_VARIANTS__READ__BEFORE_ACT)


ALL_REL_OPTIONS = set(RelOptionType) - {RelOptionType.REL_RESULT}
ALL_HDS_REL_OPTIONS = {RelOptionType.REL_HDS_CASE, RelOptionType.REL_HDS_ACT}

ALL_REL_OPTION_VARIANTS = PathRelativityVariants(ALL_REL_OPTIONS, True)

PATH_ASSERTION_RELATIVITIES = PathRelativityVariants(ALL_REL_OPTIONS, True)

PATH_ASSERTION_REL_OPTS_CONF = RelOptionsConfiguration(
    PATH_ASSERTION_RELATIVITIES, RelOptionType.REL_CWD)


def all_rel_options_config(default: RelOptionType) -> RelOptionsConfiguration:
    return RelOptionsConfiguration(
        PathRelativityVariants(ALL_REL_OPTIONS, True), default)


REL_OPTIONS_CONFIGURATION = all_rel_options_config(RelOptionType.REL_HDS_CASE)

HDS_AND_ABS_RELATIVITY_VARIANTS = PathRelativityVariants(
    ALL_HDS_REL_OPTIONS, True)


def all_rel_options_arg_config(
    argument_syntax_name: str,
コード例 #10
0
ファイル: common.py プロジェクト: emilkarlen/exactly
from exactly_lib.impls.types.parse.shell_syntax import SHELL_KEYWORD
from exactly_lib.tcfs.path_relativity import PathRelativityVariants, RelOptionType
from exactly_lib.type_val_deps.types.path.rel_opts_configuration import RelOptionArgumentConfiguration, \
    RelOptionsConfiguration

SHELL_COMMAND_MARKER = SHELL_KEYWORD

REL_OPTIONS_CONFIGURATION = RelOptionsConfiguration(
    PathRelativityVariants(
        {
            RelOptionType.REL_HDS_CASE,
            RelOptionType.REL_HDS_ACT,
            RelOptionType.REL_ACT,
            RelOptionType.REL_TMP,
            RelOptionType.REL_CWD,
        },
        absolute=True),
    default_option=RelOptionType.REL_HDS_ACT)


def relativity_configuration_of_action_to_check(
        argument_syntax_name: str) -> RelOptionArgumentConfiguration:
    return RelOptionArgumentConfiguration(
        REL_OPTIONS_CONFIGURATION,
        argument_syntax_name=argument_syntax_name,
        path_suffix_is_required=True)
コード例 #11
0
ファイル: type_parser.py プロジェクト: emilkarlen/exactly
class StringTransformerParser(TypeValueParser):
    def parse(
        self,
        fs_location_info: FileSystemLocationInfo,
        token_parser: TokenParser,
    ) -> SymbolDependentValue:
        return parse_string_transformer.parsers().full.parse_from_token_parser(
            token_parser)


class ProgramParser(TypeValueParser):
    _PARSER = parse_program.program_parser(must_be_on_current_line=False, )

    def parse(
        self,
        fs_location_info: FileSystemLocationInfo,
        token_parser: TokenParser,
    ) -> SymbolDependentValue:
        return self._PARSER.parse_from_token_parser(token_parser)


REL_OPTIONS_CONFIGURATION = RelOptionsConfiguration(
    PathRelativityVariants(frozenset(RelOptionType), True),
    RelOptionType.REL_CWD)

REL_OPTION_ARGUMENT_CONFIGURATION = RelOptionArgumentConfiguration(
    REL_OPTIONS_CONFIGURATION,
    syntax_elements.PATH_SYNTAX_ELEMENT.singular_name,
    syntax.PATH_SUFFIX_IS_REQUIRED,
)
コード例 #12
0
def rel_opts_conf_of_single(default_relativity: RelOptionType) -> RelOptionsConfiguration:
    return RelOptionsConfiguration(
        PathRelativityVariants({default_relativity}, False),
        default_relativity,
    )