Ticket #3542: processor_options.diff
| File processor_options.diff, 4.1 kB (added by anonymous, 5 months ago) |
|---|
-
graphviz/graphviz.py
old new 179 179 encoding = 'utf-8' 180 180 if type(content) == type(u''): 181 181 content = content.encode(encoding) 182 sha_text = self.processor.encode(encoding) + s elf.processor_options.encode(encoding) + content182 sha_text = self.processor.encode(encoding) + str(self.processor_options).encode(encoding) + content 183 183 184 184 else: 185 sha_text = self.processor + s elf.processor_options+ content185 sha_text = self.processor + str(self.processor_options) + content 186 186 187 187 sha_key = sha.new(sha_text).hexdigest() 188 188 img_name = '%s.%s.%s' % (sha_key, self.processor, self.out_format) # cache: hash.<dot>.<png> … … 206 206 # Antialias PNGs with rsvg, if requested 207 207 if self.out_format == 'png' and self.png_anti_alias == True: 208 208 # 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] 210 210 #self.log.debug('render_macro: svg output - running command %s' % cmd) 211 211 out, err = self.launch(cmd, content) 212 212 if len(out) or len(err): … … 222 222 return self.show_err(msg).getvalue() 223 223 224 224 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] 226 226 #self.log.debug('render_macro: render other image formats - running command %s' % cmd) 227 227 out, err = self.launch(cmd, content) 228 228 if len(out) or len(err): … … 234 234 235 235 # Create the map if not in cache 236 236 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] 238 238 #self.log.debug('render_macro: create map if not in cache - running command %s' % cmd) 239 239 out, err = self.launch(cmd, content) 240 240 if len(out) or len(err): … … 379 379 #self.log.debug('self.rsvg_path: %s' % self.rsvg_path) 380 380 381 381 # 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) 394 389 395 396 390 # check if we should run the cache manager 397 391 self.cache_manager = self.boolean(self.config.get('graphviz', 'cache_manager', False)) 398 392 if self.cache_manager:
