gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r2950 - Extractor-python


From: bader
Subject: [GNUnet-SVN] r2950 - Extractor-python
Date: Fri, 2 Jun 2006 05:27:18 -0700 (PDT)

Author: bader
Date: 2006-06-02 05:27:09 -0700 (Fri, 02 Jun 2006)
New Revision: 2950

Added:
   Extractor-python/COPYING
   Extractor-python/setup.py
Removed:
   Extractor-python/Makefile.am
   Extractor-python/README.debian
   Extractor-python/bootstrap
   Extractor-python/configure.ac
   Extractor-python/libextractor_python.c
   Extractor-python/libextractor_python_setup.py
   Extractor-python/m4/
Modified:
   Extractor-python/AUTHORS
   Extractor-python/ChangeLog
   Extractor-python/README
   Extractor-python/extract.py
   Extractor-python/extractor.py
Log:
python ctypes binding replace old one

Modified: Extractor-python/AUTHORS
===================================================================
--- Extractor-python/AUTHORS    2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/AUTHORS    2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,2 +1,2 @@
-Heiko Wundram <address@hidden>
+Bader Ladjemi <address@hidden>
 Christian Grothoff <address@hidden>

Added: Extractor-python/COPYING
===================================================================
--- Extractor-python/COPYING    2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/COPYING    2006-06-02 12:27:09 UTC (rev 2950)
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+    51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program 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 program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Modified: Extractor-python/ChangeLog
===================================================================
--- Extractor-python/ChangeLog  2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/ChangeLog  2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,4 +1,8 @@
+Sun May        28 00:42:00 CEST 2006
+       Rewrited using ctypes
+       
 Mon Jul  4 17:19:33 CEST 2005
-        Moved python binding into separate package.
+       Moved python binding into separate package.
 
        
+       

Deleted: Extractor-python/Makefile.am
===================================================================
--- Extractor-python/Makefile.am        2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/Makefile.am        2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,9 +0,0 @@
-all:
-       python libextractor_python_setup.py $(EXT_LIB_PATH) build
-install-exec-local:
-       python libextractor_python_setup.py $(EXT_LIB_PATH) install 
--prefix=$(PYTHON_PREFIX)
-EXTRA_DIST = \
-  extract.py \
-  libextractor_python_setup.py \
-  libextractor_python.c \
-  README.debian
\ No newline at end of file

Modified: Extractor-python/README
===================================================================
--- Extractor-python/README     2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/README     2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,11 +1,81 @@
-This is the python binding for libextractor.
+Python bindings for GNU libextractor
 
-Actually, there are two bindings in this package.
-One written by Heiko Wundram (abandoned) and
-another one drafted by Bader Lejmi (extractor.py).
+About libextractor
+==================
 
-Also note that there is a third binding for both
-libextractor and doodle by nokos, available at
-http://gnunet.org/libextractor/download/
+ libextractor is a simple library for keyword extraction.  libextractor
+ does not support all formats but supports a simple plugging mechanism
+ such that you can quickly add extractors for additional formats, even
+ without recompiling libextractor. libextractor typically ships with a
+ dozen helper-libraries that can be used to obtain keywords from common
+ file-types.  
 
-I have no idea which is best at this time.
+ libextractor is a part of the GNU project (http://www.gnu.org/).
+
+Dependencies
+============
+ 
+ * python >= 2.3
+    web site: http://www.python.org/
+
+ * libextractor > 0.5
+    web site: http://gnunet.org/libextractor
+
+ * ctypes >= 0.9 
+    web site: http://starship.python.net/crew/theller/ctypes/
+
+ * setuptools (optional)
+    web site: http://cheeseshop.python.org/pypi/setuptools
+
+Performances
+============
+
+ Surprisingly the original C native library is only 20% faster than
+ this python ctypes bindings. Here a quick and dirty bench:
+  
+ The C extract on Extractor test files:
+
+ $ time `find Extractor/test -type f -not -name "*.svn*"|xargs extract`
+   
+  real    0m0.403s
+  user    0m0.303s
+  sys     0m0.061s
+
+ Same data with the ctypes python bindings:
+
+ $ time `find Extractor/test -type f -not -name "*.svn*"|xargs extract.py`
+   
+  real    0m0.661s
+  user    0m0.529s
+  sys     0m0.074s
+
+Install
+=======
+
+ Using the tarball (as root):
+ # python setup.py install
+
+ Using the egg (as root):
+ # easy_install Extractor-*.egg
+
+Copyright
+=========
+ 
+ Copyright (C) 2006 Bader Ladjemi <address@hidden>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program 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 program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+ see COPYING for details
+

Deleted: Extractor-python/README.debian
===================================================================
--- Extractor-python/README.debian      2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/README.debian      2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,26 +0,0 @@
-This is a list of debian (sarge) packages that you may want to install
-prior to compiling libextractor-python. 
-
-Naturally, you will also need libextractor itself.
-
-=====================================================================
-
-Basic compilation tools and dependencies:
-
-libtool
-gcc
-make
-python2.3-dev
-
-
-For Subversion access and compilation:
-
-subversion
-autoconf
-automake1.8
-
-==============================================
-
-Please notify us if we missed some dependencies
-(note that the list is supposed to only list direct
-dependencies, not transitive dependencies).

Deleted: Extractor-python/bootstrap
===================================================================
--- Extractor-python/bootstrap  2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/bootstrap  2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,4 +0,0 @@
-#!/bin/sh
-aclocal -I m4
-autoconf
-automake -a

Deleted: Extractor-python/configure.ac
===================================================================
--- Extractor-python/configure.ac       2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/configure.ac       2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,57 +0,0 @@
-# Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.57)
-AC_INIT([libextractor-python], [0.5.4], address@hidden)
-AC_REVISION($Revision: 1.67 $)
-AM_INIT_AUTOMAKE([libextractor-python], [0.5.4])
-
-AC_PROG_AWK
-AC_PROG_CC
-
-AC_PYTHON_DEVEL
-AC_MSG_CHECKING(for python)
-if test -z "$python_path";
-then
-  AC_MSG_RESULT(yes)
-  AM_CONDITIONAL(HAVE_PYTHON,false)
-else
-  AC_MSG_RESULT(no)
-  AM_CONDITIONAL(HAVE_PYTHON,true)
-fi
-
-# test for libextractor
-extractor=0
-AC_MSG_CHECKING([for libextractor])
-AC_ARG_WITH(extractor,
-   [  --with-extractor=PFX    Base of libextractor installation],
-   [AC_MSG_RESULT([$with_extractor])
-    case $with_extractor in
-      no)
-        ;;
-      yes)
-        AC_CHECK_HEADERS(extractor.h,
-          AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
-            extractor=1))
-        ;;
-      *)
-        LDFLAGS="-L$with_extractor/lib $LDFLAGS"
-        CPPFLAGS="-I$with_extractor/include $CPPFLAGS"
-        AC_CHECK_HEADERS(extractor.h,
-          AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
-            EXT_LIB_PATH="$with_extractor"
-            extractor=1))
-        ;;
-    esac
-   ],
-   [AC_MSG_RESULT([--with-extractor not specified])
-    AC_CHECK_HEADERS(extractor.h,
-     AC_CHECK_LIB([extractor], [EXTRACTOR_loadDefaultLibraries],
-      extractor=1))])
-if test "$extractor" != 1
-then
- AC_MSG_ERROR([libextractor-python requires libextractor])
-fi
-
-AC_SUBST(EXT_LIB_PATH)
-
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT

