Commit 8d0d5fc3 authored by Chyla Zbigniew's avatar Chyla Zbigniew
Browse files

New plugin, sample Python functions.


* Makefile.am, plugin.xml, py_func.py:
New plugin, sample Python functions.
parent 6bb98b3e
2001-03-05 Zbigniew Chyla <cyba@gnome.pl>
* Makefile.am, plugin.xml, py_func.py:
New plugin, sample Python functions.
gnumeric_plugin_py_funcdir = $(gnumeric_plugindir)/py-func
gnumeric_plugin_py_func_DATA = plugin.xml
gnumeric_plugin_py_func_SCRIPTS = py_func.py
EXTRA_DIST = $(gnumeric_plugin_py_func_DATA)
<?xml version="1.0"?>
<gnumeric_plugin_group>
<plugin id="Gnumeric_PyFunc">
<information name="Python functions" description="Sample Python plugin providing some (useless) functions."/>
<loader type="python">
<attribute name="module_name" value="py_func"/>
</loader>
<services>
<service type="file_opener" id="pot" priority="1" probe="FALSE">
<information description="PO/POT files import"/>
<file_patterns>
<file_pattern type="shell_pattern" value="*.po"/>
<file_pattern type="shell_pattern" value="*.pot"/>
</file_patterns>
<save_info saver_id="" format_level="manual_remember"/>
</service>
<service type="function_group" id="test">
<category name="Python"/>
<functions>
<function name="py_printf"/>
<function name="py_capwords"/>
</functions>
</service>
</services>
</plugin>
</gnumeric_plugin_group>
from Gnumeric import *
import string
def func_printf(format, *args):
'@FUNCTION=PY_PRINTF\n'\
'@SYNTAX=PY_PRINTF (format,...)\n'\
'@DESCRIPTION='\
'\n'\
'@EXAMPLES=\n'\
'PY_PRINTF("Test: %.2f",12) equals "Test: 12.00")'\
'\n'\
'@SEEALSO='
try:
val = format % args
except TypeError:
raise GnumericError, GnumericErrorVALUE
else:
return val
def func_capwords(str):
'@FUNCTION=PY_CAPWORDS\n'\
'@SYNTAX=PY_CAPWORDS (string)\n'\
'@DESCRIPTION='\
'\n'\
'@EXAMPLES=\n'\
'PY_CAPWORDS("Hello world") equals "Hello World")'\
'\n'\
'@SEEALSO='
return string.capwords(str)
test_functions = {
'py_printf': func_printf,
'py_capwords': ('s', 'string', func_capwords)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment