Package PyFoam :: Package ThirdParty :: Package Gnuplot :: Module gp_mac
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.ThirdParty.Gnuplot.gp_mac

  1  # $Id: gp_mac.py,v 2.17 2003/04/21 09:44:09 mhagger Exp $ 
  2   
  3  # Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu> 
  4  # Thanks to Tony Ingraldi and Noboru Yamamoto for their contributions. 
  5  # 
  6  # This file is licensed under the GNU Lesser General Public License 
  7  # (LGPL).  See LICENSE.txt for details. 
  8   
  9  """gp_mac -- an interface to gnuplot for the Macintosh. 
 10   
 11  """ 
 12   
 13  __cvs_version__ = '$Revision: 2.17 $' 
 14   
 15  import os, string 
 16   
 17  import Errors 
 18   
 19   
 20  # ############ Configuration variables: ################################ 
 21   
22 -class GnuplotOpts:
23 """The configuration options for gnuplot on the Macintosh. 24 25 See gp.py for details about the meaning of these options. Please 26 let me know if you know better choices for these settings.""" 27 28 # The '-persist' option is not supported on the Mac: 29 recognizes_persist = 0 30 31 # Apparently the Mac can use binary data: 32 recognizes_binary_splot = 1 33 34 # Apparently the Mac can not use inline data: 35 prefer_inline_data = 0 36 37 # os.mkfifo is not supported on the Mac. 38 support_fifo = 0 39 prefer_fifo_data = 0 40 41 # The default choice for the 'set term' command (to display on screen). 42 # Terminal types are different in Gnuplot 3.7.1c. 43 # For earlier versions, this was default_term = 'macintosh' 44 default_term = 'pict' 45 46 # I don't know how to print directly to a printer on the Mac: 47 default_lpr = '| lpr' 48 49 # Used the 'enhanced' option of postscript by default? Set to 50 # None (*not* 0!) if your version of gnuplot doesn't support 51 # enhanced postscript. 52 prefer_enhanced_postscript = 1
53 54 # ############ End of configuration options ############################ 55 56 57 # The Macintosh doesn't support pipes so communication is via 58 # AppleEvents. 59 60 import gnuplot_Suites 61 import Required_Suite 62 import aetools 63 64 65 # Mac doesn't recognize persist.
66 -def test_persist():
67 return 0
68 69
70 -class _GNUPLOT(aetools.TalkTo, 71 Required_Suite.Required_Suite, 72 gnuplot_Suites.gnuplot_Suite, 73 gnuplot_Suites.odds_and_ends, 74 gnuplot_Suites.Standard_Suite, 75 gnuplot_Suites.Miscellaneous_Events):
76 """Start a gnuplot program and emulate a pipe to it.""" 77
78 - def __init__(self):
79 aetools.TalkTo.__init__(self, '{GP}', start=1)
80 81
82 -class GnuplotProcess:
83 """Unsophisticated interface to a running gnuplot program. 84 85 See gp_unix.GnuplotProcess for usage information. 86 87 """ 88
89 - def __init__(self, persist=0):
90 """Start a gnuplot process. 91 92 Create a 'GnuplotProcess' object. This starts a gnuplot 93 program and prepares to write commands to it. 94 95 Keyword arguments: 96 97 'persist' -- the '-persist' option is not supported on the 98 Macintosh so this argument must be zero. 99 100 """ 101 102 if persist: 103 raise Errors.OptionError( 104 '-persist is not supported on the Macintosh!') 105 106 self.gnuplot = _GNUPLOT() 107 108 # forward close method: 109 self.close = self.gnuplot.quit
110
111 - def write(self, s):
112 """Mac gnuplot apparently requires '\r' to end statements.""" 113 114 self.gnuplot.gnuexec(string.replace(s, '\n', os.linesep))
115
116 - def flush(self):
117 pass
118
119 - def __call__(self, s):
120 """Send a command string to gnuplot, for immediate execution.""" 121 122 # Apple Script doesn't seem to need the trailing '\n'. 123 self.write(s) 124 self.flush()
125