Ejemplo n.º 1
0
    def _setup_env_name(self, env_name):
        if env_name is not None:
            if self.apply_env_prefix:
                return self.env_prefix + env_name
            return env_name

        if self.format_env:
            return yapconf.change_case(
                self.env_prefix + "_".join(self.fq_name.split(self.separator)),
                "_").upper()
        else:
            return "".join(self.fq_name.split(self.separator))
Ejemplo n.º 2
0
 def _get_argparse_names(self, prefix_chars):
     cli_prefix = self._format_prefix_for_cli(prefix_chars)
     if self.format_cli:
         cli_name = yapconf.change_case(self.name, prefix_chars)
     else:
         cli_name = self.name
     if self.cli_short_name:
         return [
             "{0}{1}".format(cli_prefix, cli_name),
             "{0}{1}".format(prefix_chars, self.cli_short_name)
         ]
     else:
         return ["{0}{1}".format(cli_prefix, cli_name)]
Ejemplo n.º 3
0
    def _get_argparse_names(self, prefix_chars):
        cli_prefix = self._format_prefix_for_cli(prefix_chars)
        if self.format_cli:
            cli_name = yapconf.change_case(self.name, prefix_chars)
        else:
            cli_name = self.name

        if self.default:
            full_prefix = "{0}no{1}".format(cli_prefix, prefix_chars)
        else:
            full_prefix = cli_prefix

        full_name = "{0}{1}".format(full_prefix, cli_name)

        if self.cli_short_name:
            return [
                full_name, "{0}{1}".format(full_prefix, self.cli_short_name)
            ]
        else:
            return [full_name]
Ejemplo n.º 4
0
def test_convert_to_kebab(orig, expected):
    assert expected == yapconf.change_case(orig)
Ejemplo n.º 5
0
def test_convert_to_snake(orig, expected):
    assert expected == yapconf.change_case(orig, separator='_')