Modified: Extractor-python/extract.py
===================================================================
--- Extractor-python/extract.py 2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/extract.py 2006-06-02 12:27:09 UTC (rev 2950)
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 """extract.py
 
      This file is part of libextractor.
@@ -26,7 +27,7 @@
 
 xtract = extractor.Extractor()
 for arg in sys.argv[1:]:
-    print "Keywords from " + arg
-    keys = xtract.extract(arg);
-    for i in keys:
-        print i
+    print "Keywords from %s:" % arg
+    keys = xtract.extract(arg)
+    for keyword_type, keyword in keys:
+        print "%s - %s" % (keyword_type.encode('iso-8859-1'), 
keyword.encode('iso-8859-1'))

Modified: Extractor-python/extractor.py
===================================================================
--- Extractor-python/extractor.py       2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/extractor.py       2006-06-02 12:27:09 UTC (rev 2950)
@@ -32,12 +32,19 @@
 """
 from ctypes import *
 #fake cdll import
-libextractor = cdll.extractor
-
-__all__ = ['Extractor', 'isBinaryType']
+try:
+    #loading shared object file
+    libextractor = cdll.LoadLibrary('libextractor.so.1')
+except OSError:
+    libextractor = cdll.extractor
+ 
+__all__ = ['Extractor', 'isBinaryType', 'EXTRACTOR_ENCODING', 
'DEFAULT_LIBRARIES', 'EXTRACTOR_THUMBNAIL_DATA']
 __version__ = "0.5"
 __licence__ = "GNU GPL"
 
+"""
+keyword's charset encoding
+"""
 EXTRACTOR_ENCODING = "utf-8"
 
 KeywordType = c_int
@@ -58,28 +65,26 @@
 libextractor.EXTRACTOR_removeDuplicateKeywords.restype = KEYWORDS
 libextractor.EXTRACTOR_getKeywordTypeAsString.restype = c_char_p
 
-## Extractors_p = POINTER('Extractors')
-## ExtractMethod = CFUNCTYPE(Keywords, c_char_p, c_int, Keywords, c_char_p)
-## class Extractors(Structure):
-##     """
-##     EXTRACTOR_Extractor struct
-##     """
-##     _field_ = [('libraryHandle', c_void_p),
-##            ('libname', c_char_p),
-##            ('extractMethod', ExtractMethod),
-##            ('next', Extractors_p),
-##            ('options', c_char_p)]
-## SetPointerType(Extractors_p, Extractors)
+libextractor.EXTRACTOR_getDefaultLibraries.restype = c_char_p
 
-## EXTRACTORS = POINTER(Extractors)
+"""
+thumbnail keyword type (binary)
+"""
+EXTRACTOR_THUMBNAIL_DATA = 70
 
-## libextractor.EXTRACTOR_loadDefaultLibraries.restype = EXTRACTORS
-## libextractor.EXTRACTOR_loadConfigLibraries.restype = EXTRACTORS
-## libextractor.EXTRACTOR_addLibrary.restype = EXTRACTORS
-## libextractor.EXTRACTOR_addLibraryLast.restype = EXTRACTORS
+def isBinaryType(keyword_type):
+    """
+    returns if the given keyword_type is binary
 
-libextractor.EXTRACTOR_getDefaultLibraries.restype = c_char_p
+    @param keyword_type: keyword type (int)
+    """
+    return keyword_type == EXTRACTOR_THUMBNAIL_DATA
 
