Пример #1
0
	def __init__(self, name, version, key,
		block_paths, block_dtd, default_flow_graph, generator,
		license='', website=None, colors=[]):
		"""
		Make a platform from the arguments.
		@param name the platform name
		@param version the version string
		@param key the unique platform key
		@param block_paths the file paths to blocks in this platform
		@param block_dtd the dtd validator for xml block wrappers
		@param default_flow_graph the default flow graph file path
		@param generator the generator class for this platform
		@param colors a list of title, color_spec tuples
		@param license a multi-line license (first line is copyright)
		@param website the website url for this platform
		@return a platform object
		"""
		_Element.__init__(self)
		self._name = name
		self._version = version
		self._key = key
		self._license = license
		self._website = website
		self._block_paths = block_paths
		self._block_dtd = block_dtd
		self._default_flow_graph = default_flow_graph
		self._generator = generator
		self._colors = colors
		#create a dummy flow graph for the blocks
		self._flow_graph = _Element(self)
		#search for *.xml files in the given search path

		self.loadblocks();
Пример #2
0
    def __init__(self,
                 name,
                 version,
                 key,
                 block_paths,
                 block_dtd,
                 default_flow_graph,
                 generator,
                 license='',
                 website=None,
                 colors=None):
        """
        Make a platform from the arguments.

        Args:
            name: the platform name
            version: the version string
            key: the unique platform key
            block_paths: the file paths to blocks in this platform
            block_dtd: the dtd validator for xml block wrappers
            default_flow_graph: the default flow graph file path
            generator: the generator class for this platform
            colors: a list of title, color_spec tuples
            license: a multi-line license (first line is copyright)
            website: the website url for this platform

        Returns:
            a platform object
        """
        _Element.__init__(self)
        self._name = name
        # Save the verion string to the first
        self._version = version[0]
        self._version_major = version[1]
        self._version_api = version[2]
        self._version_minor = version[3]
        self._version_short = version[1] + "." + version[2] + "." + version[3]

        self._key = key
        self._license = license
        self._website = website
        self._block_paths = list(set(block_paths))
        self._block_dtd = block_dtd
        self._default_flow_graph = default_flow_graph
        self._generator = generator
        self._colors = colors or []
        #create a dummy flow graph for the blocks
        self._flow_graph = _Element(self)

        self._blocks = None
        self._blocks_n = None
        self._category_trees_n = None
        self._domains = dict()
        self._connection_templates = dict()
        self.load_blocks()
Пример #3
0
    def __init__(self, name, version, key,
                 block_paths, block_dtd, default_flow_graph, generator,
                 license='', website=None, colors=None):
        """
        Make a platform from the arguments.

        Args:
            name: the platform name
            version: the version string
            key: the unique platform key
            block_paths: the file paths to blocks in this platform
            block_dtd: the dtd validator for xml block wrappers
            default_flow_graph: the default flow graph file path
            generator: the generator class for this platform
            colors: a list of title, color_spec tuples
            license: a multi-line license (first line is copyright)
            website: the website url for this platform

        Returns:
            a platform object
        """
        _Element.__init__(self)
        self._name = name
        # Save the verion string to the first
        self._version = version[0]
        self._version_major = version[1]
        self._version_api = version[2]
        self._version_minor = version[3]
        self._version_short = version[1] + "." + version[2] + "." + version[3]

        self._key = key
        self._license = license
        self._website = website
        self._block_paths = list(set(block_paths))
        self._block_dtd = block_dtd
        self._default_flow_graph = default_flow_graph
        self._generator = generator
        self._colors = colors or []
        #create a dummy flow graph for the blocks
        self._flow_graph = _Element(self)

        self._blocks = None
        self._blocks_n = None
        self._category_trees_n = None
        self._domains = dict()
        self._connection_templates = dict()
        self.load_blocks()
Пример #4
0
    def __init__(self,
                 name,
                 version,
                 key,
                 block_paths,
                 block_dtd,
                 default_flow_graph,
                 generator,
                 license='',
                 website=None,
                 colors=[]):
        """
		Make a platform from the arguments.
		
		Args:
		    name: the platform name
		    version: the version string
		    key: the unique platform key
		    block_paths: the file paths to blocks in this platform
		    block_dtd: the dtd validator for xml block wrappers
		    default_flow_graph: the default flow graph file path
		    generator: the generator class for this platform
		    colors: a list of title, color_spec tuples
		    license: a multi-line license (first line is copyright)
		    website: the website url for this platform
		
		Returns:
		    a platform object
		"""
        _Element.__init__(self)
        self._name = name
        self._version = version
        self._key = key
        self._license = license
        self._website = website
        self._block_paths = block_paths
        self._block_dtd = block_dtd
        self._default_flow_graph = default_flow_graph
        self._generator = generator
        self._colors = colors
        #create a dummy flow graph for the blocks
        self._flow_graph = _Element(self)
        #search for *.xml files in the given search path

        self.loadblocks()
