Pylint updates for GraphvizReportDialog.

svn: r10625
This commit is contained in:
Brian Matherly
2008-04-23 04:42:08 +00:00
parent 634fd3964d
commit c4024f91db
2 changed files with 148 additions and 112 deletions

View File

@ -1581,20 +1581,26 @@ class GVDoc:
for Graphviz reports must implment this interface to be used by the for Graphviz reports must implment this interface to be used by the
report system. report system.
""" """
def add_node(self, id, label, shape="box", fillcolor="white", url="", htmloutput=False): def add_node(self, node_id, label, shape="", color="",
style="", fillcolor="", url="", htmloutput=False):
""" """
Add a node to this graph. Nodes can be different shapes like boxes and Add a node to this graph. Nodes can be different shapes like boxes and
circles. circles.
@param id: A unique identification value for this node. @param node_id: A unique identification value for this node.
Example: "p55" Example: "p55"
@type id: string @type node_id: string
@param label: The text to be displayed in the node. @param label: The text to be displayed in the node.
Example: "John Smith" Example: "John Smith"
@type label: string @type label: string
@param shape: The shape for the node. @param shape: The shape for the node.
Examples: "box", "ellipse", "circle" Examples: "box", "ellipse", "circle"
@type shape: string @type shape: string
@param color: The color of the node line.
Examples: "blue", "lightyellow"
@type color: string
@param style: The style of the node.
@type style: string
@param fillcolor: The fill color for the node. @param fillcolor: The fill color for the node.
Examples: "blue", "lightyellow" Examples: "blue", "lightyellow"
@type fillcolor: string @type fillcolor: string
@ -1634,7 +1640,7 @@ class GVDoc:
""" """
raise NotImplementedError raise NotImplementedError
def start_subgraph(self,id): def start_subgraph(self, graph_id):
""" """
Start a subgraph in this graph. Start a subgraph in this graph.

View File

