Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenericIO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hacc
GenericIO
Commits
be75350b
Commit
be75350b
authored
6 years ago
by
Thomas Uram
Browse files
Options
Downloads
Patches
Plain Diff
Make genericio.py Python2/3-agnostic
parent
5e1952a8
No related branches found
Branches containing commit
Tags
20170925
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/genericio.py
+12
-3
12 additions, 3 deletions
python/genericio.py
with
12 additions
and
3 deletions
python/genericio.py
+
12
−
3
View file @
be75350b
...
@@ -37,9 +37,10 @@
...
@@ -37,9 +37,10 @@
#
#
# *****************************************************************************
# *****************************************************************************
from
__future__
import
print_function
import
numpy
as
np
import
numpy
as
np
import
ctypes
as
ct
import
ctypes
as
ct
import
os
import
os
,
sys
#Define where the library is and load it
#Define where the library is and load it
_path
=
os
.
path
.
dirname
(
__file__
)
_path
=
os
.
path
.
dirname
(
__file__
)
...
@@ -71,14 +72,17 @@ libpygio.inspect_gio.restype=None
...
@@ -71,14 +72,17 @@ libpygio.inspect_gio.restype=None
libpygio
.
inspect_gio
.
argtypes
=
[
ct
.
c_char_p
]
libpygio
.
inspect_gio
.
argtypes
=
[
ct
.
c_char_p
]
def
gio_read
(
file_name
,
var_name
):
def
gio_read
(
file_name
,
var_name
):
if
sys
.
version_info
[
0
]
==
3
:
file_name
=
bytes
(
file_name
,
'
ascii
'
)
var_name
=
bytes
(
var_name
,
'
ascii
'
)
var_size
=
libpygio
.
get_elem_num
(
file_name
)
var_size
=
libpygio
.
get_elem_num
(
file_name
)
var_type
=
libpygio
.
get_variable_type
(
file_name
,
var_name
)
var_type
=
libpygio
.
get_variable_type
(
file_name
,
var_name
)
field_count
=
libpygio
.
get_variable_field_count
(
file_name
,
var_name
)
field_count
=
libpygio
.
get_variable_field_count
(
file_name
,
var_name
)
if
(
var_type
==
10
):
if
(
var_type
==
10
):
print
"
Variable not found
"
print
(
"
Variable not found
"
)
return
return
elif
(
var_type
==
9
):
elif
(
var_type
==
9
):
print
"
variable type not known (not int32/int64/float/double)
"
print
(
"
variable type not known (not int32/int64/float/double)
"
)
elif
(
var_type
==
0
):
elif
(
var_type
==
0
):
#float
#float
result
=
np
.
ndarray
((
var_size
,
field_count
),
dtype
=
np
.
float32
)
result
=
np
.
ndarray
((
var_size
,
field_count
),
dtype
=
np
.
float32
)
...
@@ -101,10 +105,15 @@ def gio_read(file_name,var_name):
...
@@ -101,10 +105,15 @@ def gio_read(file_name,var_name):
return
result
return
result
def
gio_has_variable
(
file_name
,
var_name
):
def
gio_has_variable
(
file_name
,
var_name
):
if
sys
.
version_info
[
0
]
==
3
:
file_name
=
bytes
(
file_name
,
'
ascii
'
)
var_name
=
bytes
(
var_name
,
'
ascii
'
)
var_size
=
libpygio
.
get_elem_num
(
file_name
)
var_size
=
libpygio
.
get_elem_num
(
file_name
)
var_type
=
libpygio
.
get_variable_type
(
file_name
,
var_name
)
var_type
=
libpygio
.
get_variable_type
(
file_name
,
var_name
)
return
var_type
!=
10
return
var_type
!=
10
def
gio_inspect
(
file_name
):
def
gio_inspect
(
file_name
):
if
sys
.
version_info
[
0
]
==
3
:
file_name
=
bytes
(
file_name
,
'
ascii
'
)
libpygio
.
inspect_gio
(
file_name
)
libpygio
.
inspect_gio
(
file_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