Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
aac73ac0
Commit
aac73ac0
authored
Sep 04, 2015
by
eric pellegrini
Browse files
Modified the API for better coherence among IInputData concrete classes
parent
67a74d04
Changes
5
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/InputData/EmptyData.py
View file @
aac73ac0
...
...
@@ -36,18 +36,4 @@ class EmptyData(IInputData):
type
=
"empty_data"
extension
=
None
count
=
0
def
__init__
(
self
,
filename
,
*
args
,
**
kwargs
):
IInputData
.
__init__
(
self
,
filename
,
*
args
,
**
kwargs
)
self
.
_data
=
None
if
filename
is
None
:
self
.
_filename
=
self
.
_basename
=
'empty_'
+
str
(
EmptyData
.
count
)
EmptyData
.
count
+=
1
else
:
self
.
_filename
=
self
.
_basename
=
filename
extension
=
None
\ No newline at end of file
MDANSE/Framework/InputData/IInputData.py
View file @
aac73ac0
...
...
@@ -47,37 +47,31 @@ class IInputData(object):
type
=
"input_data"
def
__init__
(
self
,
*
args
,
**
kw
args
):
def
__init__
(
self
,
name
,
*
args
):
'''
Builds an ``IInputData`` object.
'''
self
.
_name
=
name
self
.
_data
=
None
self
.
_filename
=
None
@
property
def
file
name
(
self
):
def
name
(
self
):
'''
Returns the
file
name associated with the input data.
Returns the name associated with the input data.
:return: the
file
name associated with the input data.
:return: the name associated with the input data.
:rtype: str
'''
return
self
.
_
file
name
return
self
.
_name
@
property
def
basename
(
self
):
'''
Returns the basename of the file associated with the input data.
def
shortname
(
self
):
:return: the basename of the file associated with the input data.
:rtype: str
'''
return
self
.
_basename
return
self
.
_name
@
property
def
data
(
self
):
'''
...
...
MDANSE/Framework/InputData/InputFileData.py
View file @
aac73ac0
...
...
@@ -39,17 +39,49 @@ class InputFileData(IInputData):
type
=
None
def
__init__
(
self
,
filename
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
filename
,
load
=
True
):
IInputData
.
__init__
(
self
,
filename
)
self
.
_basename
=
os
.
path
.
basename
(
filename
)
self
.
_dirname
=
os
.
path
.
dirname
(
filename
)
if
load
:
self
.
load
()
@
property
def
filename
(
self
):
'''
Returns the filename associated with the input data.
super
(
InputFileData
,
self
).
__init__
()
:return: the filename associated with the input data.
:rtype: str
'''
self
.
_filename
=
filename
self
.
_dirname
=
os
.
path
.
dirname
(
self
.
_filename
)
self
.
_basename
=
os
.
path
.
basename
(
self
.
_filename
)
self
.
_data
=
None
self
.
load
()
return
self
.
_name
@
property
def
shortname
(
self
):
'''
Returns the shortname of the file associated with the input data.
:return: the shortname of the file associated with the input data.
:rtype: str
'''
return
self
.
_basename
@
property
def
basename
(
self
):
'''
Returns the basename of the file associated with the input data.
:return: the basename of the file associated with the input data.
:rtype: str
'''
return
self
.
_basename
@
property
def
dirname
(
self
):
return
self
.
_dirname
...
...
MDANSE/Framework/InputData/MMTKTrajectoryInputData.py
View file @
aac73ac0
...
...
@@ -45,10 +45,10 @@ class MMTKTrajectoryInputData(InputFileData):
def
load
(
self
):
try
:
traj
=
MMTKTrajectory
(
None
,
self
.
_
file
name
,
"r"
)
traj
=
MMTKTrajectory
(
None
,
self
.
_name
,
"r"
)
except
IOError
:
raise
InputDataError
(
"The MMTK trajectory %r could not be loaded property."
%
self
.
_
file
name
)
raise
InputDataError
(
"The MMTK trajectory %r could not be loaded property."
%
self
.
_name
)
self
.
_data
=
traj
...
...
@@ -60,7 +60,7 @@ class MMTKTrajectoryInputData(InputFileData):
val
=
[]
val
.
append
(
"Path:"
)
val
.
append
(
"%s
\n
"
%
self
.
_
file
name
)
val
.
append
(
"%s
\n
"
%
self
.
_name
)
val
.
append
(
"Number of steps:"
)
val
.
append
(
"%s
\n
"
%
len
(
self
.
_data
))
val
.
append
(
"Universe:"
)
...
...
MDANSE/Framework/InputData/NetCDFInputData.py
View file @
aac73ac0
...
...
@@ -46,10 +46,10 @@ class NetCDFInputData(InputFileData):
def
load
(
self
):
try
:
self
.
_netcdf
=
NetCDFFile
(
self
.
_
file
name
,
"r"
)
self
.
_netcdf
=
NetCDFFile
(
self
.
_name
,
"r"
)
except
IOError
:
raise
InputDataError
(
"The data stored in %r filename could not be loaded property."
%
self
.
_
file
name
)
raise
InputDataError
(
"The data stored in %r filename could not be loaded property."
%
self
.
_name
)
else
:
self
.
_data
=
collections
.
OrderedDict
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment