Ticket #3542: processor_options.diff

File processor_options.diff, 4.1 kB (added by anonymous, 5 months ago)

fixes #3542

  • graphviz/graphviz.py

    old new  
    179179        encoding = 'utf-8' 
    180180        if type(content) == type(u''): 
    181181            content  = content.encode(encoding) 
    182             sha_text = self.processor.encode(encoding) + self.processor_options.encode(encoding) + content 
     182            sha_text = self.processor.encode(encoding) + str(self.processor_options).encode(encoding) + content 
    183183 
    184184        else: 
    185             sha_text = self.processor + self.processor_options + content 
     185            sha_text = self.processor + str(self.processor_options) + content 
    186186 
    187187        sha_key  = sha.new(sha_text).hexdigest() 
    188188        img_name = '%s.%s.%s' % (sha_key, self.processor, self.out_format) # cache: hash.<dot>.<png> 
     
    206206            # Antialias PNGs with rsvg, if requested 
    207207            if self.out_format == 'png' and self.png_anti_alias == True: 
    208208                # 1. SVG output 
    209                 cmd = [proc_cmd, self.processor_options, '-Tsvg', '-o%s.svg' % img_path] 
     209                cmd = [proc_cmd] + self.processor_options + ['-Tsvg', '-o%s.svg' % img_path] 
    210210                #self.log.debug('render_macro: svg output - running command %s' % cmd) 
    211211                out, err = self.launch(cmd, content) 
    212212                if len(out) or len(err): 
     
    222222                    return self.show_err(msg).getvalue() 
    223223             
    224224            else: # Render other image formats 
    225                 cmd = [proc_cmd, self.processor_options, '-T%s' % self.out_format, '-o%s' % img_path] 
     225                cmd = [proc_cmd] + self.processor_options + ['-T%s' % self.out_format, '-o%s' % img_path] 
    226226                #self.log.debug('render_macro: render other image formats - running command %s' % cmd) 
    227227                out, err = self.launch(cmd, content) 
    228228                if len(out) or len(err): 
     
    234234 
    235235                # Create the map if not in cache 
    236236                if not os.path.exists(map_path): 
    237                     cmd = [proc_cmd, self.processor_options, '-Tcmap', '-o%s' % map_path] 
     237                    cmd = [proc_cmd] + self.processor_options + ['-Tcmap', '-o%s' % map_path] 
    238238                    #self.log.debug('render_macro: create map if not in cache - running command %s' % cmd) 
    239239                    out, err = self.launch(cmd, content) 
    240240                    if len(out) or len(err): 
     
    379379            #self.log.debug('self.rsvg_path: %s' % self.rsvg_path) 
    380380 
    381381        # get default graph/node/edge attributes 
    382         self.processor_options = '' 
    383         default_attributes = [ o for o in self.config.options('graphviz') if o[0].startswith('default_') ] 
    384         if default_attributes: 
    385            graph_attributes   = [ o for o in default_attributes if o[0].startswith('default_graph_') ] 
    386            node_attributes    = [ o for o in default_attributes if o[0].startswith('default_node_') ] 
    387            edge_attributes    = [ o for o in default_attributes if o[0].startswith('default_edge_') ] 
    388            if graph_attributes: 
    389                self.processor_options += " ".join([ "-G" + o[0].replace('default_graph_', '') + "=" + o[1] for o in graph_attributes]) + " " 
    390            if node_attributes: 
    391                self.processor_options += " ".join([ "-N" + o[0].replace('default_node_', '') + "=" + o[1] for o in node_attributes]) + " " 
    392            if edge_attributes: 
    393                self.processor_options += " ".join([ "-E" + o[0].replace('default_edge_', '') + "=" + o[1] for o in edge_attributes]) 
     382        self.processor_options = [] 
     383        for attr, val in self.config.options('graphviz'): 
     384           m = re.match("default_(graph|node|edge)_(.*)$", attr) 
     385        
     386           if m: 
     387              self.processor_options.append('-%s=%s' % (m.group(1)[0].upper() + m.group(2), val)) 
     388        # self.log.debug(self.processor_options) 
    394389 
    395  
    396390        # check if we should run the cache manager 
    397391        self.cache_manager = self.boolean(self.config.get('graphviz', 'cache_manager', False)) 
    398392        if self.cache_manager: