Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lvcnrpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
waveforms
lvcnrpy
Commits
d3f31d8a
Commit
d3f31d8a
authored
8 years ago
by
Edward Fauchon-Jones
Browse files
Options
Downloads
Patches
Plain Diff
Improve reporting of bad fields by `lvcnrcheck`
parent
03bf8c96
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/lvcnrcheck
+29
-23
29 additions, 23 deletions
bin/lvcnrcheck
with
29 additions
and
23 deletions
bin/lvcnrcheck
+
29
−
23
View file @
d3f31d8a
...
...
@@ -34,25 +34,27 @@ parser.add_argument(
help
=
'
format level to use
'
,
type
=
int
,
choices
=
[
1
,
2
,
3
],
default
=
1
)
args
=
parser
.
parse_args
()
# Define possible attribute output templates templates
VALID
=
u
'
- [{0:}={1:}] {{0:}} ({{1:}})
'
WRONGTYPE
=
(
u
'
- [{0:}WRONG TYPE{1:}] {{0:}} ({{1:}})
'
u
'
(Type must be {{2:}})
'
)
WRONGVALUE
=
(
u
'
- [{0:}INVALID VALUE{1:}] {{0:}} ({{1:}})
'
u
'
({{2:}})
'
)
MISSING
=
u
'
- [{0:}MISSING{1:}] {{0:}} (undefined)
'
# Define possible attribute output templates
VALID_COL
=
u
'
- [{0:}={1:}] {{0:}} ({{1:}})
'
.
format
(
Fore
.
GREEN
,
Style
.
RESET_ALL
)
WRONGTYPE_COL
=
u
'
- [{0:}TYPE{1:}] {{0:}} ({{1:}})
'
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
WRONGVALUE_COL
=
u
'
- [{0:}VALUE{1:}] {{0:}} ({{1:}})
'
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
MISSING_COL
=
u
'
- [{0:}MISSING{1:}] {{0:}} (undefined)
'
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
VALID_COL
=
VALID
.
format
(
Fore
.
GREEN
,
Style
.
RESET_ALL
)
WRONGTYPE_COL
=
WRONGTYPE
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
WRONGVALUE_COL
=
WRONGVALUE
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
MISSING_COL
=
MISSING
.
format
(
Fore
.
RED
,
Style
.
RESET_ALL
)
# Define possible attribute output templates without color
VALID_NOCOL
=
u
'
- [=] {0:} ({1:})
'
WRONGTYPE_NOCOL
=
u
'
- [TYPE] {0:} ({1:})
'
WRONGVALUE_NOCOL
=
u
'
- [VALUE] {0:} ({1:})
'
MISSING_NOCOL
=
u
'
- [
MISSING
] {0:} (undefined)
'
VALID_NOCOL
=
VALID
.
format
(
''
,
''
)
WRONGTYPE_NOCOL
=
WRONGTYPE
.
format
(
''
,
''
)
WRONGVALUE_NOCOL
=
WRONGVALUE
.
format
(
''
,
''
)
MISSING_NOCOL
=
MISSING
.
format
(
''
,
''
)
if
args
.
col
:
VALID
=
VALID_COL
...
...
@@ -66,17 +68,19 @@ else:
MISSING
=
MISSING_NOCOL
def
checkAttr
(
sim
,
attr
,
type
,
values
=
None
):
def
checkAttr
(
sim
,
attr
,
d
type
,
values
=
None
):
value
=
sim
.
att
(
attr
)
if
value
is
not
None
:
if
isinstance
(
value
,
type
):
if
isinstance
(
value
,
d
type
):
if
values
is
None
or
value
in
values
:
print
VALID
.
format
(
attr
,
value
)
else
:
print
WRONGVALUE
.
format
(
attr
,
value
)
strValues
=
[
"
{0:}
"
.
format
(
v
)
for
v
in
values
]
print
WRONGVALUE
.
format
(
attr
,
value
,
"
Value must be one of
"
+
"
,
"
.
join
(
strValues
))
else
:
print
WRONGTYPE
.
format
(
attr
,
value
)
print
WRONGTYPE
.
format
(
attr
,
value
,
dtype
)
else
:
print
MISSING
.
format
(
attr
)
...
...
@@ -91,11 +95,13 @@ def checkDataset(sim, name, quantities):
if
value
:
if
isinstance
(
value
,
h5
.
Dataset
):
if
len
(
value
[
0
])
==
quantities
:
print
VALID
.
format
(
name
,
'
HDF5-dataset
'
)
print
VALID
.
format
(
name
,
len
(
value
[
0
])
)
else
:
print
WRONGVALUE
.
format
(
name
,
len
(
value
[
0
]))
print
WRONGVALUE
.
format
(
name
,
len
(
value
[
0
]),
"
Dataset must contain {0:d} columns
"
.
format
(
quantities
))
else
:
print
WRONGTYPE
.
format
(
name
,
type
(
value
))
print
WRONGTYPE
.
format
(
name
,
type
(
value
)
,
h5
.
Dataset
)
else
:
print
MISSING
.
format
(
name
)
...
...
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