Example #1
0
 def testload2(self):
     s = item_create_instance(Setting(data_type=int), 'id')
     node = XMLItem('id', 'fff')
     self.assertRaises(ValueError, s.load, node)
     node = XMLItem('id', '5')
     s.load(node)
     self.assert_(s.get_value() == 5)
     s.copy()
Example #2
0
 def testload(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     node = XMLItem('id', 'fff')
     s.load(node)
     self.assert_(s.get_value() == 'fff')
     node = XMLItem('id', None)
     s.load(node)
     self.assert_(s.get_value() is None)
     s.copy()
Example #3
0
 def __format(self):
     root = XMLGroup('medit-session')
     for d in self.__docs:
         root.add_child(XMLItem('doc', d))
     if self.__active is not None:
         root.add_child(XMLItem('active', str(self.__active)))
     if self.__file_selector_dir is not None:
         root.add_child(XMLItem('file-selector', self.__file_selector_dir))
     return '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' + \
             root.get_string()
Example #4
0
 def save(self):
     if not self.is_default():
         value = self.get_value()
         items = [
             XMLItem('working_dir', value[0]),
             XMLItem('cmd', value[1])
         ]
         return [XMLGroup(self.get_id(), items)]
     else:
         return []
Example #5
0
 def testsave3(self):
     s = item_create_instance(Setting(default='444', data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('fff')
     self.assert_(s.save() == [XMLItem('id', 'fff')])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.copy()
     s = item_create_instance(
         Setting(default='444', data_type=str, null_ok=True), 'id')
     s.set_value(None)
     self.assert_(s.save() == [XMLItem('id', None)])
Example #6
0
 def testsave2(self):
     s = item_create_instance(Setting(data_type=str), 'id')
     self.assert_(s.save() == [])
     s.set_value('')
     self.assert_(s.save() == [XMLItem('id', '')])
     s.reset()
     self.assert_(s.save() == [])
     s.copy()
Example #7
0
 def save(self):
     if not self.is_default():
         value = self.get_value()
         if value is not None:
             value = str(value)
         return [XMLItem(self.get_id(), value)]
     else:
         return []
Example #8
0
def _create_node(elm_name, attr_name, name, string):
    if elm_name is not None:
        node = XMLItem(elm_name, string)
        node.set_attr(attr_name, name)
    else:
        node = XMLItem(name, string)
    return node
Example #9
0
    def save(self):
        if self.is_default():
            return []

        value = self.get_value()

        if value in [RUN_FROM_BUILD_DIR, RUN_FROM_EXE_DIR]:
            dir = None
        else:
            dir = value

        item = XMLItem(self.get_id(), dir)

        if value == RUN_FROM_BUILD_DIR:
            item.set_attr('type', 'build-dir')
        elif value == RUN_FROM_EXE_DIR:
            item.set_attr('type', 'exe-dir')
        else:
            item.set_attr('type', 'dir')

        return [item]