1 # $Id: gp.py 292 2006-03-03 09:49:04Z mhagger $
3 # Copyright (C) 1998-2003 Michael Haggerty <mhagger@alum.mit.edu>
5 # This file is licensed under the GNU Lesser General Public License
6 # (LGPL). See LICENSE.txt for details.
8 """gp -- a platform-independent interface to a gnuplot process.
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.
18 See gp_unix.py for most documentation about the facilities of the
25 # Low-level communication with gnuplot is platform-dependent. Import
26 # the appropriate implementation of GnuplotProcess based on the
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
39 from gp_unix
import GnuplotOpts
, GnuplotProcess
, test_persist
42 def double_quote_string(s
):
43 """Return string s quoted and surrounded by double-quotes for gnuplot."""
45 for c
in ['\\', '\"']:
46 s
= string
.replace(s
, c
, '\\' + c
)