+"""
+default loaded libraries
+"""
+DEFAULT_LIBRARIES = libextractor.EXTRACTOR_getDefaultLibraries().split(':')
+
 class Extractor(object):
     """
     Main class for extracting meta-data with GNU libextractor.
@@ -94,96 +99,157 @@
     libraries that should be used.
     """
     
-    def __init__(self, defaults=True, libraries=None, lang=None, 
languages=None, hash=None, use_filename=False, duplicates=True, 
split_keywords=False):
+    def __init__(self, defaults=True, libraries=None, lang=None, 
languages=None, hash=None, use_filename=False, split_keywords=False):
        """
        Initialize Extractor's instance
-       @param extractors list of strings that contains extractor's name 
(supported types)
-       @param defaults load default plugins
-       @param lang use the generic plaintext extractor for the language with 
the 2-letter language code LANG
-       @param languages list of lang
-       @param hash compute hash using the given algorithm (currently 'sha1' or 
'md5')
-       @param use_filename use the filename as a keyword (add 
filename-extractor library)
-       @param duplicates remove duplicates only if types match
-       @param split_keywords use keyword splitting (add split-extractor 
library)
+       
+       @param extractors: list of strings that contains extractor's name 
(supported types)
+       @param defaults: load default plugins
+       @param lang: use the generic plaintext extractor for the language with 
the 2-letter language code LANG
+       @param languages: list of lang
+       @param hash: compute hash using the given algorithm (currently 'sha1' 
or 'md5')
+       @param use_filename: use the filename as a keyword (add 
filename-extractor library)
+       @param split_keywords: use keyword splitting (add split-extractor 
library)
+
+       >>> Extractor() #doctest: +ELLIPSIS
+       <__main__.Extractor object at 0x...>
+       
+       >>> extractor = Extractor(defaults=False)
+       >>> extractor.libraries
+       ()
+
+       >>> extractor = Extractor()
+       >>> sorted(extractor.libraries) == sorted(tuple(DEFAULT_LIBRARIES))
+       True
+
+       >>> extractor = Extractor(hash='md5')
+       >>> found = False
+       >>> for library in extractor.libraries:
+       ...     if 'md5' in library:
+       ...        found = True
+       ...        break
+       >>> found
+       True
+
+       >>> extractor = Extractor(use_filename=True)
+       >>> found = False
+       >>> for library in extractor.libraries:
+       ...     if 'filename' in library:
+       ...        found = True
+       ...        break
+       >>> found
+       True
+
+       >>> extractor = Extractor(split_keywords=True)
+       >>> found = False
+       >>> for library in extractor.libraries:
+       ...     if 'split' in library:
+       ...        found = True
+       ...        break
+       >>> found
+       True
+
        """
        self._libraries = {}
-
+       self.extractors = None
        if defaults:
            self.extractors = libextractor.EXTRACTOR_loadDefaultLibraries()
-           self._libraries = dict([(library, None) for library in 
libextractor.EXTRACTOR_getDefaultLibraries().split(':')])
+           self._libraries = dict([(library, None) for library in 
DEFAULT_LIBRARIES])
        if use_filename:
            self.addLibrary("libextractor_filename")
        if libraries:
            self.extractors = 
libextractor.EXTRACTOR_loadConfigLibraries(self.extractors, libraries)
            self._libraries.update(dict([(library, None) for library in 
libraries.split(':')]))
        if isinstance(lang, str):
-           self.addLibraryLast("libextractor_printable_" % lang)
+           self.addLibraryLast("libextractor_printable_%s" % lang)
        if isinstance(hash, str):
-           self.addLibraryLast("libextractor_hash_" % hash)
+           self.addLibraryLast("libextractor_hash_%s" % hash)
        if languages:
-           [self.addLibraryLast("libextractor_printable_" % language) for 
language in languages]
+           [self.addLibraryLast("libextractor_printable_%s" % language) for 
language in languages]
        if split_keywords:
            self.addLibraryLast("libextractor_split")
-
-       self.duplicates = duplicates
     
     def extract(self, filename=None, data=None, size=None):
-       """Pass a filename, or data and size, to extract keywords.
+       """Extract keywords from a file, or from its data.
 
-       @param filename filename string
-       @param data data contents
-       @param size data size
+       @param filename: filename string
+       @param data: data contents
+       @param size: data size
        
-        This function returns a dictionary. Its keys are keywords types
-       and its values are keywords values. If the file cannot be opened
-       or cannot be found, the dictionary will be empty.  The list can
-       also be empty if no dictionary was found for the file.
+        This function returns a list of tuples. Its first value is keyword type
+       and its second value is keyword value. If the file cannot be opened
+       or cannot be found, the list will be empty.  The list can
+       also be empty if no keyword was found for the file.
 
