Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tails
mat2
Commits
5a7c7f35
Commit
5a7c7f35
authored
6 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Remove `print` from libmat, and use the `logging` module instead
This should close #28
parent
d5861e46
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
libmat2/office.py
+6
-2
6 additions, 2 deletions
libmat2/office.py
libmat2/pdf.py
+1
-1
1 addition, 1 deletion
libmat2/pdf.py
libmat2/torrent.py
+2
-0
2 additions, 0 deletions
libmat2/torrent.py
tests/test_libmat2.py
+0
-1
0 additions, 1 deletion
tests/test_libmat2.py
with
9 additions
and
4 deletions
libmat2/office.py
+
6
−
2
View file @
5a7c7f35
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
libmat2/pdf.py
+
1
−
1
View file @
5a7c7f35
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
libmat2/torrent.py
+
2
−
0
View file @
5a7c7f35
...
...
@@ -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
'
,
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_libmat2.py
+
0
−
1
View file @
5a7c7f35
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment