Remove print
from libmat, and use the logging
module instead
This should close #28
This commit is contained in:
parent
d5861e4653
commit
5a7c7f35f7
@ -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)
|
||||
|
@ -16,7 +16,7 @@ from gi.repository import Poppler, GLib
|
||||
|
||||
from . import abstract
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
|
||||
poppler_version = Poppler.get_version()
|
||||
if LooseVersion(poppler_version) < LooseVersion('0.46'): # pragma: no cover
|
||||
|
@ -3,6 +3,8 @@ from typing import Union, Tuple, Dict
|
||||
|
||||
from . import abstract
|
||||
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
|
||||
|
||||
class TorrentParser(abstract.AbstractParser):
|
||||
mimetypes = {'application/x-bittorrent', }
|
||||
|
@ -195,7 +195,6 @@ class TestDeepCleaning(unittest.TestCase):
|
||||
inside_p, _ = parser_factory.get_parser(complete_path)
|
||||
if inside_p is None:
|
||||
continue
|
||||
print('[+] %s is clean inside %s' %(complete_path, p.filename))
|
||||
self.assertEqual(inside_p.get_meta(), {})
|
||||
shutil.rmtree(tempdir)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user