+       If you give data, size had to be given too.
+
         """
        if not filename and not (data and size):
            return None
        elif filename:
-           return self.extractFile(filename)
+           return self.extractFromFile(filename)
        else:
-           return self.extractData(data, size)
+           return self.extractFromData(data, size)
        
-    def extractFile(self, filename):
-       """Pass a filename to extract keywords.
+    def extractFromFile(self, filename):
+       """Extract keywords from a file using its filename.
 
-       @param filename filename string
+       @param filename: filename string
        
-        This function returns a dictionary. Its keys are keywords types
-       and its values are keywords values. If the file cannot be opened
-       or cannot be found, the dictionary will be empty.  The list can
-       also be empty if no dictionary was found for the file.
+        This function returns a list of tuples. Its first value is keyword type
+       and its second value is keyword value. If the file cannot be opened
+       or cannot be found, the list will be empty.  The list can
+       also be empty if no keyword was found for the file.
 
+       >>> import os
+       >>> extractor = Extractor()
+       >>> filename = os.tmpnam()
+       >>> f = file(filename, 'w')
+       >>> extractor.extract(filename)
+       []
+
+       >>> import os
+       >>> extractor = Extractor()
+       >>> filename = '../Extractor/test/test.png'
+       >>> extractor.extract(filename)
+       [(u'comment', u'Testing keyword extraction\\n'), 
(u'resource-identifier', u'dc6c58c971715e8043baef058b675eec'), (u'size', 
u'4x4'), (u'mimetype', u'image/png')]
+
+       >>> import os, glob
+       >>> extractor = Extractor()
+       >>> filename = glob.glob('dist/*.gz')[0]
+       >>> extracted = extractor.extract(filename)
+       >>> filename_count = 0
+       >>> for keyword_type, keyword in extracted:
+        ...     if keyword_type == 'filename':
+       ...        filename_count += 1
+       >>> filename_count > 1
+       True
+
         """
        self.keywords_p = libextractor.EXTRACTOR_getKeywords(self.extractors, 
filename)
        return self._extract()
 
-    def extractData(self, data, size):
-       """Pass data to extract keywords.
+    def extractFromData(self, data, size):
+       """Extract keywords using its data.
 
-       @param data data contents
-       @param size data size
+       @param data: data contents
+       @param size: data size
        
-        This function returns a dictionary. Its keys are keywords types
-       and its values are keywords values. If the file cannot be opened
-       or cannot be found, the dictionary will be empty.  The list can
-       also be empty if no dictionary was found for the file.
+        This function returns a list of tuples. Its first value is keyword type
+       and its second value is keyword value. If the file cannot be opened
+       or cannot be found, the list will be empty.  The list can
+       also be empty if no keyword was found for the file.
 
         """
        self.keywords_p = libextractor.EXTRACTOR_getKeywords2(self.extractors, 
data, size)
        return self._extract()
     
     def _extract(self):
+       self.extracted = []
+
        if not self.keywords_p:
-           return None
-       
-       if self.duplicates:
-           self.keywords_p = 
libextractor.EXTRACTOR_removeDuplicateKeywords(self.keywords_p, 1)
-           
-       self.extracted = {}
+           return self.extracted
+
        try:
            self.keywords = self.keywords_p.contents
        except ValueError:
@@ -196,11 +262,12 @@
            if not isBinaryType(self.keywords.keywordType):
                keyword = keyword.decode(EXTRACTOR_ENCODING)
                
-           self.extracted[keyword_type] = keyword
+           self.extracted.append((keyword_type, keyword))
            try:
                self.keywords = self.keywords.next.contents
            except ValueError:
                libextractor.EXTRACTOR_freeKeywords(self.keywords_p)
+               self.keywords_p = None
                return self.extracted
            
     def addLibrary(self, library):
@@ -216,7 +283,7 @@
         No errors are reported if the library is not
         found.
 
-       @param library library's name
+       @param library: library's name
         """    
        self._libraries[library] = None
 
@@ -226,7 +293,7 @@
        """
        Same as addLibrary but the library is added at the last.
 
-       @param library library's name
+       @param library: library's name
        """
        self._libraries[library] = None
        
@@ -243,7 +310,7 @@
         removes the PDF extractor (if added).
        ValueError will be thrown if no library match.
 
-       @param library's name
+       @param library: library's name
        """
        try:
            del self._libraries[library]
@@ -257,7 +324,7 @@
        Add given libraries. 
        Same as addLibary but libraries is a list of library's names.
 
-       @param libraries list of libraries names
+       @param libraries: list of libraries names
        """
        for library in libraries:
            if isinstance(library, str):
@@ -266,14 +333,25 @@
     def removeAllLibraries(self):
        """
        Remove all libraries.
+
+       >>> extractor = Extractor()
+       >>> extractor.removeAllLibraries()
+       >>> extractor.libraries
+       ()
        """
-       self._libaries = {}
-       libextractor.EXTRACTOR_removeAll(self.extractors)
+       self._libraries = {}
+       if self.extractors:
+           libextractor.EXTRACTOR_removeAll(self.extractors)
+           self.extractors = None
        
     def keywordTypes(self):
        """
        Returns the list of all keywords types.
-       @return list of all keywords types
+       @return: list of all keywords types
+
+       >>> extractor = Extractor()
+       >>> extractor.keywordTypes()
+       ('unknown', 'filename', 'mimetype', 'title', 'author', 'artist', 
'description', 'comment', 'date', 'publisher', 'language', 'album', 'genre', 
'location', 'version', 'organization', 'copyright', 'subject', 'keywords', 
'contributor', 'resource-type', 'format', 'resource-identifier', 'source', 
'relation', 'coverage', 'software', 'disclaimer', 'warning', 'translated', 
'creation date', 'modification date', 'creator', 'producer', 'page count', 
'page orientation', 'paper size', 'used fonts', 'page order', 'created for', 
'magnification', 'release', 'group', 'size', 'summary', 'packager', 'vendor', 
'license', 'distribution', 'build-host', 'os', 'dependency', 'MD4', 'MD5', 
'SHA-0', 'SHA-1', 'RipeMD160', 'resolution', 'category', 'book title', 
'priority', 'conflicts', 'replaces', 'provides', 'conductor', 'interpreter', 
'owner', 'lyrics', 'media type', 'contact', 'binary thumbnail data', 
'publication date', 'camera make', 'camera model', 'exposure', 'aperture', 
'exposure bias', 'flash', 'flash bias', 'focal length', 'focal length (35mm 
equivalent)', 'iso speed', 'exposure mode', 'metering mode', 'macro mode', 
'image quality', 'white balance', 'orientation')
        """
        i = 0
        keyword_types = []
