107 |
def embed_implicit_diagram(filepath, diagram): |
def embed_implicit_diagram(filepath, diagram): |
108 |
dbg_navidoc('Embedding implicitly diagram %s into %s' % (diagram, filepath)) |
dbg_navidoc('Embedding implicitly diagram %s into %s' % (diagram, filepath)) |
109 |
|
|
110 |
init_working_directory = config.working_directory |
config.link_base_directory = config.working_directory |
111 |
init_input_filename = config.input_filename |
init_input_filename = config.input_filename |
112 |
init_output_filename = config.output_filename |
init_output_filename = config.output_filename |
113 |
|
|
119 |
html = htmlfile.read() |
html = htmlfile.read() |
120 |
htmlfile.close() |
htmlfile.close() |
121 |
|
|
122 |
insert = html.find('<a id="'+diagram+'_small">') |
insert = html.find('<a id="'+diagram+'_implficit">') |
123 |
if insert == -1: |
if insert == -1: |
124 |
|
""" |
125 |
|
Implicit imagemaps are embedded after the first header or after |
126 |
|
the <body> tag. |
127 |
|
""" |
128 |
for index in range(6): |
for index in range(6): |
129 |
insert = html.upper().find('</H%s>' % (str(index)))+5 |
insert = html.upper().find('</H%s>' % (str(index)))+5 |
130 |
if insert != 4: break |
if insert != 4: break |
131 |
|
if insert == 4: |
132 |
|
insert = html.upper().find('<BODY') |
133 |
|
insert = html.upper().find('>', insert)+1 |
134 |
insert_left = insert |
insert_left = insert |
135 |
else: insert_left = html.find('/>', html.find('<img', insert))+2 |
else: insert_left = html.find('/>', html.find('<img', insert))+2 |
136 |
|
|
146 |
out.write(html[0:insert]); |
out.write(html[0:insert]); |
147 |
create_uml(diagram, context, scale=0.5) |
create_uml(diagram, context, scale=0.5) |
148 |
dbg("Mapping diagram %s within %s" % (diagram, filepath)) |
dbg("Mapping diagram %s within %s" % (diagram, filepath)) |
149 |
imgmap = get_imagemap(diagram, context, scale=0.5, id_postfix="_small") |
imgmap = get_imagemap(diagram, context, scale=0.5, id_postfix="_implicit") |
150 |
dbg("Diagram %s imagemap: %s" % (diagram, "\n"+str(imgmap))) |
dbg("Diagram %s imagemap: %s" % (diagram, "\n"+str(imgmap))) |
151 |
out.write(imgmap) |
out.write(imgmap) |
152 |
|
|
154 |
out.write(html) |
out.write(html) |
155 |
out.close() |
out.close() |
156 |
|
|
157 |
config.working_directory = init_working_directory |
config.working_directory = config.link_base_directory |
158 |
config.input_filename = init_input_filename |
config.input_filename = init_input_filename |
159 |
config.output_filename = init_output_filename |
config.output_filename = init_output_filename |
160 |
|
config.link_base_directory = None |
161 |
|
|
162 |
def is_linked(diagram): |
def is_linked(diagram): |
163 |
log = open(slashify(config.mp_directory)+diagram+'.gen.mp.log').read() |
log = open(slashify(config.mp_directory)+diagram+'.gen.mp.log').read() |