Beispiel #1
0
def get_params(args, opts):
    """
    Get params from conffile
    """
    logger = logging.getLogger('fms')
    simconffile = get_simconffile(args)
    if os.path.splitext(simconffile)[-1] == '.xml':
        logger.debug("Calling XmlParamsParser on %s" % simconffile)
        params = XmlParamsParser(simconffile)
    else:
        logger.debug("Calling YamlParamsParser on %s" % simconffile)
        params = YamlParamsParser(simconffile)
    params['simconffile'] = simconffile
    params = apply_opts(params, opts)
    params.printparams()
    return params
Beispiel #2
0
Datei: utils.py Projekt: l4u/fms
 def testDaylengthValue(self):
     """
     Daylength is correctly read as an int
     """
     xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['engines'][0]['daylength'], 10)
Beispiel #3
0
Datei: utils.py Projekt: l4u/fms
 def testClearBooksAtEODDefaultValue(self):
     """
     Engines clear books at end of day
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertTrue(params['engines'][0]['clearbooksateod'])
Beispiel #4
0
Datei: utils.py Projekt: l4u/fms
 def testDaylengthDefaultValue(self):
     """
     Daylength should be 1 if missing
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['engines'][0]['daylength'], 1)
Beispiel #5
0
Datei: utils.py Projekt: l4u/fms
 def testWorldClassValue(self):
     """
     World class is read correctly
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['world']['classname'], 'NullWorld')
Beispiel #6
0
Datei: utils.py Projekt: l4u/fms
 def testOrdersLogFileDefaultValue(self):
     """
     OrdersLogFile shoud be None if missing
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['orderslogfilename'], None)
Beispiel #7
0
Datei: utils.py Projekt: l4u/fms
 def testOutputfileDefaultValue(self):
     """
     Outputfile should be sys.stdout if missing
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['outputfilename'], 'sys.stdout')
Beispiel #8
0
Datei: utils.py Projekt: l4u/fms
 def testRandomSeedValue(self):
     """
     Randomseed is read correctly
     """
     xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['randomseed'], '12345678')
Beispiel #9
0
Datei: utils.py Projekt: l4u/fms
 def testRandomseedDefaultValue(self):
     """
     Randomseed should be None if missing
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['randomseed'], None)
Beispiel #10
0
Datei: utils.py Projekt: l4u/fms
 def testExperimentNameValue(self):
     """
     Experiment name is correctly read
     """
     xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['name'], 'Test Experiment')
Beispiel #11
0
def get_params(args, opts):
    """
    Get params from conffile
    """
    logger = logging.getLogger('fms')
    simconffile = get_simconffile(args)
    if os.path.splitext(simconffile)[-1] == '.xml':
        logger.debug("Calling XmlParamsParser on %s" % simconffile)
        params = XmlParamsParser(simconffile)
    else:
        logger.debug("Calling YamlParamsParser on %s" % simconffile)
        params = YamlParamsParser(simconffile)
    params['simconffile'] = simconffile
    params = apply_opts(params, opts)
    params.printparams()
    return params
Beispiel #12
0
Datei: utils.py Projekt: l4u/fms
 def testMarketClassValue(self):
     """
     Market param classname is read correctly
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['engines'][0]['market']['classname'],
                      'DummyMarket')
Beispiel #13
0
Datei: utils.py Projekt: l4u/fms
 def testEngineClassValue(self):
     """
     Engine classname is read correctly
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['engines'][0]['classname'],
                      'AsynchronousRandom')
Beispiel #14
0
Datei: utils.py Projekt: l4u/fms
 def testOrderLogFileValue(self):
     """
     OrdersLogFile might be read from config
     """
     xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['orderslogfilename'],
                      '%s/dummyoutput.log' % self.fixturesdir)
Beispiel #15
0
Datei: utils.py Projekt: l4u/fms
 def testOuputfileValue(self):
     """
     Outputfile might be read from config
     """
     xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['outputfilename'],
                      '%s/dummyoutput.csv' % self.fixturesdir)
Beispiel #16
0
Datei: utils.py Projekt: l4u/fms
 def testExperimentNameDefaultValue(self):
     """
     Experiment name is built from filename if missing
     """
     xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir
     params = XmlParamsParser(xmlparamsfile)
     self.assertEqual(params['name'],
                      '%s/minimalconfig.xml experiment' % self.fixturesdir)