@@ -285,20 +363,41 @@
            keyword_types.append(keyword_type)
            i += 1
            
-       return keyword_types
+       return tuple(keyword_types)
     
     def _get_libraries(self):
-       return self._libraries.keys()
+       """
+       Return current libraries
+       @return: current libraries
+       """
+       return tuple(self._libraries.keys())
 
     def _set_libraries(self, libraries):
+       """
+       Add libraries to load (don't replace current ones)
+
+       @param libraries: list of libraries
+       
+       >>> extractor = Extractor()
+       >>> extractor.libraries = ('libextractor_filename', )
+       >>> 'libextractor_filename' in extractor.libraries
+       True
+       >>> len(extractor.libraries) == len(DEFAULT_LIBRARIES)+1
+       True
+       
+       """
        self.addLibraries(libraries)
-       
-    libraries = property(fget=_get_libraries, fset=_set_libraries, 
fdel=removeAllLibraries, doc='list of loaded libraries (read only)')
 
-    
-    def __delete__(self):
-       self.removeAllLibraries()
+    libraries = property(fget=_get_libraries, fset=_set_libraries, 
fdel=removeAllLibraries, doc='tuple of loaded libraries')
 
-EXTRACTOR_THUMBNAIL_DATA = 70
-def isBinaryType(keyword_type):
-    return keyword_type == EXTRACTOR_THUMBNAIL_DATA
+    def __del__(self):
+       """
+       >>> extractor = Extractor()
+       >>> del extractor
+       """
+       if self.extractors:
+           self.removeAllLibraries()
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()

