Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102082705
gswapbytes
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 16, 22:37
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Feb 18, 22:37 (2 d)
Engine
blob
Format
Raw Data
Handle
24277914
Attached To
rGTOOLS Gtools
gswapbytes
View Options
#!/usr/bin/env python
'''
Convert bigendian into little endian
default file extension = .orb
Yves Revaz
mar mai 23 10:29:12 CEST 2006
'''
from
Nbody
import
*
try
:
from
optparse
import
OptionParser
except
ImportError
:
from
optik
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog file_in file_out"
parser
=
OptionParser
(
usage
=
usage
)
parser
.
add_option
(
"-t"
,
action
=
"store"
,
dest
=
"ftype"
,
type
=
"string"
,
default
=
None
,
help
=
"type of the file"
,
metavar
=
" TYPE"
)
parser
.
add_option
(
"-b"
,
action
=
"store"
,
dest
=
"byteorder"
,
type
=
"string"
,
default
=
'little'
,
help
=
"byte order 'little' or 'big'"
,
metavar
=
" TYPE"
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
!=
2
:
print
"you must specify two file names"
sys
.
exit
(
0
)
return
args
[
0
],
args
[
1
],
options
##########################################################
#
# MAIN
#
#########################################################
# get options
file1
,
file2
,
options
=
parse_options
()
ftype
=
options
.
ftype
byteorder
=
options
.
byteorder
nb
=
Nbody
(
file1
,
ftype
=
ftype
,
byteorder
=
byteorder
)
if
nb
.
byteorder
==
'big'
:
nb
.
byteorder
=
'little'
elif
nb
.
byteorder
==
'little'
:
nb
.
byteorder
=
'big'
else
:
print
"unknown byteorder type"
print
"must be either 'little' or 'big' "
print
"transfroming into
%s
endian."
%
(
nb
.
byteorder
)
nb
.
rename
(
file2
)
nb
.
write
()
Event Timeline
Log In to Comment