예제 #1
0
 def parse(element):
     """ parse(element) -> Bookmark
     Parse an XML object representing a bookmark and returns a Bookmark
     object. 
     It checks if the vistrails file/connection exists.
     
     """
     bookmark = Bookmark()
     bookmark.id = int(element.getAttribute('id'))
     bookmark.parent = str(element.getAttribute('parent'))
     bookmark.name = element.getAttribute('name')
     bookmark.type = element.getAttribute('type')
     if bookmark.type == "item":
         for n in element.childNodes:
             if n.localName == "locator":
                 if str(n.getAttribute('type')) == 'file':
                     bookmark.locator = FileLocator.parse(n)
                 elif str(n.getAttribute('type')) == 'db':
                     bookmark.locator = DBLocator.parse(n)
                 else:
                     bookmark.locator = None
                 bookmark.error = bookmark.get_locator_error()
                 break
         bookmark.pipeline = int(element.getAttribute('pipeline'))
     return bookmark
예제 #2
0
 def parse_locator(text):
     locator = None
     wrapper = XMLWrapper()
     dom = wrapper.create_document_from_string(text)
     root = dom.documentElement
     version = None
     version = root.getAttribute('version')
     if version == '1.0':
         for element in named_elements(root, 'locator'):
             if str(element.getAttribute('type')) == 'file':
                 locator = FileLocator.parse(element)
             elif str(element.getAttribute('type')) == 'db':
                 locator = DBLocator.parse(element)
     return locator
 def parse_locator(text):
     locator = None
     wrapper = XMLWrapper()
     dom = wrapper.create_document_from_string(text)
     root = dom.documentElement
     version = None
     version = root.getAttribute('version')
     if version == '1.0':
         for element in named_elements(root, 'locator'):
             if str(element.getAttribute('type')) == 'file':
                 locator = FileLocator.parse(element)
             elif str(element.getAttribute('type')) == 'db':
                 locator = DBLocator.parse(element)
     return locator