/[navidoc]/navidoc/navidoc/mp/__init__.py
ViewVC logotype

Diff of /navidoc/navidoc/mp/__init__.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.28 by humppake, Thu May 22 09:25:50 2003 UTC revision 1.29 by humppake, Thu May 22 10:52:21 2003 UTC
# Line 114  def context_menu(diagram): Line 114  def context_menu(diagram):
114      context_menu = ''      context_menu = ''
115            
116      # Refers must exist.      # Refers must exist.
117      filepath = slashify(config.mp_directory)+diagram+'.gen.refers'      filepath = slashify(config.mp_directory)+diagram+config.midfix+'.refers'
118      if (filepath):      if (filepath):
119          refers_file = open(filepath, "r")          refers_file = open(filepath, "r")
120          refers = refers_file.readlines()          refers = refers_file.readlines()
# Line 172  def context_menu(diagram): Line 172  def context_menu(diagram):
172  def create_uml(diagram, context='', scale=1.0):  def create_uml(diagram, context='', scale=1.0):
173      """      """
174      """      """
175      if not os.path.isfile(slashify(config.mp_directory)+diagram+'.gen.uml'):      if not os.path.isfile(slashify(config.mp_directory)+diagram+config.midfix+'.uml'):
176          raise MetapostException(slashify(config.mp_directory)+diagram+'.gen.uml'+' not found')          raise MetapostException(slashify(config.mp_directory) \
177      if not os.path.isfile(slashify(config.mp_directory)+diagram+'.gen.mp'):                                  +diagram+config.midfix+'.uml'+' not found')
178          raise MetapostException(slashify(config.mp_directory)+diagram+'.gen.mp'+' not found')      if not os.path.isfile(slashify(config.mp_directory)+diagram+config.midfix+'.mp'):
179            raise MetapostException(slashify(config.mp_directory) \
180                                    +diagram+config.midfix+'.mp'+' not found')
181            
182      s = open(slashify(config.mp_directory)+diagram+'.gen.uml').read()      s = open(slashify(config.mp_directory)+diagram+config.midfix+'.uml').read()
183      l = navidoc.util.parser.parse_indented(s)      l = navidoc.util.parser.parse_indented(s)
184      m = navidoc.parser.ElementList(l)      m = navidoc.parser.ElementList(l)
185    
# Line 189  def create_uml(diagram, context='', scal Line 191  def create_uml(diagram, context='', scal
191    
192      dir = slashify(config.mp_directory)      dir = slashify(config.mp_directory)
193    
194      gen1 = open(dir+diagram+context+'.gen.mp.1', 'w')      gen1 = open(dir+diagram+context+config.midfix+'.mp.1', 'w')
195      gen1.write(m.setup_code()+'\n')      gen1.write(m.setup_code()+'\n')
196      gen1.close()      gen1.close()
197      gen2 = open(dir+diagram+context+'.gen.mp.2', 'w')      gen2 = open(dir+diagram+context+config.midfix+'.mp.2', 'w')
198      gen2.write(m.draw_code()+"\n")      gen2.write(m.draw_code()+"\n")
199      gen2.write(draw_extra+"\n")      gen2.write(draw_extra+"\n")
200    
# Line 204  def create_uml(diagram, context='', scal Line 206  def create_uml(diagram, context='', scal
206      gen2.close()      gen2.close()
207      rough_edges = []      rough_edges = []
208    
209      gen3 = open(dir+diagram+context+".gen.mp.3", "w")      midfix = config.midfix
210        gen3 = open(dir+diagram+context+config.midfix+".mp.3", "w")
211      gen3.write("""      gen3.write("""
212          prologues := 1;          prologues := 1;
213          input uml.mp          input uml.mp
214    
215          beginfig(1)          beginfig(1)
216              input %(diagram)s%(context)s.gen.mp.1              input %(diagram)s%(context)s%(midfix)s.mp.1
217              input %(diagram)s.gen.mp              input %(diagram)s%(midfix)s.mp
218              input %(diagram)s%(context)s.gen.mp.2              input %(diagram)s%(context)s%(midfix)s.mp.2
219          endfig          endfig
220          end          end
221          """ % locals())          """ % locals())
# Line 227  def mp2png(diagram, scale=1.0): Line 230  def mp2png(diagram, scale=1.0):
230    
231      syscmd = 'mpost --file-line-error-style ' \      syscmd = 'mpost --file-line-error-style ' \
232               + '--interaction nonstopmode ' \               + '--interaction nonstopmode ' \
233               + diagram +'.gen.mp.3 >/dev/null'               + diagram + config.midfix + '.mp.3 >/dev/null'
234    
235      dbg(syscmd)      dbg(syscmd)
236      os.system('cd '+config.mp_directory+';'+syscmd)      os.system('cd '+config.mp_directory+';'+syscmd)
237    
238      if config.mp_eps_only:      if config.mp_eps_only:
239          os.rename(slashify(config.mp_directory)+diagram+'.gen.mp.1',          if config.midfix.startswith('.'):
240                    slashify(config.mp_directory)+diagram+'_gen.eps')              midfix = '_'+config.midfix[1:]
241            else: midfix = config.midfix
242            os.rename(slashify(config.mp_directory)+diagram+config.midfix+'.mp.1',
243                      slashify(config.mp_directory)+diagram+midfix+'.eps')
244          return          return
245    
246      log = open(slashify(config.mp_directory)+diagram+'.gen.mp.log').read()      log = open(slashify(config.mp_directory)+diagram+config.midfix+'.mp.log').read()
247      if log.find("\n"+'!') != -1:      if log.find("\n"+'!') != -1:
248          dbg_fail('Error occurred while processing the diagram. The log is shown below.')          dbg_fail('Error occurred while processing the diagram. The log is shown below.')
249          dbg_fail(log)          dbg_fail(log)
# Line 269  def mp2png(diagram, scale=1.0): Line 275  def mp2png(diagram, scale=1.0):
275      scaling = int(scaling / scale)      scaling = int(scaling / scale)
276    
277      dbg("List: "+str(list))      dbg("List: "+str(list))
278      syscmd = ('pstopnm '+' '.join(list)+' <'+slashify(config.mp_directory)+diagram+'.gen' \      syscmd = ('pstopnm '+' '.join(list)+' <'+slashify(config.mp_directory)+diagram+config.midfix \
279                +""".mp.1 2>/dev/null | pnmscale -reduce %s 2>/dev/null | """%scaling \                +""".mp.1 2>/dev/null | pnmscale -reduce %s 2>/dev/null | """%scaling \
280                +'pnmtopng >'+slashify(config.mp_directory)+diagram+'.gen.png 2>/dev/null')#                +'pnmtopng >'+slashify(config.mp_directory)+diagram+config.midfix+'.png 2>/dev/null')#
281    
282      dbg(syscmd)      dbg(syscmd)
283      os.system(syscmd)      os.system(syscmd)

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26