From 5a7c7f35f7d526a8c0ed49da12e4efc5e9dd6582 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 10 Jul 2018 21:30:38 +0200 Subject: Remove `print` from libmat, and use the `logging` module instead This should close #28 --- libmat2/office.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libmat2/office.py') diff --git a/libmat2/office.py b/libmat2/office.py index b3fde7e..1ececdf 100644 --- a/libmat2/office.py +++ b/libmat2/office.py @@ -4,7 +4,9 @@ import shutil import tempfile import datetime import zipfile +import logging from typing import Dict, Set, Pattern + try: # protect against DoS from defusedxml import ElementTree as ET # type: ignore except ImportError: @@ -17,6 +19,8 @@ from . import abstract, parser_factory assert Set assert Pattern +logging.basicConfig(level=logging.ERROR) + def _parse_xml(full_path: str): """ This function parse XML with namespace support. """ def parse_map(f): # etree support for ns is a bit rough @@ -98,7 +102,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): if self._specific_cleanup(full_path) is False: shutil.rmtree(temp_folder) os.remove(self.output_filename) - print("Something went wrong during deep cleaning of %s" % item.filename) + logging.info("Something went wrong during deep cleaning of %s", item.filename) return False if item.filename in self.files_to_keep: @@ -112,7 +116,7 @@ class ArchiveBasedAbstractParser(abstract.AbstractParser): if not tmp_parser: shutil.rmtree(temp_folder) os.remove(self.output_filename) - print("%s's format (%s) isn't supported" % (item.filename, mtype)) + logging.info("%s's format (%s) isn't supported", item.filename, mtype) return False tmp_parser.remove_all() os.rename(tmp_parser.output_filename, full_path) -- cgit v1.3