Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mat2
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
18
Issues
18
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jvoisin
mat2
Commits
d76a6cbb
Commit
d76a6cbb
authored
Aug 01, 2019
by
jvoisin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some arguments of mat2 are mutually exclusive
parent
49e0c43a
Pipeline
#26569
passed with stages
in 13 minutes and 54 seconds
Changes
2
Pipelines
5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
16 deletions
+25
-16
mat2
mat2
+19
-12
tests/test_climat2.py
tests/test_climat2.py
+6
-4
No files found.
mat2
View file @
d76a6cbb
...
...
@@ -46,13 +46,7 @@ def __check_file(filename: str, mode: int = os.R_OK) -> bool:
def
create_arg_parser
()
->
argparse
.
ArgumentParser
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Metadata anonymisation toolkit 2'
)
parser
.
add_argument
(
'files'
,
nargs
=
'*'
,
help
=
'the files to process'
)
parser
.
add_argument
(
'-v'
,
'--version'
,
action
=
'version'
,
version
=
'MAT2
%
s'
%
__version__
)
parser
.
add_argument
(
'-l'
,
'--list'
,
action
=
'store_true'
,
help
=
'list all supported fileformats'
)
parser
.
add_argument
(
'--check-dependencies'
,
action
=
'store_true'
,
help
=
'check if MAT2 has all the dependencies it needs'
)
parser
.
add_argument
(
'-V'
,
'--verbose'
,
action
=
'store_true'
,
help
=
'show more verbose status information'
)
parser
.
add_argument
(
'--unknown-members'
,
metavar
=
'policy'
,
default
=
'abort'
,
...
...
@@ -60,12 +54,25 @@ def create_arg_parser() -> argparse.ArgumentParser:
'files (policy should be one of:
%
s) [Default: abort]'
%
', '
.
join
(
p
.
value
for
p
in
UnknownMemberPolicy
))
excl_group
=
parser
.
add_mutually_exclusive_group
()
excl_group
.
add_argument
(
'files'
,
nargs
=
'*'
,
help
=
'the files to process'
,
default
=
[])
excl_group
.
add_argument
(
'-v'
,
'--version'
,
action
=
'version'
,
version
=
'MAT2
%
s'
%
__version__
)
excl_group
.
add_argument
(
'-l'
,
'--list'
,
action
=
'store_true'
,
default
=
False
,
help
=
'list all supported fileformats'
)
excl_group
.
add_argument
(
'--check-dependencies'
,
action
=
'store_true'
,
default
=
False
,
help
=
'check if MAT2 has all the dependencies it '
'needs'
)
info
=
parser
.
add_mutually_exclusive_group
()
info
.
add_argument
(
'-s'
,
'--show'
,
action
=
'store_true'
,
help
=
'list harmful metadata detectable by MAT2 without removing them'
)
info
.
add_argument
(
'-L'
,
'--lightweight'
,
action
=
'store_true'
,
excl_group
=
parser
.
add_mutually_exclusive_group
()
excl_group
.
add_argument
(
'-L'
,
'--lightweight'
,
action
=
'store_true'
,
help
=
'remove SOME metadata'
)
excl_group
.
add_argument
(
'-s'
,
'--show'
,
action
=
'store_true'
,
help
=
'list harmful metadata detectable by MAT2 '
'without removing them'
)
return
parser
...
...
tests/test_climat2.py
View file @
d76a6cbb
...
...
@@ -20,16 +20,18 @@ class TestHelp(unittest.TestCase):
def
test_help
(
self
):
proc
=
subprocess
.
Popen
(
mat2_binary
+
[
'--help'
],
stdout
=
subprocess
.
PIPE
)
stdout
,
_
=
proc
.
communicate
()
self
.
assertIn
(
b
'
usage: mat2 [-h] [-v] [-l] [--check-dependencies] [-V
]'
,
self
.
assertIn
(
b
'
mat2 [-h] [-V] [--unknown-members policy] [-v] [-l
]'
,
stdout
)
self
.
assertIn
(
b
'[--unknown-members policy] [-s | -L]'
,
stdout
)
self
.
assertIn
(
b
'[--check-dependencies] [-L | -s]'
,
stdout
)
self
.
assertIn
(
b
'[files [files ...]]'
,
stdout
)
def
test_no_arg
(
self
):
proc
=
subprocess
.
Popen
(
mat2_binary
,
stdout
=
subprocess
.
PIPE
)
stdout
,
_
=
proc
.
communicate
()
self
.
assertIn
(
b
'
usage: mat2 [-h] [-v] [-l] [--check-dependencies] [-V
]'
,
self
.
assertIn
(
b
'
mat2 [-h] [-V] [--unknown-members policy] [-v] [-l
]'
,
stdout
)
self
.
assertIn
(
b
'[--unknown-members policy] [-s | -L]'
,
stdout
)
self
.
assertIn
(
b
'[--check-dependencies] [-L | -s]'
,
stdout
)
self
.
assertIn
(
b
'[files [files ...]]'
,
stdout
)
class
TestVersion
(
unittest
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment