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

Source Code for Module PyFoam.ThirdParty.Gnuplot.gp

 1  # $Id: gp.py 292 2006-03-03 09:49:04Z mhagger $ 
 2   
 3  # Copyright (C) 1998-2003 Michael Haggerty <mhagger@alum.mit.edu> 
 4  # 
 5  # This file is licensed under the GNU Lesser General Public License 
 6  # (LGPL).  See LICENSE.txt for details. 
 7   
 8  """gp -- a platform-independent interface to a gnuplot process. 
 9   
10  This file imports a low-level, platform-independent interface to the 
11  gnuplot program.  Which interface is imported depends on the platform. 
12  There are variations of this file for Unix, the Macintosh, and for 
13  Windows called gp_unix.py, gp_mac.py, and gp_win32.py, respectively. 
14  Note that the end-user should use the more capable interface from 
15  __init__.py (i.e., 'import Gnuplot') rather than the low-level 
16  interface imported by this file. 
17   
18  See gp_unix.py for most documentation about the facilities of the 
19  gp_*.py modules. 
20   
21  """ 
22   
23  import sys, string 
24   
25  # Low-level communication with gnuplot is platform-dependent.  Import 
26  # the appropriate implementation of GnuplotProcess based on the 
27  # platform: 
28  if sys.platform == 'mac': 
29      from gp_mac import GnuplotOpts, GnuplotProcess, test_persist 
30  elif sys.platform == 'win32': 
31      from gp_win32 import GnuplotOpts, GnuplotProcess, test_persist 
32  elif sys.platform == 'darwin': 
33      from gp_macosx import GnuplotOpts, GnuplotProcess, test_persist 
34  elif sys.platform[:4] == 'java': 
35      from gp_java import GnuplotOpts, GnuplotProcess, test_persist 
36  elif sys.platform == 'cygwin': 
37      from gp_cygwin import GnuplotOpts, GnuplotProcess, test_persist 
38  else: 
39      from gp_unix import GnuplotOpts, GnuplotProcess, test_persist 
40   
41   
42 -def double_quote_string(s):
43 """Return string s quoted and surrounded by double-quotes for gnuplot.""" 44 45 for c in ['\\', '\"']: 46 s = string.replace(s, c, '\\' + c) 47 48 return '"%s"' % (s,)
49