Changeset 1229

Show
Ignore:
Timestamp:
08/03/07 13:52:25 (6 years ago)
Author:
kop-labs
Message:

Added Functions to Move Up and Move Down options

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/k0p/umitInterfaceEditor/ProfileCore.py

    r1166 r1229  
    170170                result.append(tmp_po) 
    171171        return result 
    172                  
    173                      
     172 
    174173         
    175174    def add_section(self): 
    176175        pass 
     176    def remove_opt(self, section, name): 
     177         
     178         
     179        elem = self.search_option(section, name) 
     180        root = self.xml_parse.getElementsByTagName(self.root_tag)[0] 
     181        sec = root.getElementsByTagName(section) 
     182         
     183        sec[0].removeChild(elem) 
    177184    def remove_section(self, section_name): 
    178185        ''' 
     
    187194        elem = self.search_in_groups(name) 
    188195        root.removeChild(elem) 
     196         
     197         
    189198         
    190199    def search_in_groups(self, name): 
     
    248257        return result 
    249258         
    250      
     259    def add_option_before(self, section_name, option, before): 
     260 
     261        result = self.xml.getElementsByTagName(section_name)[0].insertBefore(option, before)        
    251262     
    252263    def add_option(self, section_name, tagname, label, option=None,  
     
    296307                result.appendChild(i) 
    297308         
    298      
     309    def get_prev(self, section):  
     310        ''' 
     311        get prev section  
     312        ''' 
     313                 
     314        element = self.xml.getElementsByTagName('groups')[0] 
     315        element_group = element.getElementsByTagName(u'group') 
     316        result = None  
     317        for i in element_group: 
     318            if i.getAttribute('name') == name: 
     319                break 
     320             
     321            result = i 
     322        return result 
     323     
     324     
     325     
     326     
     327    def move_section_left(self, section): 
     328        none_prev = self.get_prev(section) 
     329         
     330    def move_section_right(self, section): 
     331        pass 
     332    def get_list_opt(self, section): 
     333        pass 
     334    def get_prev_opt(section, option): 
     335        elem = self.search_option(section, option) 
     336        pass 
     337 
     338    def move_option_up(self, section,option, option_up): 
     339        option_prev =  self.search_option(section, option_up) 
     340        if option_up == None :  
     341            pass 
     342        else:  
     343            elem = self.search_option(section, option) 
     344            self.remove_opt(section, option) 
     345            self.add_option_before(section, elem, option_prev) 
     346 
     347             
     348         
     349    def move_option_down(self, section, option, option_down): 
     350        option_next =  self.search_option(section, option_down) 
     351        if option_down == None :  
     352            pass 
     353        else:  
     354            self.remove_opt(section, option_down) 
     355            elem = self.search_option(section, option) 
     356            self.add_option_before(section, option_next, elem) 
     357             
     358 
    299359     
    300360     
     
    329389    #s.add_option('Scan', 'option_list', 'dasdas', 'dasda',  
    330390    #            'dasdas', ['sdas','dasda'], 'Timing: ') 
     391    s.remove_opt('Scan', 'TCP scan: ') 
    331392    s.print_screen() 
    332393