Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
e3565a77
Commit
e3565a77
authored
Nov 11, 2015
by
eric pellegrini
Browse files
Added the python script selector in the GUI
parent
394c94eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Selectors/PythonScript.py
View file @
e3565a77
...
...
@@ -30,17 +30,32 @@ Created on Mar 27, 2015
:author: Eric C. Pellegrini
'''
import
glob
import
os
from
MDANSE
import
PREFERENCES
from
MDANSE.Framework.Selectors.ISelector
import
ISelector
class
PythonScript
(
ISelector
):
type
=
"python_script"
section
=
None
section
=
'miscellaneous'
def
__init__
(
self
,
universe
):
ISelector
.
__init__
(
self
,
universe
)
self
.
_choices
.
extend
(
glob
.
glob
(
os
.
path
.
join
(
PREFERENCES
[
'working_directory'
].
get_value
(),
'*.py'
)))
self
.
_rindexes
=
dict
([(
at
.
index
,
at
)
for
at
in
universe
.
atomList
()])
def
select
(
self
,
scripts
):
sel
=
set
()
if
'*'
in
scripts
:
scripts
=
self
.
_choices
[
1
:]
for
s
in
scripts
:
...
...
@@ -55,6 +70,6 @@ class PythonScript(ISelector):
if
not
namespace
.
has_key
(
"selection"
):
continue
sel
.
update
(
namespace
[
"selection"
])
sel
.
update
(
[
self
.
_rindexes
[
idx
]
for
idx
in
namespace
[
"selection"
]
]
)
return
sel
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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