https://svn.lrde.epita.fr/svn/oln/trunk/swilena
We now have a beginning of a Swilena Python Shell for Olena. To try
it out, build it, go to the swilena/python directory of your *build*
tree (which can be the same as your source tree, of course) and run
`sps-local':
make -C swilena
cd swilena/python
./sps-local
and type `example', for instance.
Use `sps-local', not `sps', for the latter will only work when the
project is *installed*. Once installed, you should be able to run
this shell using `sps'.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Improve sps.
* python/sps-common.in: Move the lines printing information at
the startup of the shell...
* python/sps.py: ...here (new file).
Use this script instead of swilena.py for sps...
* python/sps.in, python/sps-local.in: ...here.
* python/Makefile.am (python_PYTHON): Add sps.py.
Makefile.am | 6 ++++--
sps-common.in | 4 +---
sps-local.in | 2 +-
sps.in | 2 +-
sps.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 61 insertions(+), 7 deletions(-)
Index: python/sps-common.in
--- python/sps-common.in (revision 2098)
+++ python/sps-common.in (working copy)
@@ -29,6 +29,4 @@
# The Swilena Python Shell.
-echo 'The Swilena Python Shell (sps).'
-echo 'Type "help", "copyright", "credits" or
"license" for more information.'
-echo 'Type "quit()" or ^D (Ctrl-D) to quit.'
+# FIXME: We might want to add some option processing here.
Index: python/sps-local.in
--- python/sps-local.in (revision 2098)
+++ python/sps-local.in (working copy)
@@ -3,4 +3,4 @@
# sps local version, for use from non installed distributions.
PYTHONPATH='@abs_builddir@/python:@abs_srcdir@/python':"$PYTHONPATH" \
DYLD_LIBRARY_PATH='.libs:@abs_top_builddir@/src/.libs' \
-exec @PYTHON@ -i @abs_srcdir@/swilena.py "$@"
+exec @PYTHON@ -i @abs_srcdir@/sps.py "$@"
Index: python/Makefile.am
--- python/Makefile.am (revision 2098)
+++ python/Makefile.am (working copy)
@@ -23,8 +23,11 @@
rm -f "$(DEPDIR)/$*-wrap.Tcc"; exit 1;\
fi
+
# ltihooks.py: Python import hooks that understand Libtool libraries.
python_PYTHON = ltihooks.py
+# swilena.py: The whole Swilena suite.
+python_PYTHON += swilena.py
## ----------------- ##
@@ -51,8 +54,7 @@
## ---------------------------- ##
# FIXME: We might want to rename this shell as something else.
-
-python_PYTHON += swilena.py
+python_PYTHON += sps.py
# The script to be used in installed distributions.
bin_SCRIPTS = sps
Index: python/sps.in
--- python/sps.in (revision 2098)
+++ python/sps.in (working copy)
@@ -3,4 +3,4 @@
# sps, for use from an installed distribution.
PYTHONPATH='@pythondir@':"$PYTHONPATH" \
DYLD_LIBRARY_PATH='@pythondir@:@libdir@' \
-exec @PYTHON@ -i @pythondir@/swilena.py "$@"
+exec @PYTHON@ -i @pythondir@/sps.py "$@"
Index: python/sps.py
--- python/sps.py (revision 0)
+++ python/sps.py (revision 0)
@@ -0,0 +1,54 @@
+#! /usr/bin/env python
+
+# Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+#
+# This file is part of the Olena Library. This library is free
+# software; you can redistribute it and/or modify it under the terms
+# of the GNU General Public License version 2 as published by the
+# Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this library; see the file COPYING. If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02111-1307, USA.
+#
+# As a special exception, you may use this file as part of a free
+# software library without restriction. Specifically, if other files
+# instantiate templates or use macros or inline functions from this
+# file, or you compile this file and link it with other files to
+# produce an executable, this file does not by itself cause the
+# resulting executable to be covered by the GNU General Public
+# License.
+# reasons why the executable file might be covered by the GNU General
+# Public License.
+
+from swilena import *
+
+# FIXME: See if could use cmd.Cmd here
+# (
http://docs.huihoo.com/pydoc/python/2.5/stdlib/cmd.Cmd-class.html).
+class Example:
+ def __init__(self, message):
+ self.message = message
+ def __repr__(self):
+ return self.message
+
+example = Example('''\
+The following example creates a 2-d image of integers with 3 rows and
+3 columns, then fills its cells with the value `42' and prints it:
+
+ ima = image2d.image2d_int(3, 3)
+ image2d.fill_image2d_int(ima, 42)
+ image2d.println_image2d_int(ima)
+
+You can try it by copying and pasting each line on the following prompt.
+''')
+
+print '''The Swilena Python Shell (sps).
+Type "help", "copyright", "credits" or "license"
for more information on Python
+Type "example" for a short example.
+Type "quit()" or ^D (Ctrl-D) to quit.'''