Deleted: Extractor-python/libextractor_python.c
===================================================================
--- Extractor-python/libextractor_python.c      2006-06-02 08:16:05 UTC (rev 
2949)
+++ Extractor-python/libextractor_python.c      2006-06-02 12:27:09 UTC (rev 
2950)
@@ -1,536 +0,0 @@
-/*
-     This file is part of libextractor.
-     (C) 2004, 2005 Vidyut Samanta and Christian Grothoff
-
-     libextractor is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     libextractor 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 libextractor; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
- */
-
-
-/* libextractor_python.c
-   ---------------------
-
-   Implements the Python wrapper for libextractor. The wrapper builds on the
-   Python type module, which wraps a single module, over extractor, which
-   implements the extractor from modules, up to keyword(list), which implements
-   keyword handling. */
-
-/* Includes. */
-
-#include <Python.h>
-#include <extractor.h>
-
-/* Typedefs. */
-
-typedef struct {
-  PyObject_HEAD
-  PyObject *mlist;
-  int locks;
-} ModuleList;
-
-typedef struct {
-  PyObject_HEAD
-  EXTRACTOR_ExtractorList *module;
-  ModuleList *mlist;
-} Module;
-
-/* Type objects. */
-
-static PyTypeObject ModuleListType;
-static PyTypeObject ModuleType;
-
-/* Module list type. */
-
-static inline int ModuleList_checkModule(Module *arg)
-{
-  if( !PyObject_IsInstance((PyObject*)arg,(PyObject*)&ModuleType) ) {
-    PyErr_SetString(PyExc_TypeError,"append only accepts a Module.");
-    return -1;
-  }
-
-  if( arg->mlist ) {
-    PyErr_SetString(PyExc_TypeError,"cannot take ownership of module.");
-    return -1;
-  }
-
-  return 0;
-}
-
-static PyObject *ModuleList_prepend(ModuleList *self, Module *arg)
-{
-  PyObject *rv = NULL;
-  Module *first = NULL;
-  int mlistlen = 0;
-
-  if( ModuleList_checkModule(arg) )
-    goto error;
-
-  mlistlen = PyList_GET_SIZE(self->mlist);
-  if( mlistlen ) {
-    first = (Module*)PyList_GET_ITEM(self->mlist,0);
-    arg->module->next = first->module;
-  }
-
-  if( PyList_Insert(self->mlist,0,(PyObject*)arg) )
-    goto error;
-  arg->mlist = self;
-  Py_INCREF(self);
-
-  rv = (PyObject*)arg;
-  Py_INCREF(rv);
-
-  goto finish;
-
- error:
-  Py_XDECREF(rv);
-  rv = NULL;
-
- finish:
-  return (PyObject*)rv;
-}
-
-static PyObject *ModuleList_append(ModuleList *self, Module *arg)
-{
-  PyObject *rv = NULL;
-  Module *last = NULL;
-  int mlistlen = 0;
-
-  if( ModuleList_checkModule(arg) )
-    goto error;
-
-  mlistlen = PyList_GET_SIZE(self->mlist);
-  if( mlistlen ) {
-    last = (Module*)PyList_GET_ITEM(self->mlist,mlistlen-1);
-    last->module->next = arg->module;
-  }
-
-  if( PyList_Append(self->mlist,(PyObject*)arg) )
-    goto error;
-  arg->mlist = self;
-  Py_INCREF(self);
-
-  rv = (PyObject*)arg;
-  Py_INCREF(rv);
-
-  goto finish;
-
- error:
-  Py_XDECREF(rv);
-  rv = NULL;
-
- finish:
-  return (PyObject*)rv;
-}
-
-static PyObject *ModuleList_new(PyTypeObject *type, PyObject *args,
-                               PyObject *kwargs)
-{
-  ModuleList *self = NULL;
-
-  if( !( self = (ModuleList*)type->tp_alloc(type,0) ) )
-    goto error;
-  self->locks = 0;
-
-  if( !( self->mlist = PyList_New(0) ) )
-    goto error;
-
-  goto finish;
-
- error:
-  Py_XDECREF(self);
-  self = NULL;
-
- finish:
-  return (PyObject*)self;
-}
-
-static int ModuleList_init(ModuleList *self, PyObject *args, PyObject *kwargs)
-{
-  PyObject *mod = NULL, *mod_iter = NULL, *mod_item = NULL;
-  EXTRACTOR_ExtractorList *elist = NULL, *ecur = NULL;
-  char *kwargs_list[] = {"modules",NULL};
-  int rv = 0;
-
-  if( !PyArg_ParseTupleAndKeywords(args,kwargs,"|O:__init__",kwargs_list,
-                                  &mod) )
-    goto error;
-
-  if( !mod || mod == Py_None || PyString_Check(mod) ) {
-    if( !mod || mod == Py_None )
-      elist = EXTRACTOR_loadDefaultLibraries();
-    else
-      elist = EXTRACTOR_loadConfigLibraries(NULL,PyString_AsString(mod));
-
-    ecur = elist;
-    while( ecur ) {
-      if( !( mod_item = (PyObject*)PyObject_GC_New(Module,&ModuleType) ) )
-       goto error;
-
-      elist = ecur;
-      ecur = elist->next;
-      elist->next = NULL;
-
-      ((Module*)mod_item)->module = elist;
-      ((Module*)mod_item)->mlist = NULL;
-
-      if( !ModuleList_append(self,(Module*)mod_item) )
-       goto error;
-      Py_DECREF(mod_item);
-      mod_item = NULL;
-    }
-  } else if( PyObject_IsInstance(mod,(PyObject*)&ModuleType) ) {
-    if( !ModuleList_append(self,(Module*)mod) )
-      goto error;
-  } else {
-    if( !( mod_iter = PyObject_GetIter(mod) ) )
-      goto error;
-
-    while( ( mod_item = PyIter_Next(mod_iter) ) ) {
-      if( !ModuleList_append(self,(Module*)mod_item) )
-       goto error;
-      Py_DECREF(mod_item);
-      mod_item = NULL;
-    }
-  }
-
-  goto finish;
-
- error:
-  EXTRACTOR_removeAll(ecur);
-  Py_XDECREF(mod_item);
-  rv = -1;
-
- finish:
-  Py_XDECREF(mod_iter);
-  return rv;
-}
-
-static PyObject *ModuleList_repr(ModuleList *self)
-{
-  return PyString_FromFormat("<ModuleList: %i modules>",
-                            PyList_GET_SIZE(self->mlist));
-}
-
-static int ModuleList_traverse(ModuleList *self, visitproc visit, void *arg)
-{
-#ifdef Py_VISIT
-  Py_VISIT(self->mlist);
-#endif
-  return 0;
-}
-
-static int ModuleList_clear(ModuleList *self)
-{
-#ifdef Py_CLEAR
-  Py_CLEAR(self->mlist);
-#endif
-  return 0;
-}
-
-static void ModuleList_dealloc(ModuleList *self)
-{
-  ModuleList_clear(self);
-  self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyMethodDef ModuleList_methods[] = {
-  {"prepend",(PyCFunction)ModuleList_prepend,METH_O,
-   "Prepend a single module to the structure."},
-  {"append",(PyCFunction)ModuleList_append,METH_O,
-   "Append a single module to the structure."},
-  {NULL}  /* Sentinel */
-};
-
-static PyTypeObject ModuleListType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "extractor.ModuleList",    /*tp_name*/
-    sizeof(ModuleList),        /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)ModuleList_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    0,                         /*tp_getattr*/
-    0,                         /*tp_setattr*/
-    0,                         /*tp_compare*/
-    (reprfunc)ModuleList_repr, /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    0,                         /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-    "ModuleList objects",      /* tp_doc */
-    (traverseproc)ModuleList_traverse, /* tp_traverse */
-    (inquiry)ModuleList_clear, /* tp_clear */
-    0,                        /* tp_richcompare */
-    0,                        /* tp_weaklistoffset */
-    0,                         /* tp_iter */
-    0,                        /* tp_iternext */
-    ModuleList_methods,        /* tp_methods */
-    0,                         /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)ModuleList_init, /* tp_init */
-    0,                         /* tp_alloc */
-    ModuleList_new,            /* tp_new */
-};
-
-/* Module type. */
-
-static EXTRACTOR_KeywordList *
-Module_extractMethod(const char *filename,
-                    char *data, 
-                    size_t filesize,
-                    EXTRACTOR_KeywordList * next,
-                    const char *options) {
-  Module *self = NULL;
-
-  self = (Module*)atoi(options); /* convert back from string repr of self. */
-#if 0
-  printf("In the extractor with object %p.",
-         self);
-#endif
-  return next;
-}
-
-static PyObject *Module_new(PyTypeObject *type, PyObject *args,
-                           PyObject *kwargs)
-{
-  Module *self = NULL;
-  char *name = NULL, *options = NULL;
-  char *kwargs_list[] = {"name","options",NULL};
-  int namelen = 0, i;
-
-  if( !PyArg_ParseTupleAndKeywords(args,kwargs,"s#|z:__new__",kwargs_list,
-                                  &name,&namelen,&options) )
-    goto error;
-
-  i = 0;
-  while( name[i] )
-    if( name[i++] == '(' ) {
-      PyErr_SetString(PyExc_ValueError,"name may not contain (.");
-      goto error;
-    }
-
-  if( !( self = (Module*)type->tp_alloc(type,0) ) )
-    goto error;
-
-  /* Somewhat a HACK, creates a module structure from scratch. */
-  self->module = malloc(sizeof(EXTRACTOR_ExtractorList));
-  self->module->libraryHandle = NULL;
-  self->module->extractMethod = (ExtractMethod)&Module_extractMethod;
-  self->module->libname = strdup(name);
-  self->module->options = malloc(24); /* store self as string in options. */
-  snprintf(self->module->options, 24, "%p", self);
-  self->module->next = NULL;
-
-  goto finish;
-
- error:
-  Py_XDECREF(self);
-  self = NULL;
-
- finish:
-  return (PyObject*)self;
-}
-
-static int Module_init(Module *self, PyObject *args, PyObject *kwargs)
-{
-  char *name = NULL, *options = NULL, *optstring = NULL;
-  char *kwargs_list[] = {"name","options",NULL};
-  int namelen = 0, optionslen = 0, i, rv = 0;
-
-  if( !PyArg_ParseTupleAndKeywords(args,kwargs,"s#|z#:__init__",kwargs_list,
-                                  &name,&namelen,&options,&optionslen) )
-    goto error;
-
-  i = 0;
-  while( options && options[i] )
-    if( options[i++] == ')' ) {
-      PyErr_SetString(PyExc_ValueError,"option may not contain ).");
-      goto error;
-    }
-
-  EXTRACTOR_removeAll(self->module); /* slight crutch, was allocated in */
-  self->module = NULL; /* __new__, so that programmer can create subtype. */
-
-  optstring = malloc(namelen+optionslen+3);
-  if( options )
-    sprintf(optstring,"%s(%s)",name,options);
-  else
-    sprintf(optstring,"%s",name);
-  if( !( self->module = EXTRACTOR_loadConfigLibraries(NULL,optstring) ) ) {
-    PyErr_SetString(PyExc_ValueError,"could not load module.");
-    goto error;
-  }
-
-  goto finish;
-
- error:
-  rv = -1;
-
- finish:
-  if( optstring )
-    free(optstring);
-  return rv;
-}
-
-static PyObject *Module_getattr(Module *self, char *name)
-{
-  if( !strcmp(name,"libname") )
-    return PyString_FromString(self->module->libname);
-  else if( !strcmp(name,"options") )
-    return PyString_FromString(self->module->options);
-  else if( !strcmp(name,"mlist") )
-    return (PyObject*)self->mlist;
-  PyErr_SetString(PyExc_AttributeError,name);
-  return NULL;
-}
-
-static int Module_setattr(Module *self, char *name, PyObject *value)
-{
-  if( !strcmp(name,"libname") || !strcmp(name,"options") ||
-      !strcmp(name,"mlist") )
-    PyErr_Format(PyExc_AttributeError,"cannot set %s.",name);
-  else
-    PyErr_SetString(PyExc_AttributeError,name);
-  return -1;
-}
-
-static PyObject *Module_repr(Module *self)
-{
-  if( self->module->options )
-    return PyString_FromFormat("%s(\"%s\",\"%s\")",self->ob_type->tp_name,
-                              self->module->libname,self->module->options);
-  else
-    return PyString_FromFormat("%s(\"%s\")",self->ob_type->tp_name,
-                              self->module->libname);
-}
-
-static long Module_hash(Module *self)
-{
-  return (int)self->module;
-}
-
-static int Module_traverse(Module *self, visitproc visit, void *arg)
-{
-#ifdef Py_VISIT
-  Py_VISIT((PyObject*)self->mlist);
-#endif
-  return 0;
-}
-
-static int Module_clear(Module *self)
-{
-#if 0
-  printf("Removing module in clear: %s.\n",
-         self->module->libname);
-#endif
-#ifdef Py_CLEAR
-  Py_CLEAR(self->mlist);
-#endif
-  return 0;
-}
-
-static void Module_dealloc(Module *self)
-{
-  Module_clear(self);
-#if 0
-  printf("Removing module: %s.\n",
-         self->module->libname);
-#endif
-  self->module->next = NULL;
-  EXTRACTOR_removeAll(self->module);
-  self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyMethodDef Module_methods[] = {
-  {NULL}  /* Sentinel */
-};
-
-static PyTypeObject ModuleType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
-    "extractor.Module",        /*tp_name*/
-    sizeof(Module),            /*tp_basicsize*/
-    0,                         /*tp_itemsize*/
-    (destructor)Module_dealloc, /*tp_dealloc*/
-    0,                         /*tp_print*/
-    (getattrfunc)Module_getattr, /*tp_getattr*/
-    (setattrfunc)Module_setattr, /*tp_setattr*/
-    0,                         /*tp_compare*/
-    (reprfunc)Module_repr,     /*tp_repr*/
-    0,                         /*tp_as_number*/
-    0,                         /*tp_as_sequence*/
-    0,                         /*tp_as_mapping*/
-    (hashfunc)Module_hash,     /*tp_hash */
-    0,                         /*tp_call*/
-    0,                         /*tp_str*/
-    0,                         /*tp_getattro*/
-    0,                         /*tp_setattro*/
-    0,                         /*tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-    "Module objects",          /* tp_doc */
-    (traverseproc)Module_traverse, /* tp_traverse */
-    (inquiry)Module_clear,     /* tp_clear */
-    0,                        /* tp_richcompare */
-    0,                        /* tp_weaklistoffset */
-    0,                         /* tp_iter */
-    0,                        /* tp_iternext */
-    Module_methods,            /* tp_methods */
-    0,                         /* tp_members */
-    0,                         /* tp_getset */
-    0,                         /* tp_base */
-    0,                         /* tp_dict */
-    0,                         /* tp_descr_get */
-    0,                         /* tp_descr_set */
-    0,                         /* tp_dictoffset */
-    (initproc)Module_init,     /* tp_init */
-    0,                         /* tp_alloc */
-    Module_new,                /* tp_new */
-};
-
-/* Module level. */
-
-static PyMethodDef Extractor_Module_methods[] = {
-  {NULL}  /* Sentinel */
-};
-
-PyMODINIT_FUNC initextractor(void)
-{
-  PyObject *m;
-
-  if( PyType_Ready(&ModuleListType) )
-    return;
-  if( PyType_Ready(&ModuleType) )
-    return;
-
-  m = Py_InitModule3("extractor",Extractor_Module_methods,"Extractor module.");
-  if (m == NULL)
-    return;
-
-  Py_INCREF(&ModuleListType);
-  Py_INCREF(&ModuleType);
-  PyModule_AddObject(m,"ModuleList",(PyObject*)&ModuleListType);
-  PyModule_AddObject(m,"Module",(PyObject*)&ModuleType);
-}

