Ejemplo n.º 1
0
    def value(self, newval):
        self.__value = str(newval)
        if self.__strip_whitespaces:
            self.__value = unescaped_strip(self.__value)

        self.__prepare_list()
        self.__prepare_dict()
Ejemplo n.º 2
0
    def value(self, newval):
        self.__value = str(newval)
        if self.__strip_whitespaces:
            self.__value = unescaped_strip(self.__value)

        self.__prepare_list()
        self.__prepare_dict()
Ejemplo n.º 3
0
    def __prepare_list(self):
        self.__escaped_list = self.__get_raw_list()

        if self.__strip_whitespaces:
            self.__escaped_list = [unescaped_strip(elem)
                                   for elem in self.__escaped_list]

        self.__unescaped_list = [unescape(elem)
                                 for elem in self.__escaped_list]

        if self.__remove_empty_iter_elements:
            # Need to do after stripping, cant use builtin functionality of
            # split.
            while "" in self.__unescaped_list:
                self.__unescaped_list.remove("")
            while "" in self.__escaped_list:
                self.__escaped_list.remove("")
Ejemplo n.º 4
0
    def __prepare_list(self):
        self.__escaped_list = self.__get_raw_list()

        if self.__strip_whitespaces:
            self.__escaped_list = [unescaped_strip(elem)
                                   for elem in self.__escaped_list]

        self.__unescaped_list = [unescape(elem)
                                 for elem in self.__escaped_list]

        if self.__remove_empty_iter_elements:
            # Need to do after stripping, cant use builtin functionality of
            # split.
            while "" in self.__unescaped_list:
                self.__unescaped_list.remove("")
            while "" in self.__escaped_list:
                self.__escaped_list.remove("")
Ejemplo n.º 5
0
    def __prepare_dict(self):
        # We must keep order here, user can drop it later.
        self.__dict = OrderedDict()
        for elem in self.__get_raw_list():
            key_val = unescaped_split(self.__dict_delimiter, elem, max_split=1)

            if self.__strip_whitespaces:
                key_val = [unescaped_strip(item) for item in key_val]

            key_val = [unescape(item) for item in key_val]

            if not any(item != "" for item in key_val):
                continue

            if len(key_val) < 2:
                self.__dict[key_val[0]] = ""
            else:
                self.__dict[key_val[0]] = key_val[1]
Ejemplo n.º 6
0
    def __prepare_dict(self):
        # We must keep order here, user can drop it later.
        self.__dict = OrderedDict()
        for elem in self.__get_raw_list():
            key_val = unescaped_split(self.__dict_delimiter, elem, max_split=1)

            if self.__strip_whitespaces:
                key_val = [unescaped_strip(item) for item in key_val]

            key_val = [unescape(item) for item in key_val]

            if not any(item != "" for item in key_val):
                continue

            if len(key_val) < 2:
                self.__dict[key_val[0]] = ""
            else:
                self.__dict[key_val[0]] = key_val[1]