Example #1
0
def loadYaml(filename=None, importedAlready=None):
    """ Loads the YAML and constructs a configuration from it. """
    if not filename:
        filename = _findYaml()
    if not filename:
        raise exceptions.YamlFileNotFoundError('fsm.yaml')

    try:
        yamlFile = open(filename)
    except IOError:
        raise exceptions.YamlFileNotFoundError(filename)
    try:
        configDict = yaml.load(yamlFile.read())
    finally:
        yamlFile.close()

    return Configuration(configDict, importedAlready=importedAlready)
Example #2
0
 def _importYaml(self, importYamlFile, importedAlready=None):
     """ Imports a yaml file """
     yamlFile = _findYaml(yamlNames=[importYamlFile])
     if not yamlFile:
         raise exceptions.YamlFileNotFoundError(importYamlFile)
     if yamlFile in importedAlready:
         raise exceptions.YamlFileCircularImportError(importYamlFile)
     importedAlready.append(yamlFile)
     importedConfig = loadYaml(filename=yamlFile, importedAlready=importedAlready)
     self.__addMachinesFromImportedConfig(importedConfig)