From d487487f368e65242c50657b8a0dd76ba5f1c069 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Wed, 29 Oct 2008 21:35:58 +0000 Subject: [PATCH 1/5] Initialize branch F-9 for python-Levenshtein --- branch | 1 + 1 file changed, 1 insertion(+) create mode 100644 branch diff --git a/branch b/branch new file mode 100644 index 0000000..1c26f78 --- /dev/null +++ b/branch @@ -0,0 +1 @@ +F-9 From 611f5ecdd85d16b89026dff4536413136bde4e6d Mon Sep 17 00:00:00 2001 From: dwayne Date: Thu, 30 Oct 2008 05:18:00 +0000 Subject: [PATCH 2/5] Initial import of python-Levenshtein for F-9 rhbz#429882 --- .cvsignore | 1 + genextdoc.py | 216 ++++++++++++++++++++++++++++++++++++++++ import.log | 1 + python-Levenshtein.spec | 78 +++++++++++++++ sources | 1 + 5 files changed, 297 insertions(+) create mode 100644 genextdoc.py create mode 100644 import.log create mode 100644 python-Levenshtein.spec diff --git a/.cvsignore b/.cvsignore index e69de29..67550fe 100644 --- a/.cvsignore +++ b/.cvsignore @@ -0,0 +1 @@ +python-Levenshtein-0.10.1.tar.bz2 diff --git a/genextdoc.py b/genextdoc.py new file mode 100644 index 0000000..c07399d --- /dev/null +++ b/genextdoc.py @@ -0,0 +1,216 @@ +#!/usr/bin/env python +# Simple Python extension module doc generator. +# @(#) $Id: genextdoc.py,v 1.1 2008/10/30 05:18:00 dwayne Exp $ +# Written by Yeti +# 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 = """\ + + + +%s %s + +""" + +html_foot = """\ + + +""" + +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\w+)(?P.*)', s) + args = re.sub(r'([a-zA-Z]\w+)', r'\1', m.group('args')) + func = m.group('func') + if link: + if classname: + func = '%s' % (classname, func, func) + else: + func = '%s' % (func, func) + lst[i] = func + args + return '
\n'.join(lst) + +def format_para(p): + if not p: return '' + doc = '' + if p.startswith('>>>'): doc += '
\n%s\n
\n' % q(p) + else: + if not re.search('^- ', p, re.M): doc += '

%s

\n' % q(p) + else: + p = re.split('(?m)^- ', p) + if p[0]: doc += '

%s

\n' % q(p[0].strip()) + del p[0] + doc += ('
    %s
