aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorDaniel de Kok <danieldk@pobox.com>2010-05-11 14:56:25 +0200
committerRobby Workman <rworkman@slackbuilds.org>2010-05-11 14:56:25 +0200
commit78ed94f075a71136ca0b59b85fb5ff42354c8e1d (patch)
treec97b240418b90e99e1bb241baedecabfa4befffc /libraries
parentbf03802672e912df5133379de5baa03ca8fb4132 (diff)
libraries/python-levenshtein: Initial import
Diffstat (limited to 'libraries')
-rw-r--r--libraries/python-levenshtein/README4
-rw-r--r--libraries/python-levenshtein/genextdoc.py216
-rw-r--r--libraries/python-levenshtein/python-levenshtein.SlackBuild80
-rw-r--r--libraries/python-levenshtein/python-levenshtein.info8
-rw-r--r--libraries/python-levenshtein/slack-desc19
5 files changed, 327 insertions, 0 deletions
diff --git a/libraries/python-levenshtein/README b/libraries/python-levenshtein/README
new file mode 100644
index 000000000000..e85f56322866
--- /dev/null
+++ b/libraries/python-levenshtein/README
@@ -0,0 +1,4 @@
+python-levenhstein is a C extension module for Python that can be
+used for fast calculation of string distances with the Levenshtein
+algorithm, as well as some other methods.
+
diff --git a/libraries/python-levenshtein/genextdoc.py b/libraries/python-levenshtein/genextdoc.py
new file mode 100644
index 000000000000..fa0113f0a4f1
--- /dev/null
+++ b/libraries/python-levenshtein/genextdoc.py
@@ -0,0 +1,216 @@
+#!/usr/bin/env python
+# Simple Python extension module doc generator.
+# @(#) $Id: genextdoc.py,v 1.5 2004/10/07 15:32:31 yeti Exp $
+# Written by Yeti <yeti@physics.muni.cz>
+# This program is in the public domain.
+import re, sys, types, inspect
+from cgi import escape as q
+
+args = sys.argv
+args.pop(0)
+if not args:
+ print 'Usage: genextdoc.py [--selfcontained] module_name'
+ sys.exit(0)
+
+selfcontained = False
+if args[0].startswith('-') and 'selfcontained'.startswith(args[0].strip('-')):
+ selfcontained = True
+ args.pop(0)
+if not args: sys.exit(0)
+modname = args.pop(0)
+plain_docs = args
+
+html_head = """\
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head><title>%s %s</title></head>
+<body>
+"""
+
+html_foot = """\
+</body>
+</html>
+"""
+
+def split_para(doc):
+ p = []
+ for x in doc.split('\n\n'):
+ x = x.strip()
+ if x.find('\n>>>') > -1:
+ h, t = x.split('\n>>>', 1)
+ p.append(h)
+ p.append('>>>' + t)
+ else:
+ p.append(x)
+ return p
+
+def get_doc(members):
+ try: doc = members['__doc__']
+ except KeyError: pass
+ if doc: return doc
+ try: doc = 'Python module %s' % members['__name__']
+ except KeyError: pass
+ if doc: return doc
+ else: return 'A Python module'
+
+def format_synopsis(synopsis, link=False, classname=None):
+ lst = synopsis.split('\n')
+ for i, s in zip(range(len(lst)), lst):
+ m = re.match(r'(?P<func>\w+)(?P<args>.*)', s)
+ args = re.sub(r'([a-zA-Z]\w+)', r'<var>\1</var>', m.group('args'))
+ func = m.group('func')
+ if link:
+ if classname:
+ func = '<a href="#%s-%s">%s</a>' % (classname, func, func)
+ else:
+ func = '<a href="#%s">%s</a>' % (func, func)
+ lst[i] = func + args
+ return '<br/>\n'.join(lst)
+
+def format_para(p):
+ if not p: return ''
+ doc = ''
+ if p.startswith('>>>'): doc += '<pre>\n%s\n</pre>\n' % q(p)
+ else:
+ if not re.search('^- ', p, re.M): doc += '<p>%s</p>\n' % q(p)
+ else:
+ p = re.split('(?m)^- ', p)
+ if p[0]: doc += '<p>%s</p>\n' % q(p[0].strip())
+ del p[0]
+ doc += ('<ul>%s</ul>\n'
+ % '\n'.join(['<li>%s</li>' % q(p.strip()) for p in p]))
+ return doc
+
+def preprocess_routine(name, doc):
+ parts = split_para(doc)
+ if parts: summary = parts.pop(0)
+ else: summary = 'FIXME'
+ if parts and re.match(r'\w+\(.*\)', parts[0]): synopsis = parts.pop(0)
+ else: synopsis = name + '()'
+ return {'synopsis': synopsis, 'summary': summary, 'details': parts}
+
+def analyse(obj):
+ members = obj.__dict__
+ if inspect.isclass(obj):
+ main_doc = preprocess_routine(obj.__name__, get_doc(members))
+ bases = [x.__name__ for x in obj.__bases__]
+ else:
+ main_doc = split_para(get_doc(members))
+ bases = []
+ routines = {}
+ classes = {}
+ data = {}
+ for name, m in members.items():
+ if name.startswith('__'): continue
+ try:
+ mro = list(inspect.getmro(m))
+ if mro[0] != m: continue
+ except AttributeError: pass
+ if inspect.isroutine(m):
+ try: doc = m.__doc__
+ except KeyError: pass
+ if not doc: doc = 'FIXME'
+ routines[name] = preprocess_routine(name, doc)
+ continue
+ if inspect.isclass(m):
+ classes[name] = analyse(m)
+ continue
+ t = type(m)
+ if t == types.IntType or t == types.StringType:
+ data[name] = repr(m)
+ else:
+ data[name] = m.__doc__
+ return {'name': obj.__name__, 'doc': main_doc, 'routines': routines,
+ 'classes': classes, 'data': data, 'bases': bases}
+
+def format(tree, level, prefix=''):
+ name = tree['name']
+ if prefix: fullname = '%s-%s' % (prefix, name)
+ else: fullname = name
+ ##### Main doc
+ doc = []
+ if level > 1:
+ doc = ['<h%d id="%s">' % (level, fullname)]
+ try: doc.append(format_synopsis(tree['doc']['synopsis']))
+ except TypeError:
+ doc.append(name)
+ doc.append('</h%d>\n' % level)
+ if tree.has_key('bases'):
+ doc.append('<p>Bases: %s.</p>\n' % ', '.join(tree['bases']))
+ try: lst = [tree['doc']['summary']] + tree['doc']['details']
+ except TypeError: lst = tree['doc']
+ for p in lst: doc.append(format_para(p))
+ ##### Table of contents
+ routines = tree['routines'].keys()
+ classes = tree['classes'].keys()
+ data = tree['data'].keys()
+ if routines:
+ routines.sort()
+ if level == 1: doc.append('<p><b>Functions:</b></p>\n')
+ else: doc.append('<p><b>Methods:</b></p>\n')
+ doc.append('<ul class="ltoc">\n')
+ for r in routines:
+ synopsis = tree['routines'][r]['synopsis']
+ doc.append('<li>%s</li>\n' % format_synopsis(synopsis, True,
+ fullname))
+ doc.append('</ul>\n')
+ if classes:
+ classes.sort()
+ doc.append('<p><b>Classes:</b></p>\n')
+ doc.append('<ul class="ltoc">\n')
+ for r in classes:
+ synopsis = tree['classes'][r]['doc']['synopsis']
+ doc.append('<li>%s</li>\n' % format_synopsis(synopsis, True,
+ fullname))
+ doc.append('</ul>\n')
+ if data:
+ data.sort()
+ doc.append('<p><b>Data:</b></p>\n')
+ doc.append('<ul class="ltoc">\n')
+ for r in data:
+ doc.append('<li>%s = %s</li>\n' % (r, q(tree['data'][r])))
+ doc.append('</ul>\n')
+ ##### Functions
+ if routines:
+ if level == 1: doc.append('<hr/>\n')
+ doc.append('<dl>\n')
+ for r in routines:
+ doc.append('<dt id="%s-%s">' % (fullname, r))
+ rt = tree['routines'][r]
+ doc.append('%s</dt>\n<dd>' % format_synopsis(rt['synopsis']))
+ for p in [rt['summary']] + rt['details']:
+ doc.append(format_para(p))
+ doc.append('</dd>\n')
+ doc.append('</dl>\n')
+ ##### Classes
+ if classes:
+ for r in classes:
+ doc.append('<hr/>\n')
+ doc.append(format(tree['classes'][r], level+1, fullname))
+ return ''.join(doc)
+
+exec 'import %s as __test__' % modname
+doctree = analyse(__test__)
+document = format(doctree, 1)
+print modname + '.html'
+fh = file(modname + '.html', 'w')
+if selfcontained: fh.write(html_head % (modname, 'module API'))
+fh.write(document)
+if selfcontained: fh.write(html_foot)
+fh.close()
+for f in plain_docs:
+ try: fh = file(f, 'r')
+ except: continue
+ document = fh.read()
+ fh.close()
+ print f + '.xhtml'
+ fh = file(f + '.xhtml', 'w')
+ if selfcontained: fh.write(html_head % (modname, f))
+ fh.write('<h1>%s %s</h1>\n\n' % (modname, f))
+ fh.write('<pre class="main">\n')
+ fh.write(document)
+ fh.write('</pre>\n')
+ if selfcontained: fh.write(html_foot)
+ fh.close()
diff --git a/libraries/python-levenshtein/python-levenshtein.SlackBuild b/libraries/python-levenshtein/python-levenshtein.SlackBuild
new file mode 100644
index 000000000000..cc4bd9ac9a29
--- /dev/null
+++ b/libraries/python-levenshtein/python-levenshtein.SlackBuild
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+# Slackware build script for python-levenshtein
+
+# Copyright (c) 2007 Daniel de Kok <moc.mikciat@leinad>
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Exit on most errors
+set -e
+
+PRGNAM=python-levenshtein
+DISTNAM=python-Levenshtein
+VERSION=0.10.1
+ARCH=${ARCH:-i486}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+if [ "$ARCH" = "i486" ]; then
+ SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+fi
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $DISTNAM-$VERSION
+tar xzvf $CWD/$DISTNAM-$VERSION.tar.gz
+cd $DISTNAM-$VERSION
+cp $CWD/genextdoc.py .
+chown -R root:root .
+chmod -R u+w,go+r-w,a-s .
+
+CFLAGS="$SLKCFLAGS" \
+python setup.py bdist
+
+tar -C $PKG -zxvf dist/$DISTNAM-$VERSION.linux-i686.tar.gz
+
+find $PKG | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+
+# Generate HTML documentation that describes the module functions.
+# Maybe we'll want to replace the Python version number with a variable
+# in the future, but for the moment this is for Slackware Linux 11.
+PYTHONPATH=$PKG/usr/lib/python2.4/site-packages sh gendoc.sh --selfcontained
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a COPYING Levenshtein.html NEWS README $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+
+# Add the StringMatcher moduke as an example. You may choose to provide
+# this system-wide.
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/examples
+cp StringMatcher.py $PKG/usr/doc/$PRGNAM-$VERSION/examples
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.tgz
diff --git a/libraries/python-levenshtein/python-levenshtein.info b/libraries/python-levenshtein/python-levenshtein.info
new file mode 100644
index 000000000000..2e1ea56c4323
--- /dev/null
+++ b/libraries/python-levenshtein/python-levenshtein.info
@@ -0,0 +1,8 @@
+PRGNAM="python-levenshtein"
+VERSION="0.10.1"
+HOMEPAGE="http://trific.ath.cx/resources/python/levenshtein/"
+DOWNLOAD="http://trific.ath.cx/Ftp/python/levenshtein/python-Levenshtein-0.10.1.tar.gz"
+MD5SUM="c21cb043bb2951b3197a0447bd61aba4"
+MAINTAINER="Daniel de Kok"
+EMAIL="danieldk@pobox.com"
+APPROVED="robw810"
diff --git a/libraries/python-levenshtein/slack-desc b/libraries/python-levenshtein/slack-desc
new file mode 100644
index 000000000000..6d4385c6f2a2
--- /dev/null
+++ b/libraries/python-levenshtein/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|' on
+# the right side marks the last column you can put a character in. You must make
+# exactly 11 lines for the formatting to be correct. It's also customary to
+# leave one space after the ':'.
+
+ |-----handy-ruler------------------------------------------------------|
+python-levenshtein: python-levenshtein (string distance calculation module)
+python-levenshtein:
+python-levenshtein: python-levenhstein is a C extension module for Python that can be
+python-levenshtein: used for fast calculation of string distances with the Levenshtein
+python-levenshtein: algorithm, as well as some other methods.
+python-levenshtein:
+python-levenshtein: The python-levenshtein website can be found at:
+python-levenshtein: http://trific.ath.cx/resources/python/levenshtein/
+python-levenshtein:
+python-levenshtein:
+python-levenshtein: