예제 #1
0
 def parse(self, filename):
     """parse(filename: str) -> None  
     Loads a list of connections from a XML file, appending it to
     self.__connections.
     
     """
     self.open_file(filename)
     root = self.dom.documentElement
     for element in named_elements(root, 'connection'):
         self.add_connection(ExtConnection.parse(element))
     self.refresh_current_id()
예제 #2
0
    def find_disabledpackage_element(self, doc):
        """find_disabledpackage_element(documentElement) -> Node or None

        Returns the package's disabledpackage element, if
        present. Returns None otherwise.

        """
        packages = enter_named_element(doc, 'disabledpackages')
        assert packages
        for package_node in named_elements(packages, 'package'):
            if str(package_node.attributes['name'].value) == self.codepath:
                return package_node
        return None
    def find_disabledpackage_element(self, doc):
        """find_disabledpackage_element(documentElement) -> Node or None

        Returns the package's disabledpackage element, if
        present. Returns None otherwise.

        """
        packages = enter_named_element(doc, 'disabledpackages')
        assert packages
        for package_node in named_elements(packages, 'package'):
            if str(package_node.attributes['name'].value) == self.codepath:
                return package_node
        return None
예제 #4
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
예제 #6
0
    def load_packages(self):
        """load_packages() -> None

        Loads the appropriate packages from .vistrails/startup.xml.
        """
        
        def parse_package(node):
            is_value = (lambda node: node.nodeName in
                        set(['bool', 'str', 'int', 'float']))
            package_name = str(node.attributes['name'].value)
            self._package_manager.add_package(package_name)
        dom = self.startup_dom()
        doc = dom.documentElement
        packages_node = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages_node, 'package'):
            parse_package(package_node)
예제 #7
0
 def parse(self, filename):
     """parse(filename: str) -> None  
     Loads a collection of bookmarks from a XML file, appending it to
     self.bookmarks.
     
     """
     self.open_file(filename)
     root = self.dom.documentElement
     version = None
     version = root.getAttribute('version')
     if version == '1.0':
         for element in named_elements(root, 'bookmark'):    
             self.add_bookmark(Bookmark.parse(element))
     else:
         core.debug.warning("Old bookmarks file found. File will be reset.")
     self.refresh_current_id()
     self.changed = False
     self.updateGUI = True
예제 #8
0
    def load_packages(self):
        """load_packages() -> None

        Loads the appropriate packages from .vistrails/startup.xml.
        """
        def parse_package(node):
            is_value = (lambda node: node.nodeName in set(
                ['bool', 'str', 'int', 'float']))
            package_name = str(node.attributes['name'].value)
            # FIXME use more robust checks here!
            if package_name != 'basic_modules' and \
                    package_name != 'abstraction':
                self._package_manager.add_package(package_name)

        dom = self.startup_dom()
        doc = dom.documentElement
        packages_node = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages_node, 'package'):
            parse_package(package_node)
예제 #9
0
    def find_own_dom_element(self):
        """find_own_dom_element() -> (DOM, Node)

        Opens the startup DOM, looks for the element that belongs to the package,
        and returns DOM and node. Creates a new one if element is not there.

        """
        dom = get_vistrails_application().vistrailsStartup.startup_dom()
        doc = dom.documentElement
        packages = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages, 'package'):
            if str(package_node.attributes['name'].value) == self.codepath:
                return (dom, package_node)

        # didn't find anything, create a new node

        package_node = dom.createElement("package")
        package_node.setAttribute('name', self.codepath)
        packages.appendChild(package_node)

        get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
        return (dom, package_node)
예제 #10
0
파일: startup.py 프로젝트: imclab/vistrails
    def load_packages(self):
        """load_packages() -> None

        Loads the appropriate packages from .vistrails/startup.xml.
        """
        
        for package_name in self._needed_packages:
            self._package_manager.add_package(package_name)

        def parse_package(node):
            is_value = (lambda node: node.nodeName in
                        set(['bool', 'str', 'int', 'float']))
            package_name = str(node.attributes['name'].value)
            # FIXME use more robust checks here!
            if package_name != 'basic_modules' and \
                    package_name != 'abstraction':
                self._package_manager.add_package(package_name)
        dom = self.startup_dom()
        doc = dom.documentElement
        packages_node = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages_node, 'package'):
            parse_package(package_node)
    def find_own_dom_element(self):
        """find_own_dom_element() -> (DOM, Node)

        Opens the startup DOM, looks for the element that belongs to the package,
        and returns DOM and node. Creates a new one if element is not there.

        """
        dom = get_vistrails_application().vistrailsStartup.startup_dom()
        doc = dom.documentElement
        packages = enter_named_element(doc, 'packages')
        for package_node in named_elements(packages, 'package'):
            if str(package_node.attributes['name'].value) == self.codepath:
                return (dom, package_node)

        # didn't find anything, create a new node

        package_node = dom.createElement("package")
        package_node.setAttribute('name', self.codepath)
        packages.appendChild(package_node)

        get_vistrails_application().vistrailsStartup.write_startup_dom(dom)
        return (dom, package_node)
예제 #12
0
 def find_it():
     packages = enter_named_element(doc, 'packages')
     for package_node in named_elements(packages, 'package'):
         if str(package_node.attributes['name'].value) == self.codepath:
             return package_node
 def find_it():
     packages = enter_named_element(doc, 'packages')
     for package_node in named_elements(packages, 'package'):
         if str(package_node.attributes['name'].value) == self.codepath:
             return package_node