Commit 226d504b authored by eric pellegrini's avatar eric pellegrini

updated the job template writing

small refactoring of the save job template command line option
removed unused imports
removed white spaces
parent 7cb5b317
......@@ -472,17 +472,17 @@ class IJob(Configurable):
f.write(
'''import collections
from MDANSE import REGISTRY
from MDANSE.Framework.Jobs.IJob import IJob
class %s(IJob):
class %(classname)s(IJob):
"""
You should enter the description of your job here ...
"""
type = %r
# You should enter the label under which your job will be referenced from the gui.
label = %r
# You should enter the label under which your job will be viewed from the gui.
label = %(label)r
# You should enter the category under which your job will be references.
category = ('My jobs',)
......@@ -532,7 +532,9 @@ class %s(IJob):
# The trajectory is closed
self.configuration['trajectory']['instance'].close()
''' % (classname,shortname,classname))
REGISTRY[%(shortname)r] = %(classname)s
''' % {'classname':classname,'label':'label of the class','shortname':shortname})
except IOError:
return None
......
......@@ -8,12 +8,3 @@ from MDANSE.Framework.OutputVariables import *
from MDANSE.Framework.Projectors import *
from MDANSE.Framework.QVectors import *
from MDANSE.Framework.Selectors import *
import os
from MDANSE import PLATFORM,REGISTRY
macrosDirectories = sorted([x[0] for x in os.walk(PLATFORM.macros_directory())][0:])
for d in macrosDirectories:
REGISTRY.update(d)
......@@ -52,3 +52,8 @@ from MMTK import Database
# The default database is still the MMTK one
Database.path.append(os.path.join(PLATFORM.package_directory(), 'Data'))
macrosDirectories = sorted([x[0] for x in os.walk(PLATFORM.macros_directory())][0:])
for d in macrosDirectories:
REGISTRY.update(d)
......@@ -233,7 +233,7 @@ class CommandLineParser(optparse.OptionParser):
if len(parser.rargs) == 0:
print "Registered interfaces:"
for interfaceName in REGISTRY.get_interfaces():
for interfaceName in REGISTRY.interfaces:
print "\t- %s" % interfaceName
elif len(parser.rargs) == 1:
val = parser.rargs[0]
......@@ -333,9 +333,10 @@ class CommandLineParser(optparse.OptionParser):
from MDANSE.Framework.Jobs.IJob import IJob
if nargs != 2:
raise CommandLineParserError("Invalid number of arguments for %r option" % opt_str)
print "Two arguments required resp. the name and the shortname of the class to be templated"
return
shortname,classname = parser.rargs
classname,shortname = parser.rargs
try:
IJob.save_template(shortname,classname)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment