Skip to content

Commit

Permalink
Actually store dotfile and generated pdf in the directory specified i…
Browse files Browse the repository at this point in the history
…n config.
  • Loading branch information
Kami committed Jun 5, 2011
1 parent 366a245 commit f14baeb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 11 additions & 3 deletions dot_interface.py
@@ -1,5 +1,7 @@
import subprocess

import os.path

class DotInterface(object):
"""
Abstracts dot specific parsing and editing.
Expand All @@ -19,8 +21,12 @@ class DotInterface(object):
}
'''

def __init__(self, name):
def __init__(self, name, dest_path):
self.name = name
self.dest_path = dest_path

if not os.path.exists(dest_path):
os.mkdir(dest_path)

def create_dotfile(self, AObjects):
"""
Expand All @@ -29,7 +35,8 @@ def create_dotfile(self, AObjects):
2. Second pass writes arrows
3. Does layout
"""
f = open(self.name, 'w')
target_path = os.path.join(self.dest_path, self.name)
f = open(target_path, 'w')
f.write("digraph %s {\n\n" % self.name)
f.write("rankdir=LR;\n\n")

Expand All @@ -49,7 +56,8 @@ def create_dotfile(self, AObjects):
f.close()

def create_pdf(self):
command = ["dot", "-O", "-Tpdf", self.name]
dot_file_path = os.path.join(self.dest_path, self.name)
command = ["dot", "-O", "-Tpdf", dot_file_path]
subprocess.Popen(command)

def _retrieve_color(self, color):
Expand Down
3 changes: 1 addition & 2 deletions main.py
Expand Up @@ -179,8 +179,7 @@ def main():

elif command.endswith("2dot") or command.endswith("_to_dot"):
import config
config.GENERATED_FILE_DIRECTORY
doti = DotInterface("event_flow")
doti = DotInterface("event_flow", config.GENERATED_FILE_DIRECTORY)
doti.create_dotfile(aobjects)
doti.create_pdf()
created = "Dot diagram"
Expand Down

0 comments on commit f14baeb

Please sign in to comment.