Exemplo n.º 1
0
 def set_func_list(self):
     """
     Set the function selection list in TUI session.
     """
     for ip in range(2):
         choice, defaults, slices = RetrieveData.get_choice(ip)
         if os.path.isfile(self.custom):
             choice.insert(0, [4, 1, 0, "customize"])
             defaults[0x04] = [1]
             for i in range(len(slices)):
                 slices[i] += 1
             slices.insert(0, 0)
         defaults[0x40].append(1) #adblocks-hostsx
         defaults[0x40].append(2) #adblock-mvp
         if 0x10 in defaults:
         #http://stackoverflow.com/questions/4915920/how-to-delete-an-item-in-a-list-if-it-exists-python
             try:
                 defaults[0x10].remove(256) #no github
                 defaults[0x10].remove(32) #no wiki
             except ValueError:
                 pass
         self.choice[ip] = choice
         self.slices[ip] = slices
         funcs = []
         for func in choice:
             if func[1] in defaults[func[0]]:
                 funcs.append(1)
             else:
                 funcs.append(0)
         self._funcs[ip] = funcs
Exemplo n.º 2
0
 def set_func_list(self):
     """
     Set the function selection list in TUI session.
     """
     for ip in range(2):
         choice, defaults, slices = RetrieveData.get_choice(ip)
         if os.path.isfile(self.custom):
             choice.insert(0, [4, 1, 0, "customize"])
             defaults[0x04] = [1]
             for i in range(len(slices)):
                 slices[i] += 1
             slices.insert(0, 0)
         self.choice[ip] = choice
         self.slices[ip] = slices
         funcs = []
         for func in choice:
             if func[1] in defaults[func[0]]:
                 funcs.append(1)
             else:
                 funcs.append(0)
         self._funcs[ip] = funcs
Exemplo n.º 3
0
    def set_func_list(self, new=0):
        """
        Draw the function list and decide whether to load the default
        selection configuration or not.

        :param new: A flag indicating whether to load the default selection
            configuration or not. Default value is `0`.

            ===  ===================
            new  Operation
            ===  ===================
            0    Use user config.
            1    Use default config.
            ===  ===================
        :type new: int
        """
        self.ui.Functionlist.clear()
        self.ui.FunctionsBox.setTitle(_translate(
            "Util", "Functions", None))
        if new:
            for ip in range(2):
                choice, defaults, slices = RetrieveData.get_choice(ip)
                if self.custom is None: # fix bug that "self.custom" is None
                    self.custom = "custom.hosts" # as above
                if os.path.isfile(self.custom):
                    choice.insert(0, [4, 1, 0, "customize"])
                    defaults[0x04] = [1]
                    for i in range(len(slices)):
                        slices[i] += 1
                    slices.insert(0, 0)
                self.choice[ip] = choice
                self.slices[ip] = slices
                funcs = []
                for func in choice:
                    if func[1] in defaults[func[0]]:
                        funcs.append(1)
                    else:
                        funcs.append(0)
                self._funcs[ip] = funcs
Exemplo n.º 4
0
 def set_func_list(cls):
     """
     Set the function selection list in TUI session.
     Modified from tui.hostsutil.HostsUtil.set_func_list()
     """
     for ip in range(2):
         choice, defaults, slices = RetrieveData.get_choice(ip)
         if os.path.isfile(cls.custom):
             choice.insert(0, [4, 1, 0, "customize"])
             defaults[0x04] = [1] 
             for i in range(len(slices)):
                 slices[i] += 1
             slices.insert(0, 0)
         cls.choice[ip] = choice
         cls.slices[ip] = slices
         funcs = []
         for func in choice:
             if func[1] in defaults[func[0]]:
                 funcs.append(1)
             else:
                 funcs.append(0)
         cls.funcs[ip] = funcs
Exemplo n.º 5
0
    def set_func_list(self, new=0):
        """
        Draw the function list and decide whether to load the default
        selection configuration or not.

        :param new: A flag indicating whether to load the default selection
            configuration or not. Default value is `0`.

            ===  ===================
            new  Operation
            ===  ===================
            0    Use user config.
            1    Use default config.
            ===  ===================
        :type new: int
        """
        self.ui.Functionlist.clear()
        self.ui.FunctionsBox.setTitle(_translate(
            "Util", "Functions", None))
        if new:
            for ip in range(2):
                choice, defaults, slices = RetrieveData.get_choice(ip)
                if os.path.isfile(self.custom):
                    choice.insert(0, [4, 1, 0, "customize"])
                    defaults[0x04] = [1]
                    for i in range(len(slices)):
                        slices[i] += 1
                    slices.insert(0, 0)
                self.choice[ip] = choice
                self.slices[ip] = slices
                funcs = []
                for func in choice:
                    if func[1] in defaults[func[0]]:
                        funcs.append(1)
                    else:
                        funcs.append(0)
                self._funcs[ip] = funcs