Esempio n. 1
0
    def __init__(self,
                 key,
                 value,
                 origin="",
                 strip_whitespaces=True,
                 list_delimiters=(",", ";"),
                 from_cli=False):
        """
        Initializes a new Setting,

        :param key:               The key of the Setting
        :param value:             The value, if you apply conversions to this
                                  object these will be applied to this value.
        :param origin:            The originating file. This will be used for
                                  path conversions and the last part will be
                                  stripped of. If you want to specify a
                                  directory as origin be sure to end it with a
                                  directory seperator.
        :param strip_whitespaces: Whether to strip whitespaces from the value
                                  or not
        :param list_delimiters:   Delimiters for list conversion
        :param from_cli:          True if this setting was read by the
                                  CliParser.
        """
        if not isinstance(from_cli, bool):
            raise TypeError("from_cli needs to be a boolean value.")

        StringConverter.__init__(self,
                                 value,
                                 strip_whitespaces=strip_whitespaces,
                                 list_delimiters=list_delimiters)
        self.from_cli = from_cli
        self.key = key
        self.origin = str(origin)
Esempio n. 2
0
    def __init__(self,
                 key,
                 value,
                 origin="",
                 strip_whitespaces=True,
                 list_delimiters=[",", ";"],
                 from_cli=False):
        """
        Initializes a new Setting,

        :param key: The key of the Setting
        :param value: The value, if you apply conversions to this object these will be applied to this value.
        :param origin: The originating file. This will be used for path conversions and the last part will be stripped
        of. If you want to specify a directory as origin be sure to end it with a directory seperator.
        :param strip_whitespaces: Whether to strip whitespaces from the value or not
        :param list_delimiters: Delimiters for list conversion
        :param from_cli: True of this setting was read by the CliParser.
        """
        if not isinstance(from_cli, bool):
            raise TypeError("from_cli needs to be a boolean value.")

        StringConverter.__init__(self,
                                 value,
                                 strip_whitespaces=strip_whitespaces,
                                 list_delimiters=list_delimiters)
        self.from_cli = from_cli
        self.key = key
        self.origin = str(origin)