diff options
author | Nils Gillmann <gillmann@infotropique.org> | 2018-06-17 14:20:39 +0000 |
---|---|---|
committer | Nils Gillmann <gillmann@infotropique.org> | 2018-06-17 14:20:39 +0000 |
commit | a4763e6617dc5420939f94c0183030b94c5b010a (patch) | |
tree | eae0aa298f355b2d85d9856a3da67f6b3eae14c1 | |
parent | b0fffb70d102642fedcfa53e85e2a14ca743472a (diff) | |
download | libextractor-python-a4763e6617dc5420939f94c0183030b94c5b010a.tar.gz libextractor-python-a4763e6617dc5420939f94c0183030b94c5b010a.zip |
attempt
Signed-off-by: Nils Gillmann <gillmann@infotropique.org>
-rw-r--r-- | libextractor/examples/__main__.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libextractor/examples/__main__.py b/libextractor/examples/__main__.py index 91bab1d..d28b6e1 100644 --- a/libextractor/examples/__main__.py +++ b/libextractor/examples/__main__.py | |||
@@ -35,19 +35,35 @@ faulthandler.enable() | |||
35 | 35 | ||
36 | xtract = extractor.Extractor() | 36 | xtract = extractor.Extractor() |
37 | 37 | ||
38 | logger = logging.getLogger() | ||
39 | logger.setLevel(logging.DEBUG) | ||
40 | |||
41 | formatter = logging.Formater('%(asctime)s %(levelname)s - %(message)s') | ||
42 | |||
43 | fh = logging.FileHandler('log.txt') | ||
44 | fh.setLevel(logging.DEBUG) | ||
45 | fh.setFormatter(formatter) | ||
46 | logger.addHandler(fh) | ||
47 | |||
48 | ch = logging.StreamHandler() | ||
49 | ch.setLevel(logging.DEBUG) | ||
50 | ch.setFormatter(formatter) | ||
51 | logger.addHandler(ch) | ||
52 | |||
38 | def print_k(xt, plugin, type, format, mime, data, datalen): | 53 | def print_k(xt, plugin, type, format, mime, data, datalen): |
39 | mstr = cast(data, c_char_p) | 54 | mstr = cast(data, c_char_p) |
40 | # FIXME: this ignores 'datalen', not that great... | 55 | # FIXME: this ignores 'datalen', not that great... |
41 | # (in general, depending on the mime type and format, only | 56 | # (in general, depending on the mime type and format, only |
42 | # the first 'datalen' bytes in 'data' should be used). | 57 | # the first 'datalen' bytes in 'data' should be used). |
43 | if (format == extractor.EXTRACTOR_METAFORMAT_UTF8): | 58 | if (format == extractor.EXTRACTOR_METAFORMAT_UTF8): |
44 | print("%s - %s" % (xtract.keywordTypes()[type], mstr.value)) | 59 | # print("%s - %s" % (xtract.keywordTypes()[type], mstr.value)) |
60 | logger.debug("%s - %s" % (xtract.keywordTypes()[type], mstr.value)) | ||
45 | return 0 | 61 | return 0 |
46 | 62 | ||
47 | def main(): | 63 | def main(): |
48 | # stuff | 64 | # stuff |
49 | for arg in sys.argv[1:]: | 65 | for arg in sys.argv[1:]: |
50 | print("Keywords from %s:" % arg) | 66 | logger.debug("Keywords from %s:" % arg) |
51 | xtract.extract(print_k, None, arg) | 67 | xtract.extract(print_k, None, arg) |
52 | 68 | ||
53 | if __name__ == "__main__": | 69 | if __name__ == "__main__": |