Exemple #1
0
def _isConfigurationValid(codeGenerationJobs):
    """checks up the give job configuration array and
    returns True if valid else if not
    """

    isValid = True
    if (codeGenerationJobs is None) or (len(codeGenerationJobs) == 0):
        errorMsg = getErrorTxt('no generation jobs are given - cancel')
        logging.info(errorMsg)
        return False
    if _foundAllTemplates(codeGenerationJobs) is False:
        isValid = False
    if _foundAllModels(codeGenerationJobs) is False:
        isValid = False
    return isValid
Exemple #2
0
def _foundAllModels(codeGenerationJobs):
    """checks up if all model file are accessible. For internal templates the
    template file name is changed

    returns True if all templates are available, else False
    """

    foundAll = True
    for job in codeGenerationJobs:
        for model in job.models:
            fileExists = doesFileExist(model.schema)
            fileExistsString = getOkTxt('found') if fileExists \
                else getErrorTxt('missing')
            if not fileExists:
                foundAll = False
            logging.info('   {}\t{}'.format(fileExistsString, model.schema))
    return foundAll
Exemple #3
0
def _tryToFindTemplate(templateFile):
    """tests if the given file name is a external or an internal template. If it
    is an internal template, then the file name is changed to a relative path.

    Function return a tupel with the true or false as first element, and the file name
    to the found file as second element
    """

    fileExists = False
    templateFileToReturn = templateFile
    if doesFileExist(templateFile):
        fileExists = True
    else:
        internalTemplateName = 'yacg/generators/templates/{}.mako'.format(
            templateFile)
        fileExists = doesFileExist(internalTemplateName)
        templateFileToReturn = internalTemplateName
    fileExistsString = getOkTxt('found') if fileExists else getErrorTxt(
        'missing')
    logging.info('   {}\t{}'.format(fileExistsString, templateFile))
    return (fileExists, templateFileToReturn)