gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libextractor-python] branch master updated: create libextr


From: gnunet
Subject: [GNUnet-SVN] [libextractor-python] branch master updated: create libextractor.examples.__main__ as entry_point
Date: Sun, 17 Jun 2018 15:01:04 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository libextractor-python.

The following commit(s) were added to refs/heads/master by this push:
     new cb07309  create libextractor.examples.__main__ as entry_point
cb07309 is described below

commit cb07309c378dbd11932e518b9ddf03f219f2f38a
Author: Nils Gillmann <address@hidden>
AuthorDate: Sun Jun 17 13:01:35 2018 +0000

    create libextractor.examples.__main__ as entry_point
    
    Signed-off-by: Nils Gillmann <address@hidden>
---
 libextractor/examples/__main__.py | 51 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/libextractor/examples/__main__.py 
b/libextractor/examples/__main__.py
new file mode 100644
index 0000000..9f67f1c
--- /dev/null
+++ b/libextractor/examples/__main__.py
@@ -0,0 +1,51 @@
+"""
+extract.py
+
+     This file is part of libextractor.
+     (C) 2002, 2003, 2004, 2005 Vidyut Samanta and Christian Grothoff
+     (C) 2017, 2018 Nils Gillmann <address@hidden>
+
+     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 3, 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.
+
+Little demo how to use the libextractor Python binding.
+
+"""
+from __future__ import print_function
+from libextractor import extractor
+import sys
+from ctypes import *
+import struct
+
+
+xtract = extractor.Extractor()
+
+def print_k(xt, plugin, type, format, mime, data, datalen):
+    mstr = cast(data, c_char_p)
+    # FIXME: this ignores 'datalen', not that great...
+    # (in general, depending on the mime type and format, only
+    # the first 'datalen' bytes in 'data' should be used).
+    if (format == extractor.EXTRACTOR_METAFORMAT_UTF8):
+        print("%s - %s" % (xtract.keywordTypes()[type], mstr.value))
+    return 0
+
+def main():
+    # stuff
+    for arg in sys.argv[1:]:
+        print("Keywords from %s:" % arg)
+        xtract.extract(print_k, None, arg)
+
+if __name__ == "__main__":
+    main()

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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