Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
SIPS
EdosL0Util
Commits
d830e566
Commit
d830e566
authored
6 years ago
by
Greg Quinn
Browse files
Options
Downloads
Patches
Plain Diff
Use crio.ReadError for CR input exceptions
parent
8452a48f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
edosl0util/crio.py
+9
-2
9 additions, 2 deletions
edosl0util/crio.py
with
9 additions
and
2 deletions
edosl0util/crio.py
+
9
−
2
View file @
d830e566
...
...
@@ -6,6 +6,10 @@ import numbers
from
edosl0util.headers
import
BaseStruct
,
DaySegmentedTimecode
class
ReadError
(
ValueError
):
"""
Unable to parse construction record due to improper format
"""
def
read
(
cr_file
):
"""
Parse a PDS construction record from a file (*00.PDS)
"""
...
...
@@ -42,14 +46,17 @@ def read(cr_file):
rv
[
'
file_info
'
].
append
(
d
)
extra
=
f
.
read
()
if
extra
:
raise
Value
Error
(
'
{} bytes remain after reading CR
'
.
format
(
len
(
extra
)))
raise
Read
Error
(
'
{} bytes remain after reading CR
'
.
format
(
len
(
extra
)))
return
rv
def
read_into_dict
(
f
,
struct
,
data
):
data
.
update
(
read_struct
(
f
,
struct
))
def
read_struct
(
f
,
struct
):
rv
=
struct_to_dict
(
struct
.
from_buffer_copy
(
f
.
read
(
c
.
sizeof
(
struct
))))
buf
=
f
.
read
(
c
.
sizeof
(
struct
))
if
len
(
buf
)
<
c
.
sizeof
(
struct
):
raise
ReadError
(
'
Unexpected EOF reading CR
'
)
rv
=
struct_to_dict
(
struct
.
from_buffer_copy
(
buf
))
rv
=
{
k
:
v
for
k
,
v
in
rv
.
items
()
if
not
k
.
startswith
(
'
spare_
'
)}
# no spare fields
return
{
k
:
int
(
v
)
if
isinstance
(
v
,
numbers
.
Integral
)
else
v
for
k
,
v
in
rv
.
items
()}
# no longs
...
...
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