~ubuntu-branches/ubuntu/warty/python-gnuplot/warty

« back to all changes in this revision

Viewing changes to gp_mac.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2003-11-16 12:36:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20031116123626-1knq7mn30ta2q6ds
Tags: 1.7-3
Fix typo in README.Debian (closes: #219485).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: gp_mac.py,v 2.8 2001/01/07 21:35:13 mhagger Exp $
 
1
# $Id: gp_mac.py,v 2.17 2003/04/21 09:44:09 mhagger Exp $
2
2
 
3
 
# Copyright (C) 1999 Michael Haggerty <mhagger@alum.mit.edu>
 
3
# Copyright (C) 1999-2003 Michael Haggerty <mhagger@alum.mit.edu>
4
4
# Thanks to Tony Ingraldi and Noboru Yamamoto for their contributions.
5
5
#
6
 
# This program is free software; you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation; either version 2 of the License, or (at
9
 
# your option) any later version.  This program is distributed in the
10
 
# hope that it will be useful, but WITHOUT ANY WARRANTY; without even
11
 
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
 
# PURPOSE.  See the GNU General Public License for more details; it is
13
 
# available at <http://www.fsf.org/copyleft/gpl.html>, or by writing to
14
 
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15
 
# Boston, MA 02111-1307, USA.
 
6
# This file is licensed under the GNU Lesser General Public License
 
7
# (LGPL).  See LICENSE.txt for details.
16
8
 
17
9
"""gp_mac -- an interface to gnuplot for the Macintosh.
18
10
 
19
11
"""
20
12
 
21
 
__cvs_version__ = '$Revision: 2.8 $'
 
13
__cvs_version__ = '$Revision: 2.17 $'
 
14
 
 
15
import os, string
 
16
 
 
17
import Errors
22
18
 
23
19
 
24
20
# ############ Configuration variables: ################################
38
34
    # Apparently the Mac can not use inline data:
39
35
    prefer_inline_data = 0
40
36
 
41
 
    # The default choice for the 'set term' command (to display on screen):
42
 
    default_term = 'macintosh'
 
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'
43
45
 
44
46
    # I don't know how to print directly to a printer on the Mac:
45
 
    default_lpr = None
 
47
    default_lpr = '| lpr'
46
48
 
47
49
    # Used the 'enhanced' option of postscript by default?  Set to
48
50
    # None (*not* 0!) if your version of gnuplot doesn't support
74
76
    """Start a gnuplot program and emulate a pipe to it."""
75
77
 
76
78
    def __init__(self):
77
 
        aetools.TalkTo.__init__(self, 'GPSE', start=1)
 
79
        aetools.TalkTo.__init__(self, '{GP}', start=1)
78
80
 
79
81
 
80
82
class GnuplotProcess:
81
83
    """Unsophisticated interface to a running gnuplot program.
82
84
 
83
 
    See gp.GnuplotProcess for usage information.
 
85
    See gp_unix.GnuplotProcess for usage information.
84
86
 
85
87
    """
86
88
 
97
99
 
98
100
        """
99
101
 
100
 
        assert not persist, \
101
 
               OptionException('-persist is not supported on the Macintosh!')
 
102
        if persist:
 
103
            raise Errors.OptionError(
 
104
                '-persist is not supported on the Macintosh!')
102
105
 
103
106
        self.gnuplot = _GNUPLOT()
104
107
 
105
 
        # forward write and flush methods:
106
 
        self.write = self.gnuplot.gnuexec
 
108
        # forward close method:
107
109
        self.close = self.gnuplot.quit
108
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
 
109
116
    def flush(self):
110
 
                pass
111
 
                
 
117
        pass
 
118
        
112
119
    def __call__(self, s):
113
 
        """Send a command string to gnuplot, followed by newline."""
 
120
        """Send a command string to gnuplot, for immediate execution."""
114
121
 
115
 
        self.write(s + '\n')
 
122
        # Apple Script doesn't seem to need the trailing '\n'.
 
123
        self.write(s)
116
124
        self.flush()
117
125
 
118
126