summaryrefslogtreecommitdiff
path: root/graph.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2009-05-06 10:39:07 +0200
committerEmile Anclin <emile.anclin@logilab.fr>2009-05-06 10:39:07 +0200
commit7d2f8b5e22a164738983e4f2eda1741aa793fcea (patch)
treece05ca6b3edcb0544896cd086631a27f36e664f1 /graph.py
parent1c8a3aa285df804360bc39107dee441b86d1f00e (diff)
downloadlogilab-common-7d2f8b5e22a164738983e4f2eda1741aa793fcea.tar.gz
fix double ".dot" extension using outpufile="name.dot"
Diffstat (limited to 'graph.py')
-rw-r--r--graph.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/graph.py b/graph.py
index 097f503..2e11ab9 100644
--- a/graph.py
+++ b/graph.py
@@ -2,7 +2,7 @@
(dot generation adapted from pypy/translator/tool/make_dot.py)
-:copyright: 2000-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2000-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: General Public License version 2 - http://www.gnu.org/licenses
"""
@@ -22,9 +22,8 @@ def escape(value):
def target_info_from_filename(filename):
"""Transforms /some/path/foo.png into ('/some/path', 'foo.png', 'png')."""
- abspath = osp.abspath(filename)
basename = osp.basename(filename)
- storedir = osp.dirname(abspath)
+ storedir = osp.dirname(osp.abspath(filename))
target = filename.split('.')[-1]
return storedir, basename, target
@@ -71,7 +70,12 @@ class DotBackend:
:return: a path to the generated file
"""
name = self.graphname
- dotfile = dotfile or ('%s.dot' % name)
+ if not dotfile:
+ # if 'outputfile' is a dot file use it as 'dotfile'
+ if outputfile and outputfile[-4:]==".dot":
+ dotfile = outputfile
+ else:
+ dotfile = '%s.dot' % name
if outputfile is not None:
storedir, basename, target = target_info_from_filename(outputfile)
if target != "dot":