Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProMod3
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
schwede
ProMod3
Commits
265862fc
Commit
265862fc
authored
10 years ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Extended error message
parent
9a4d5029
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/pymod/core/argcheck.py
+13
-3
13 additions, 3 deletions
core/pymod/core/argcheck.py
core/tests/test_argcheck.py
+6
-3
6 additions, 3 deletions
core/tests/test_argcheck.py
extras/pre-commit
+3
-3
3 additions, 3 deletions
extras/pre-commit
with
22 additions
and
9 deletions
core/pymod/core/argcheck.py
+
13
−
3
View file @
265862fc
...
@@ -68,10 +68,16 @@ def FileExtension(prefix, exit_status, file, extensions, gz=False):
...
@@ -68,10 +68,16 @@ def FileExtension(prefix, exit_status, file, extensions, gz=False):
is_gz
=
True
is_gz
=
True
filename
,
fileext
=
os
.
path
.
splitext
(
filename
)
filename
,
fileext
=
os
.
path
.
splitext
(
filename
)
if
not
gz
:
if
not
gz
:
sys
.
stderr
.
write
(
'
%s file extension not supported: %s
\n
'
%
(
prefix
,
file
))
extension_string
=
'
,
'
.
join
(
extensions
)
sys
.
stderr
.
write
(
'
%s file extension not supported: %s.
'
%
(
prefix
,
file
)
+
'
Allowed extensions are: %s
\n
'
%
extension_string
)
sys
.
exit
(
exit_status
)
sys
.
exit
(
exit_status
)
if
fileext
==
''
:
if
fileext
==
''
:
sys
.
stderr
.
write
(
'
%s file extension not supported: %s
\n
'
%
(
prefix
,
file
))
extension_string
=
'
,
'
.
join
(
extensions
)
if
gz
:
extension_string
+=
'
,
'
+
'
.gz,
'
.
join
(
extensions
)
+
'
.gz
'
sys
.
stderr
.
write
(
'
%s file extension not supported: %s.
'
%
(
prefix
,
file
)
+
'
Allowed extensions are: %s
\n
'
%
extension_string
)
sys
.
exit
(
exit_status
)
sys
.
exit
(
exit_status
)
fileext
=
fileext
[
1
:].
lower
()
fileext
=
fileext
[
1
:].
lower
()
for
ext
in
extensions
:
for
ext
in
extensions
:
...
@@ -80,7 +86,11 @@ def FileExtension(prefix, exit_status, file, extensions, gz=False):
...
@@ -80,7 +86,11 @@ def FileExtension(prefix, exit_status, file, extensions, gz=False):
return
os
.
path
.
basename
(
filename
),
fileext
,
is_gz
return
os
.
path
.
basename
(
filename
),
fileext
,
is_gz
else
:
else
:
return
os
.
path
.
basename
(
filename
),
fileext
return
os
.
path
.
basename
(
filename
),
fileext
sys
.
stderr
.
write
(
'
%s file extension not supported: %s
\n
'
%
(
prefix
,
file
))
extension_string
=
'
,
'
.
join
(
extensions
)
if
gz
:
extension_string
+=
'
,
'
+
'
.gz,
'
.
join
(
extensions
)
+
'
.gz
'
sys
.
stderr
.
write
(
'
%s file extension not supported: %s.
'
%
(
prefix
,
file
)
+
'
Allowed extensions are: %s
\n
'
%
extension_string
)
sys
.
exit
(
exit_status
)
sys
.
exit
(
exit_status
)
__all__
=
(
__all__
=
(
...
...
This diff is collapsed.
Click to expand it.
core/tests/test_argcheck.py
+
6
−
3
View file @
265862fc
...
@@ -66,7 +66,8 @@ class ArgcheckTests(unittest.TestCase):
...
@@ -66,7 +66,8 @@ class ArgcheckTests(unittest.TestCase):
'
noextension
'
,
[
'
py
'
])
'
noextension
'
,
[
'
py
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
27
)
self
.
assertEqual
(
ec
.
exception
.
code
,
27
)
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
'
Argcheck test file extension not supported: noextension
'
)
'
Argcheck test file extension not supported: noextension.
'
+
'
Allowed extensions are: py
'
)
def
testFileExtensionFalseGZ
(
self
):
def
testFileExtensionFalseGZ
(
self
):
# make sure we fail outside gz mode if a gz extension is provided
# make sure we fail outside gz mode if a gz extension is provided
...
@@ -76,7 +77,8 @@ class ArgcheckTests(unittest.TestCase):
...
@@ -76,7 +77,8 @@ class ArgcheckTests(unittest.TestCase):
'
wrongname.gz
'
,
[
'
py
'
])
'
wrongname.gz
'
,
[
'
py
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
26
)
self
.
assertEqual
(
ec
.
exception
.
code
,
26
)
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
'
Argcheck test file extension not supported: wrongname.gz
'
)
'
Argcheck test file extension not supported: wrongname.gz.
'
+
'
Allowed extensions are: py
'
)
def
testFileExtensionFalse
(
self
):
def
testFileExtensionFalse
(
self
):
# check file name with unknown extension
# check file name with unknown extension
...
@@ -86,7 +88,8 @@ class ArgcheckTests(unittest.TestCase):
...
@@ -86,7 +88,8 @@ class ArgcheckTests(unittest.TestCase):
'
unknown.ext
'
,
[
'
py
'
])
'
unknown.ext
'
,
[
'
py
'
])
self
.
assertEqual
(
ec
.
exception
.
code
,
25
)
self
.
assertEqual
(
ec
.
exception
.
code
,
25
)
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
self
.
assertEqual
(
err
.
getvalue
().
strip
(),
'
Argcheck test file extension not supported: unknown.ext
'
)
'
Argcheck test file extension not supported: unknown.ext.
'
+
'
Allowed extensions are: py
'
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
from
ost
import
testutils
from
ost
import
testutils
...
...
This diff is collapsed.
Click to expand it.
extras/pre-commit
+
3
−
3
View file @
265862fc
...
@@ -94,14 +94,14 @@ def CheckWithespaces():
...
@@ -94,14 +94,14 @@ def CheckWithespaces():
FailMsg
(
"
Found trailing whitespace(s):
\n
%s
"
%
'
\n
'
.
join
(
output
),
8
)
FailMsg
(
"
Found trailing whitespace(s):
\n
%s
"
%
'
\n
'
.
join
(
output
),
8
)
def
GetFileType
(
filepath
):
def
GetFileType
(
filepath
):
if
filepath
.
endswith
(
'
.py
'
):
return
"
python
"
try
:
try
:
fo
=
subprocess
.
check_output
([
'
file
'
,
filepath
],
shell
=
False
)
fo
=
subprocess
.
check_output
([
'
file
'
,
filepath
],
shell
=
False
)
except
Exception
,
e
:
except
Exception
,
e
:
FailMsg
(
"
Failed to run
'
file %s
'
:
'
%s
'"
%
(
filepath
,
str
(
e
)),
11
)
FailMsg
(
"
Failed to run
'
file %s
'
:
'
%s
'"
%
(
filepath
,
str
(
e
)),
11
)
fo
=
fo
.
strip
()
fo
=
fo
.
strip
()
if
fo
.
endswith
(
'
.py
'
):
if
fo
==
"
%s: a python script text executable
"
%
filepath
:
return
"
python
"
elif
fo
==
"
%s: a python script text executable
"
%
filepath
:
return
"
python
"
return
"
python
"
elif
fo
==
"
%s: a ost script text executable
"
%
filepath
:
elif
fo
==
"
%s: a ost script text executable
"
%
filepath
:
return
"
python
"
return
"
python
"
...
...
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