def __init__(self, filename): cls = TestableComponent # If we recieve a filename like 'iaf', that doesn't # end in '.py', then lets prepend the component directory # and append .py if not filename.endswith('.py'): compdir = LocationMgr.getComponentDir() filename = os.path.join(compdir, '%s.py' % filename) self.filename = filename self.mod = load_py_module(filename) # Get the component functor: if not cls.functor_name in self.mod.__dict__.keys(): err = """Can't load TestableComponnet from %s""" % self.filename err += """Can't find required method: %s""" % cls.functor_name raise NineMLRuntimeError(err) self.component_functor = self.mod.__dict__[cls.functor_name] # Check the functor will actually return us an object: try: c = self.component_functor() except Exception, e: print e raise
def __init__(self, **kw): self.debug = kw.get("debug", 0) self.names = {} try: modname = os.path.split(os.path.splitext(__file__)[0])[1] + "_" + self.__class__.__name__ except: modname = "parser" + "_" + self.__class__.__name__ # self.debugfile = modname + ".dbg" # self.tabmodule = modname + "_" + "parsetab" self.debugfile = LocationMgr.getTmpDir() + modname + ".dbg" self.tabmodule = LocationMgr.getTmpDir() + modname + "_" + "parsetab" # print self.debugfile, self.tabmodule # Build the lexer and parser lex.lex(module=self, debug=self.debug) yacc.yacc(module=self, debug=self.debug, debugfile=self.debugfile, tabmodule=self.tabmodule)
def list_available(cls): """Returns a list of strings, of the available components""" compdir = LocationMgr.getComponentDir() comps = [] for fname in os.listdir(compdir): fname, ext = os.path.splitext(fname) if not ext == '.py': continue if fname == '__init__': continue comps.append(fname) return comps
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """ #import nineml.abstraction_layer as nineml #import os from nineml.abstraction_layer.testing_utils import TestableComponent from nineml.abstraction_layer.flattening import flatten #from nineml.abstraction_layer.flattening import ComponentFlattener from nineml.abstraction_layer.component_modifiers import ComponentModifier from nineml.utility import LocationMgr #from nineml.abstraction_layer.visitors import RenameSymbol LocationMgr.StdAppendToPath() comp_data = TestableComponent('nestequivalent_iaf_cond_exp') # Build the component: component = comp_data() component = flatten(component) component.backsub_all() ComponentModifier.close_all_reduce_ports(component=component) # Copy the descriptive strings: component.short_description = comp_data.metadata.short_description component.long_description = comp_data.metadata.long_description # Get the initial regime. If this component comes from an flattened component, # then we should look up the new regime from the locations in the old
from nineml.utility import LocationMgr from os.path import join as Join from nineml.abstraction_layer.xmlns import * import nineml.abstraction_layer as al import nineml.abstraction_layer.readers as readers import nineml.abstraction_layer.writers as writers import pyNN.neuron.nineml as pyNNml from nineml.abstraction_layer.flattening import ComponentFlattener #LocationMgr.StdAppendToPath() sample_xml_dir = Join(LocationMgr.getCatalogDir(), "sample_xml_files") tenml_dir = Join(LocationMgr.getCatalogDir(), "sample_xml_files/10ml/") def t1(): print 'Loading First XML File' print '----------------------' component = readers.XMLReader.read_component( Join(sample_xml_dir, 'PostTF_izhikevich.xml')) writers.XMLWriter.write(component, '/tmp/nineml_toxml1.xml') def t2(): print 'Loading Second XML File (IAF-Component' print '--------------------------------------' component = readers.XMLReader.read_component( Join(tenml_dir, 'comp_iaf.9ml'))
from nineml.utility import LocationMgr from os.path import join as Join from nineml.abstraction_layer.xmlns import * import nineml.abstraction_layer as al import nineml.abstraction_layer.readers as readers import nineml.abstraction_layer.writers as writers import pyNN.neuron.nineml as pyNNml from nineml.abstraction_layer.flattening import ComponentFlattener #LocationMgr.StdAppendToPath() sample_xml_dir = Join(LocationMgr.getCatalogDir(), "sample_xml_files") tenml_dir = Join(LocationMgr.getCatalogDir(), "sample_xml_files/10ml/") def t1(): print 'Loading First XML File' print '----------------------' component = readers.XMLReader.read_component(Join(sample_xml_dir, 'PostTF_izhikevich.xml')) writers.XMLWriter.write(component, '/tmp/nineml_toxml1.xml') def t2(): print 'Loading Second XML File (IAF-Component' print '--------------------------------------' component = readers.XMLReader.read_component(Join(tenml_dir, 'comp_iaf.9ml')) writers.XMLWriter.write(component, '/tmp/nineml_toxml2.xml')