Пример #5
0
    def __init__(self,
                 name,
                 version,
                 key,
                 block_paths,
                 block_dtd,
                 default_flow_graph,
                 generator,
                 license='',
                 website=None,
                 colors=[]):
        """
		Make a platform from the arguments.
		@param name the platform name
		@param version the version string
		@param key the unique platform key
		@param block_paths the file paths to blocks in this platform
		@param block_dtd the dtd validator for xml block wrappers
		@param default_flow_graph the default flow graph file path
		@param generator the generator class for this platform
		@param colors a list of title, color_spec tuples
		@param license a multi-line license (first line is copyright)
		@param website the website url for this platform
		@return a platform object
		"""
        _Element.__init__(self)
        self._name = name
        self._version = version
        self._key = key
        self._license = license
        self._website = website
        self._block_paths = block_paths
        self._block_dtd = block_dtd
        self._default_flow_graph = default_flow_graph
        self._generator = generator
        self._colors = colors
        #create a dummy flow graph for the blocks
        self._flow_graph = _Element(self)
        #search for *.xml files in the given search path
        xml_files = list()
        for block_path in self._block_paths:
            if os.path.isfile(block_path): xml_files.append(block_path)
            elif os.path.isdir(block_path):
                for dirpath, dirnames, filenames in os.walk(block_path):
                    for filename in sorted(
                            filter(lambda f: f.endswith('.xml'), filenames)):
                        xml_files.append(os.path.join(dirpath, filename))
        #load the blocks
        self._blocks = odict()
        self._blocks_n = odict()
        self._block_tree_files = list()
        for xml_file in xml_files:
            try:  #try to add the xml file as a block wrapper
                ParseXML.validate_dtd(xml_file, self._block_dtd)
                n = ParseXML.from_file(xml_file).find('block')
                #inject block wrapper path
                n['block_wrapper_path'] = xml_file
                block = self.Block(self._flow_graph, n)
                key = block.get_key()
                #test against repeated keys
                if key in self.get_block_keys():
                    print >> sys.stderr, 'Warning: Block with key "%s" already exists.\n\tIgnoring: %s' % (
                        key, xml_file)
                #store the block
                else:
                    self._blocks[key] = block
                    self._blocks_n[key] = n
            except ParseXML.XMLSyntaxError, e:
                try:  #try to add the xml file as a block tree
                    ParseXML.validate_dtd(xml_file, BLOCK_TREE_DTD)
                    self._block_tree_files.append(xml_file)
                except ParseXML.XMLSyntaxError, e:
                    print >> sys.stderr, 'Warning: Block validation failed:\n\t%s\n\tIgnoring: %s' % (
                        e, xml_file)
Пример #6
0
	def __init__(self, name, version, key,
		block_paths, block_dtd, default_flow_graph, generator,
		license='', website=None, colors=[]):
		"""
		Make a platform from the arguments.
		@param name the platform name
		@param version the version string
		@param key the unique platform key
		@param block_paths the file paths to blocks in this platform
		@param block_dtd the dtd validator for xml block wrappers
		@param default_flow_graph the default flow graph file path
		@param generator the generator class for this platform
		@param colors a list of title, color_spec tuples
		@param license a multi-line license (first line is copyright)
		@param website the website url for this platform
		@return a platform object
		"""
		_Element.__init__(self)
		self._name = name
		self._version = version
		self._key = key
		self._license = license
		self._website = website
		self._block_paths = block_paths
		self._block_dtd = block_dtd
		self._default_flow_graph = default_flow_graph
		self._generator = generator
		self._colors = colors
		#create a dummy flow graph for the blocks
		self._flow_graph = _Element(self)
		#search for *.xml files in the given search path
		xml_files = list()
		for block_path in self._block_paths:
			if os.path.isfile(block_path): xml_files.append(block_path)
			elif os.path.isdir(block_path):
				for dirpath, dirnames, filenames in os.walk(block_path):
					for filename in sorted(filter(lambda f: f.endswith('.xml'), filenames)):
						xml_files.append(os.path.join(dirpath, filename))
		#load the blocks
		self._blocks = odict()
		self._blocks_n = odict()
		self._block_tree_files = list()
		for xml_file in xml_files:
			try: #try to add the xml file as a block wrapper
				ParseXML.validate_dtd(xml_file, self._block_dtd)
				n = ParseXML.from_file(xml_file).find('block')
				#inject block wrapper path
				n['block_wrapper_path'] = xml_file
				block = self.Block(self._flow_graph, n)
				key = block.get_key()
				#test against repeated keys
				try:
					assert key not in self.get_block_keys()
					#store the block
					self._blocks[key] = block
					self._blocks_n[key] = n
				except AssertionError:
					print >> sys.stderr, 'Warning: Block with key "%s" already exists.\n\tIgnoring: %s'%(key, xml_file)
			except ParseXML.XMLSyntaxError, e: 
				try: #try to add the xml file as a block tree
					ParseXML.validate_dtd(xml_file, BLOCK_TREE_DTD)
					self._block_tree_files.append(xml_file)
				except ParseXML.XMLSyntaxError, e:
					print >> sys.stderr, 'Warning: Block validation failed:\n\t%s\n\tIgnoring: %s'%(e, xml_file)