@ -47,7 +47,7 @@ import Mime
import Utils import Utils
import BaseDoc import BaseDoc
import Config import Config
from _Constants import CATEGORY_GRAPHVIZ from ReportBase import CATEGORY_GRAPHVIZ
from _ReportDialog import ReportDialog from _ReportDialog import ReportDialog
from _FileEntry import FileEntry from _FileEntry import FileEntry
from _PaperMenu import PaperFrame from _PaperMenu import PaperFrame
@ -114,38 +114,40 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
def __init__(self, options, paper_style): def __init__(self, options, paper_style):
BaseDoc.BaseDoc.__init__(self, None, paper_style, None) BaseDoc.BaseDoc.__init__(self, None, paper_style, None)
self.options = options.handler.options_dict self._filename = None
self.dot = StringIO() self._dot = StringIO()
self.paper = paper_style self._paper = paper_style
self.dpi = self.options['dpi' ] menu = options.menu
self.fontfamily = _FONTS[ self.options['font_family' ]]['value']
self.fontsize = self.options['font_size' ] self.dpi = menu.get_option_by_name('dpi').get_value()
self.hpages = self.options['h_pages' ] self.fontfamily = menu.get_option_by_name('font_family').get_value()
self.nodesep = self.options['nodesep' ] self.fontsize = menu.get_option_by_name('font_size').get_value()
self.noteloc = self.options['noteloc' ] self.hpages = menu.get_option_by_name('h_pages').get_value()
self.notesize = self.options['notesize' ] self.nodesep = menu.get_option_by_name('nodesep').get_value()
self.note = self.options['note' ] self.noteloc = menu.get_option_by_name('noteloc').get_value()
self.pagedir = _PAGEDIR[ self.options['page_dir' ]]['value'] self.notesize = menu.get_option_by_name('notesize').get_value()
self.rankdir = _RANKDIR[ self.options['rank_dir' ]]['value'] self.note = menu.get_option_by_name('note').get_value()
self.ranksep = self.options['ranksep' ] self.pagedir = menu.get_option_by_name('page_dir').get_value()
self.ratio = _RATIO[ self.options['ratio' ]]['value'] self.rankdir = menu.get_option_by_name('rank_dir').get_value()
self.vpages = self.options['v_pages' ] self.ranksep = menu.get_option_by_name('ranksep').get_value()
self.ratio = menu.get_option_by_name('ratio').get_value()
self.vpages = menu.get_option_by_name('v_pages').get_value()
paper_size = paper_style.get_size() paper_size = paper_style.get_size()
sizew = ( paper_size.get_width() - sizew = ( paper_size.get_width() -
self.paper.get_left_margin() - self._paper.get_left_margin() -
self.paper.get_right_margin() ) / 2.54 self._paper.get_right_margin() ) / 2.54
sizeh = ( paper_size.get_height() - sizeh = ( paper_size.get_height() -
self.paper.get_top_margin() - self._paper.get_top_margin() -
self.paper.get_bottom_margin() ) / 2.54 self._paper.get_bottom_margin() ) / 2.54
pheight = paper_size.get_height_inches() pheight = paper_size.get_height_inches()
pwidth = paper_size.get_width_inches() pwidth = paper_size.get_width_inches()
xmargin = self.paper.get_left_margin() / 2.54 xmargin = self._paper.get_left_margin() / 2.54
ymargin = self.paper.get_top_margin() / 2.54 ymargin = self._paper.get_top_margin() / 2.54
sizew = sizew * self.hpages sizew = sizew * self.hpages
sizeh = sizeh * self.vpages sizeh = sizeh * self.vpages
@ -182,10 +184,12 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
self.write( '\n' ) self.write( '\n' )
def write(self, text): def write(self, text):
self.dot.write(text.encode('iso-8859-1', 'xmlcharrefreplace')) """ Write text to the dot file """
self._dot.write(text.encode('iso-8859-1', 'xmlcharrefreplace'))
def open(self, filename): def open(self, filename):
self.filename = os.path.normpath(os.path.abspath(filename)) """ Implement BaseDoc.BaseDoc.open() """
self._filename = os.path.normpath(os.path.abspath(filename))
def close(self): def close(self):
""" """
@ -202,7 +206,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
self.write( '}' ) self.write( '}' )
def add_node(self, id, label, shape="", color="", def add_node(self, node_id, label, shape="", color="",
style="", fillcolor="", url="", htmloutput=False): style="", fillcolor="", url="", htmloutput=False):
""" """
Add a node to this graph. Nodes can be different shapes like boxes and Add a node to this graph. Nodes can be different shapes like boxes and
@ -236,7 +240,7 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
text += ' URL="%s"' % url text += ' URL="%s"' % url
text += " ]" text += " ]"
self.write(' %s %s;\n' % (id, text)) self.write(' %s %s;\n' % (node_id, text))
def add_link(self, id1, id2, style="", head="", tail="", comment=""): def add_link(self, id1, id2, style="", head="", tail="", comment=""):
""" """
@ -281,11 +285,13 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
else: else:
self.write('# %s\n' % text) self.write('# %s\n' % text)
def start_subgraph(self, id): def start_subgraph(self, graph_id):
self.write(' subgraph cluster_%s\n' % id) """ Implement BaseDoc.GVDoc.start_subgraph() """
self.write(' subgraph cluster_%s\n' % graph_id)
self.write(' {\n') self.write(' {\n')
def end_subgraph(self): def end_subgraph(self):
""" Implement BaseDoc.GVDoc.end_subgraph() """
self.write(' }\n') self.write(' }\n')
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -294,20 +300,23 @@ class GVDocBase(BaseDoc.BaseDoc, BaseDoc.GVDoc):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVDotDoc(GVDocBase): class GVDotDoc(GVDocBase):
""" GVDoc implementation that generates a .dot text file. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".dot": if self._filename[-4:] != ".dot":
self.filename += ".dot" self._filename += ".dot"
file = open(self.filename, "w") dotfile = open(self._filename, "w")
file.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
file.close() dotfile.close()
if self.print_req: if self.print_req:
app = Mime.get_application("text/x-graphviz") app = Mime.get_application("text/x-graphviz")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -315,6 +324,7 @@ class GVDotDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPsDoc(GVDocBase): class GVPsDoc(GVDocBase):
""" GVDoc implementation that generates a .ps file using Graphviz. """
def __init__(self, options, paper_style): def __init__(self, options, paper_style):
# DPI must always be 72 for PDF. # DPI must always be 72 for PDF.
@ -323,27 +333,28 @@ class GVPsDoc(GVDocBase):
GVDocBase.__init__(self, options, paper_style) GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-3:] != ".ps": if self._filename[-3:] != ".ps":
self.filename += ".ps" self._filename += ".ps"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tps2 -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tps2 -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("application/postscript") app = Mime.get_application("application/postscript")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -351,28 +362,31 @@ class GVPsDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVSvgDoc(GVDocBase): class GVSvgDoc(GVDocBase):
""" GVDoc implementation that generates a .svg file using Graphviz. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".svg": if self._filename[-4:] != ".svg":
self.filename += ".svg" self._filename += ".svg"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tsvg -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tsvg -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("image/svg") app = Mime.get_application("image/svg")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -380,28 +394,31 @@ class GVSvgDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVSvgzDoc(GVDocBase): class GVSvgzDoc(GVDocBase):
""" GVDoc implementation that generates a .svg file using Graphviz. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-5:] != ".svgz": if self._filename[-5:] != ".svgz":
self.filename += ".svgz" self._filename += ".svgz"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tsvgz -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tsvgz -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("image/svgz") app = Mime.get_application("image/svgz")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -409,28 +426,31 @@ class GVSvgzDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPngDoc(GVDocBase): class GVPngDoc(GVDocBase):
""" GVDoc implementation that generates a .png file using Graphviz. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".png": if self._filename[-4:] != ".png":
self.filename += ".png" self._filename += ".png"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tpng -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tpng -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("image/png") app = Mime.get_application("image/png")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -438,28 +458,31 @@ class GVPngDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVJpegDoc(GVDocBase): class GVJpegDoc(GVDocBase):
""" GVDoc implementation that generates a .jpg file using Graphviz. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".jpg": if self._filename[-4:] != ".jpg":
self.filename += ".jpg" self._filename += ".jpg"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tjpg -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tjpg -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("image/jpeg") app = Mime.get_application("image/jpeg")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -467,28 +490,31 @@ class GVJpegDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVGifDoc(GVDocBase): class GVGifDoc(GVDocBase):
""" GVDoc implementation that generates a .gif file using Graphviz. """
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".gif": if self._filename[-4:] != ".gif":
self.filename += ".gif" self._filename += ".gif"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PS file. # Generate the PS file.
os.system( 'dot -Tgif -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tgif -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("image/gif") app = Mime.get_application("image/gif")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
@ -496,6 +522,7 @@ class GVGifDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPdfGvDoc(GVDocBase): class GVPdfGvDoc(GVDocBase):
""" GVDoc implementation that generates a .pdf file using Graphviz. """
def __init__(self, options, paper_style): def __init__(self, options, paper_style):
# DPI must always be 72 for PDF. # DPI must always be 72 for PDF.
@ -504,27 +531,28 @@ class GVPdfGvDoc(GVDocBase):
GVDocBase.__init__(self, options, paper_style) GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".pdf": if self._filename[-4:] != ".pdf":
self.filename += ".pdf" self._filename += ".pdf"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Generate the PDF file. # Generate the PDF file.
os.system( 'dot -Tpdf -o"%s" "%s"' % (self.filename, tmp_dot) ) os.system( 'dot -Tpdf -o"%s" "%s"' % (self._filename, tmp_dot) )
# Delete the temporary dot file # Delete the temporary dot file
os.remove(tmp_dot) os.remove(tmp_dot)
if self.print_req: if self.print_req:
app = Mime.get_application("application/pdf") app = Mime.get_application("application/pdf")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -533,7 +561,7 @@ class GVPdfGvDoc(GVDocBase):
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class GVPdfGsDoc(GVDocBase): class GVPdfGsDoc(GVDocBase):
""" GVDoc implementation that generates a .pdf file using Ghostscript. """
def __init__(self, options, paper_style): def __init__(self, options, paper_style):
# DPI must always be 72 for PDF. # DPI must always be 72 for PDF.
# GV documentation says dpi is only for image formats. # GV documentation says dpi is only for image formats.
@ -541,16 +569,17 @@ class GVPdfGsDoc(GVDocBase):
GVDocBase.__init__(self, options, paper_style) GVDocBase.__init__(self, options, paper_style)
def close(self): def close(self):
""" Implements GVDocBase.close() """
GVDocBase.close(self) GVDocBase.close(self)
# Make sure the extension is correct # Make sure the extension is correct
if self.filename[-4:] != ".pdf": if self._filename[-4:] != ".pdf":
self.filename += ".pdf" self._filename += ".pdf"
# Create a temporary dot file # Create a temporary dot file
(handle, tmp_dot) = tempfile.mkstemp(".dot" ) (handle, tmp_dot) = tempfile.mkstemp(".dot" )
dotfile = os.fdopen(handle,"w") dotfile = os.fdopen(handle,"w")
dotfile.write(self.dot.getvalue()) dotfile.write(self._dot.getvalue())
dotfile.close() dotfile.close()
# Create a temporary PostScript file # Create a temporary PostScript file
@ -562,14 +591,14 @@ class GVPdfGsDoc(GVDocBase):
os.system(command) os.system(command)
# Add .5 to remove rounding errors. # Add .5 to remove rounding errors.
paper_size = self.paper.get_size() paper_size = self._paper.get_size()
width_pt = int( (paper_size.get_width_inches() * 72) + 0.5 ) width_pt = int( (paper_size.get_width_inches() * 72) + 0.5 )
height_pt = int( (paper_size.get_height_inches() * 72) + 0.5 ) height_pt = int( (paper_size.get_height_inches() * 72) + 0.5 )
# Convert to PDF using ghostscript # Convert to PDF using ghostscript
command = '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dDEVICEWIDTHPOINTS=%d' \ command = '%s -q -sDEVICE=pdfwrite -dNOPAUSE -dDEVICEWIDTHPOINTS=%d' \
' -dDEVICEHEIGHTPOINTS=%d -sOutputFile="%s" "%s" -c quit' \ ' -dDEVICEHEIGHTPOINTS=%d -sOutputFile="%s" "%s" -c quit' \
% ( _GS_CMD, width_pt, height_pt, self.filename, tmp_ps ) % ( _GS_CMD, width_pt, height_pt, self._filename, tmp_ps )
os.system(command) os.system(command)
os.remove(tmp_ps) os.remove(tmp_ps)
@ -577,71 +606,72 @@ class GVPdfGsDoc(GVDocBase):
if self.print_req: if self.print_req:
app = Mime.get_application("application/pdf") app = Mime.get_application("application/pdf")
Utils.launch(app[0], self.filename) Utils.launch(app[0], self._filename)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
# Various Graphviz formats. # Various Graphviz formats.
# #
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
_formats = [] _FORMATS = []
_formats += [{ 'type' : "dot",
'ext' : "dot",
'descr': _("Graphviz Dot File"),
'mime' : "text/x-graphviz",
'class': GVDotDoc }]
if _DOT_FOUND: if _DOT_FOUND:
if _GS_CMD != "": if _GS_CMD != "":
_formats += [{ 'type' : "gspdf", _FORMATS += [{ 'type' : "gspdf",
'ext' : "pdf", 'ext' : "pdf",
'descr': _("PDF (Ghostscript)"), 'descr': _("PDF (Ghostscript)"),
'mime' : "application/pdf", 'mime' : "application/pdf",
'class': GVPdfGsDoc }] 'class': GVPdfGsDoc }]
_formats += [{ 'type' : "gvpdf", _FORMATS += [{ 'type' : "gvpdf",
'ext' : "pdf", 'ext' : "pdf",
'descr': _("PDF (Graphviz)"), 'descr': _("PDF (Graphviz)"),
'mime' : "application/pdf", 'mime' : "application/pdf",
'class': GVPdfGvDoc }] 'class': GVPdfGvDoc }]
_formats += [{ 'type' : "ps", _FORMATS += [{ 'type' : "ps",
'ext' : "ps", 'ext' : "ps",
'descr': _("PostScript"), 'descr': _("PostScript"),
'mime' : "application/postscript", 'mime' : "application/postscript",
'class': GVPsDoc }] 'class': GVPsDoc }]
_formats += [{ 'type' : "svg", _FORMATS += [{ 'type' : "svg",
'ext' : "svg", 'ext' : "svg",
'descr': _("Structured Vector Graphics (SVG)"), 'descr': _("Structured Vector Graphics (SVG)"),
'mime' : "image/svg", 'mime' : "image/svg",
'class': GVSvgDoc }] 'class': GVSvgDoc }]
_formats += [{ 'type' : "svgz", _FORMATS += [{ 'type' : "svgz",
'ext' : "svgz", 'ext' : "svgz",
'descr': _("Compressed Structured Vector Graphs (SVG)"), 'descr': _("Compressed Structured Vector Graphs (SVG)"),
'mime' : "image/svgz", 'mime' : "image/svgz",
'class': GVSvgzDoc }] 'class': GVSvgzDoc }]
_formats += [{ 'type' : "jpg", _FORMATS += [{ 'type' : "jpg",
'ext' : "jpg", 'ext' : "jpg",
'descr': _("JPEG image"), 'descr': _("JPEG image"),
'mime' : "image/jpeg", 'mime' : "image/jpeg",
'class': GVJpegDoc }] 'class': GVJpegDoc }]
_formats += [{ 'type' : "gif", _FORMATS += [{ 'type' : "gif",
'ext' : "gif", 'ext' : "gif",
'descr': _("GIF image"), 'descr': _("GIF image"),
'mime' : "image/gif", 'mime' : "image/gif",
'class': GVGifDoc }] 'class': GVGifDoc }]
_formats += [{ 'type' : "png", _FORMATS += [{ 'type' : "png",
'ext' : "png", 'ext' : "png",
'descr': _("PNG image"), 'descr': _("PNG image"),
'mime' : "image/png", 'mime' : "image/png",
'class': GVPngDoc }] 'class': GVPngDoc }]
_FORMATS += [{ 'type' : "dot",
'ext' : "dot",
'descr': _("Graphviz Dot File"),
'mime' : "text/x-graphviz",
'class': GVDotDoc }]
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# #
# GraphvizFormatComboBox # GraphvizFormatComboBox
@ -661,7 +691,7 @@ class GraphvizFormatComboBox(gtk.ComboBox):
out_pref = Config.get(Config.OUTPUT_PREFERENCE) out_pref = Config.get(Config.OUTPUT_PREFERENCE)
index = 0 index = 0
active_index = 0 active_index = 0
for item in _formats: for item in _FORMATS:
name = item["descr"] name = item["descr"]
self.store.append(row=[name]) self.store.append(row=[name])
if item['type'] == active: if item['type'] == active:
@ -672,10 +702,10 @@ class GraphvizFormatComboBox(gtk.ComboBox):
self.set_active(active_index) self.set_active(active_index)
def get_label(self): def get_label(self):
return _formats[self.get_active()]["descr"] return _FORMATS[self.get_active()]["descr"]
def get_reference(self): def get_reference(self):
return _formats[self.get_active()]["class"] return _FORMATS[self.get_active()]["class"]
def get_paper(self): def get_paper(self):
return 1 return 1
@ -684,13 +714,13 @@ class GraphvizFormatComboBox(gtk.ComboBox):
return 0 return 0
def get_ext(self): def get_ext(self):
return '.%s' % _formats[self.get_active()]['ext'] return '.%s' % _FORMATS[self.get_active()]['ext']
def get_format_str(self): def get_format_str(self):
return _formats[self.get_active()]["type"] return _FORMATS[self.get_active()]["type"]
def get_printable(self): def get_printable(self):
_apptype = _formats[self.get_active()]["mime"] _apptype = _FORMATS[self.get_active()]["mime"]
print_label = None print_label = None
try: try:
mprog = Mime.get_application(_apptype) mprog = Mime.get_application(_apptype)
@ -704,7 +734,7 @@ class GraphvizFormatComboBox(gtk.ComboBox):
return print_label return print_label
def get_clname(self): def get_clname(self):
return _formats[self.get_active()]["type"] return _FORMATS[self.get_active()]["type"]
#----------------------------------------------------------------------- #-----------------------------------------------------------------------
# #
@ -731,10 +761,10 @@ class GraphvizReportDialog(ReportDialog):
################################ ################################
category = _("GraphViz Layout") category = _("GraphViz Layout")
################################ ################################
font_family = EnumeratedListOption(_("Font family"), 0) font_family = EnumeratedListOption(_("Font family"), "")
index = 0 index = 0
for item in _FONTS: for item in _FONTS:
font_family.add_item(index, item["name"]) font_family.add_item(item["value"], item["name"])
index += 1 index += 1
font_family.set_help(_("Choose the font family. If international " font_family.set_help(_("Choose the font family. If international "
"characters don't show, use FreeSans font. " "characters don't show, use FreeSans font. "
@ -746,10 +776,10 @@ class GraphvizReportDialog(ReportDialog):
font_size.set_help(_("The font size, in points.")) font_size.set_help(_("The font size, in points."))
self.options.add_menu_option(category, "font_size", font_size) self.options.add_menu_option(category, "font_size", font_size)
rank_dir = EnumeratedListOption(_("Graph Direction"), 0) rank_dir = EnumeratedListOption(_("Graph Direction"), "TB")
index = 0 index = 0
for item in _RANKDIR: for item in _RANKDIR:
rank_dir.add_item(index, item["name"]) rank_dir.add_item(item["value"], item["name"])
index += 1 index += 1
rank_dir.set_help(_("Whether graph goes from top to bottom " rank_dir.set_help(_("Whether graph goes from top to bottom "
"or left to right.")) "or left to right."))
@ -769,10 +799,10 @@ class GraphvizReportDialog(ReportDialog):
"of pages in the array vertically.")) "of pages in the array vertically."))
self.options.add_menu_option(category, "v_pages", v_pages) self.options.add_menu_option(category, "v_pages", v_pages)
page_dir = EnumeratedListOption(_("Paging Direction"), 0) page_dir = EnumeratedListOption(_("Paging Direction"), "BL")
index = 0 index = 0
for item in _PAGEDIR: for item in _PAGEDIR:
page_dir.add_item(index, item["name"]) page_dir.add_item(item["value"], item["name"])
index += 1 index += 1
page_dir.set_help(_("The order in which the graph pages are output. " page_dir.set_help(_("The order in which the graph pages are output. "
"This option only applies if the horizontal pages " "This option only applies if the horizontal pages "
@ -795,10 +825,10 @@ class GraphvizReportDialog(ReportDialog):
category = _("GraphViz Options") category = _("GraphViz Options")
################################ ################################
aspect_ratio = EnumeratedListOption(_("Aspect ratio"), 0) aspect_ratio = EnumeratedListOption(_("Aspect ratio"), "fill")
index = 0 index = 0
for item in _RATIO: for item in _RATIO:
aspect_ratio.add_item(index, item["name"]) aspect_ratio.add_item(item["value"], item["name"])
index += 1 index += 1
aspect_ratio.set_help(_("Affects greatly how the graph is layed out " aspect_ratio.set_help(_("Affects greatly how the graph is layed out "
"on the page.")) "on the page."))