Deleted: Extractor-python/libextractor_python_setup.py
===================================================================
--- Extractor-python/libextractor_python_setup.py       2006-06-02 08:16:05 UTC 
(rev 2949)
+++ Extractor-python/libextractor_python_setup.py       2006-06-02 12:27:09 UTC 
(rev 2950)
@@ -1,17 +0,0 @@
-from distutils.core import Extension, setup
-import sys
-
-path=sys.argv[1]
-sys.argv = sys.argv[1:]
-
-cmod = Extension("extractor",["libextractor_python.c"],
-                 libraries=["extractor"],
-                 include_dirs=[path + "/include"],
-                 library_dirs=[path + "/lib"])
-
-setup(name="Extractor",
-      version="0.5.4",
-      ext_modules=[cmod],
-      author="Christian Grothoff, Heiko Wundram",
-      author_email="address@hidden")
-

Added: Extractor-python/setup.py
===================================================================
--- Extractor-python/setup.py   2006-06-02 08:16:05 UTC (rev 2949)
+++ Extractor-python/setup.py   2006-06-02 12:27:09 UTC (rev 2950)
@@ -0,0 +1,47 @@
+#!/bin/env/python
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+
+setup(
+    name = "Extractor",
+    version = "0.5",
+
+    py_modules = ['extractor'],
+    scripts = ['extract.py'],
+
+    #install_requires = ['ctypes >= 0.9'],
+
+    # metadata for upload to PyPI
+    author = "Bader Ladjemi, Christian Grothoff",
+    author_email = "address@hidden",
+    description = "Python bindings for GNU libextractor",
+    license = "GNU GPL",
+    keywords = "libextractor binding tag metadata",
+    url = "http://gnunet.org/libextractor/";,  
+
+    dependency_links=['http://starship.python.net/crew/theller/ctypes/',],
+
+    long_description="""libextractor is a simple library for keyword 
extraction.  libextractor
+does not support all formats but supports a simple plugging mechanism
+such that you can quickly add extractors for additional formats, even
+without recompiling libextractor. libextractor typically ships with a
+dozen helper-libraries that can be used to obtain keywords from common
+file-types.  
+
+libextractor is a part of the GNU project (http://www.gnu.org/).""",
+    
+    classifiers=['Development Status :: 3 - Alpha',
+                'Intended Audience :: Developers',
+                'License :: OSI Approved :: GNU General Public License (GPL)',
+                'Operating System :: OS Independent',
+                'Operating System :: MacOS :: MacOS X',
+                'Operating System :: Microsoft :: Windows',
+                'Operating System :: POSIX',
+                'Topic :: System :: Filesystems',
+                'Topic :: Text Processing :: Filters'],
+    
+    platforms=['windows', 'Linux', 'MacOS X', 'Solaris', 'FreeBSD'],
+    
+)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]