\n' + % '\n'.join(['
  • %s
  • ' % 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 = ['' % (level, fullname)] + try: doc.append(format_synopsis(tree['doc']['synopsis'])) + except TypeError: + doc.append(name) + doc.append('\n' % level) + if tree.has_key('bases'): + doc.append('

    Bases: %s.

    \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('

    Functions:

    \n') + else: doc.append('

    Methods:

    \n') + doc.append('
      \n') + for r in routines: + synopsis = tree['routines'][r]['synopsis'] + doc.append('
    • %s
    • \n' % format_synopsis(synopsis, True, + fullname)) + doc.append('
    \n') + if classes: + classes.sort() + doc.append('

    Classes:

    \n') + doc.append('
      \n') + for r in classes: + synopsis = tree['classes'][r]['doc']['synopsis'] + doc.append('
    • %s
    • \n' % format_synopsis(synopsis, True, + fullname)) + doc.append('
    \n') + if data: + data.sort() + doc.append('

    Data:

    \n') + doc.append('
      \n') + for r in data: + doc.append('
    • %s = %s
    • \n' % (r, q(tree['data'][r]))) + doc.append('
    \n') + ##### Functions + if routines: + if level == 1: doc.append('
    \n') + doc.append('
    \n') + for r in routines: + doc.append('
    ' % (fullname, r)) + rt = tree['routines'][r] + doc.append('%s
    \n
    ' % format_synopsis(rt['synopsis'])) + for p in [rt['summary']] + rt['details']: + doc.append(format_para(p)) + doc.append('
    \n') + doc.append('
    \n') + ##### Classes + if classes: + for r in classes: + doc.append('
    \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('

    %s %s

    \n\n' % (modname, f)) + fh.write('
    \n')
    +    fh.write(document)
    +    fh.write('
    \n') + if selfcontained: fh.write(html_foot) + fh.close() diff --git a/import.log b/import.log new file mode 100644 index 0000000..c9f8325 --- /dev/null +++ b/import.log @@ -0,0 +1 @@ +python-Levenshtein-0_10_1-6_fc9:F-9:python-Levenshtein-0.10.1-6.fc9.src.rpm:1225343755 diff --git a/python-Levenshtein.spec b/python-Levenshtein.spec new file mode 100644 index 0000000..53a0a9f --- /dev/null +++ b/python-Levenshtein.spec @@ -0,0 +1,78 @@ +%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} + +Name: python-Levenshtein +Summary: Python extension computing string distances and similarities +Version: 0.10.1 +Release: 6%{?dist} + +Group: Development/Libraries +License: GPLv2+ + +# The original site: http://trific.ath.cx/python/levenshtein/ +# no longer exists so pointing to the pypi listing instead. +URL: http://pypi.python.org/pypi/python-Levenshtein/ + +# The wayback machine provides this link to the original source: +# http://web.archive.org/web/20060715051500/http://trific.ath.cx/Ftp/python/levenshtein/python-Levenshtein-0.10.1.tar.bz2 +# SHA1: d630141e003f47a43e0f8eacdcbf593bf9d15ed6 +# The sourceforge files are a mirror of these files. +Source: http://downloads.sourceforge.net/translate/python-Levenshtein-%{version}.tar.bz2 + +# The same applies to genextdoc.py see v 1.5: +# http://web.archive.org/web/20060717041205/http://trific.ath.cx/Ftp/python/genextdoc.py +# SHA1: 5c91974b102f42144529913ce181c1866451bcf6 +Source1: genextdoc.py +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: python-devel +BuildRequires: python-setuptools-devel + +%description +Levenshtein computes Levenshtein distances, similarity ratios, generalized +medians and set medians of Strings and Unicodes. Because it's implemented +in C, it's much faster than corresponding Python library functions and +methods. + + +%prep +%setup -q +cp %{SOURCE1} . + +%build +CFLAGS="$RPM_OPT_FLAGS" %{__python} -c 'import setuptools; execfile("setup.py")' build + +%install +rm -rf $RPM_BUILD_ROOT +%{__python} -c 'import setuptools; execfile("setup.py")' install --skip-build --root $RPM_BUILD_ROOT +PYTHONPATH=$PYTHONPATH:$RPM_BUILD_ROOT/%{python_sitearch} %{__python} genextdoc.py Levenshtein + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +%doc README COPYING NEWS StringMatcher.py Levenshtein.html +%{python_sitearch}/*egg-info +%{python_sitearch}/Levenshtein.so + +%changelog +* Thu Mar 27 2008 Dwayne Bailey - 0.10.1-6 +- Comments about location of source files +- Update genextdoc.py to v1.5 + +* Thu Mar 27 2008 Dwayne Bailey - 0.10.1-5 +- Build and package *egg-info +- Fix some rpmlint issues + +* Thu Feb 14 2008 Dwayne Bailey - 0.10.1-4 +- Add genextdoc.py as Source not Patch + +* Wed Jan 30 2008 Dwayne Bailey - 0.10.1-3 +- Some rpmlint fixes +- Fix document generation + +* Wed Jan 23 2008 Dwayne Bailey - 0.10.1-2 +- Add missing genextdoc.py to generate usage documentation + +* Wed Jan 23 2008 Dwayne Bailey - 0.10.1-1 +- Initial packaging diff --git a/sources b/sources index e69de29..57ba7c9 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +af9b9c69c4563e211b11dc5184a93872 python-Levenshtein-0.10.1.tar.bz2 From 8333afd9bec3f51fea0a1542571d2a4b55e5597d Mon Sep 17 00:00:00 2001 From: dwayne Date: Thu, 30 Oct 2008 06:10:26 +0000 Subject: [PATCH 3/5] Fix date in changelog --- python-Levenshtein.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-Levenshtein.spec b/python-Levenshtein.spec index 53a0a9f..cbccd3c 100644 --- a/python-Levenshtein.spec +++ b/python-Levenshtein.spec @@ -56,7 +56,7 @@ rm -rf $RPM_BUILD_ROOT %{python_sitearch}/Levenshtein.so %changelog -* Thu Mar 27 2008 Dwayne Bailey - 0.10.1-6 +* Tue Oct 21 2008 Dwayne Bailey - 0.10.1-6 - Comments about location of source files - Update genextdoc.py to v1.5 From 4f38a1bfecdf1cf9d06346d8fbdd774a28dd3201 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 26 Nov 2009 01:52:41 +0000 Subject: [PATCH 4/5] Fix typo that causes a failure to update the common directory. (releng #2781) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ff74265..313cb05 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NAME := python-Levenshtein SPECFILE = $(firstword $(wildcard *.spec)) define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done endef MAKEFILE_COMMON := $(shell $(find-makefile-common)) From fd751c13937e104f7954edbabb9061e4f8428e8b Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 29 Jul 2010 10:10:32 +0000 Subject: [PATCH 5/5] dist-git conversion --- .cvsignore => .gitignore | 0 Makefile | 21 --------------------- branch | 1 - import.log | 1 - 4 files changed, 23 deletions(-) rename .cvsignore => .gitignore (100%) delete mode 100644 Makefile delete mode 100644 branch delete mode 100644 import.log diff --git a/.cvsignore b/.gitignore similarity index 100% rename from .cvsignore rename to .gitignore diff --git a/Makefile b/Makefile deleted file mode 100644 index 313cb05..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: python-Levenshtein -# $Id$ -NAME := python-Levenshtein -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/branch b/branch deleted file mode 100644 index 1c26f78..0000000 --- a/branch +++ /dev/null @@ -1 +0,0 @@ -F-9 diff --git a/import.log b/import.log deleted file mode 100644 index c9f8325..0000000 --- a/import.log +++ /dev/null @@ -1 +0,0 @@ -python-Levenshtein-0_10_1-6_fc9:F-9:python-Levenshtein-0.10.1-6.fc9.src.rpm:1225343755