コード例 #1
0
ファイル: __init__.py プロジェクト: oeg-upm/Mapeathor
def writePrefix(data, path):
    """
    Writes the prefixes temporal file from the template with the information in 'data' into the path 'path'
    """
    for prefix in data['Prefix']:
        f = open(path + 'Prefix.yml', 'a+')
        f_base = open(path + 'Base.yml', 'a+')

        if ':' in str(prefix['Prefix']):
            re.sub(':', '', str(prefix['Prefix']))
        elif prefix['Prefix'] == 'nan' or prefix['URI'] == 'nan':
            continue

        if prefix['Prefix'] == '@base':
            f_base.write('URI' + ': ' + str(prefix['URI']) + '\n')
            f_base.close()
            go_template.render_template(templatesDir + 'Base.tmpl',tmpDir + 'Base.yml', tmpDir + 'Base.txt')
            writeResult('', 'Base')  

        else:
            f.write('Prefix' + ': ' + str(prefix['Prefix']) + '\n')
            f.write('URI' + ': ' + str(prefix['URI']) + '\n')
            f.close()
            go_template.render_template(templatesDir + 'Prefix.tmpl',tmpDir + 'Prefix.yml', tmpDir + 'Prefix.txt')
            writeResult('', 'Prefix')
コード例 #2
0
ファイル: __init__.py プロジェクト: daniel-dona/Mapeathor
def writePredicateObjects(data, path):
    """
    Writes the predicateObjectMaps temporal file from the template with the information in 'data' into the path 'path'
    """
    for key in data:
        if (len(data[key]) > 0):
            for predicateObjects in data[key]:
                f = open(path + key + '.yml', 'a+')
                predicateObjects['Object'] = replaceVars(
                    str(predicateObjects['Object']),
                    str(predicateObjects['ObjectType']),
                    str(predicateObjects['TermType']))
                predicateObjects['Predicate'] = replaceVars(
                    str(predicateObjects['Predicate']),
                    str(predicateObjects['PredicateType']), 'nan')
                if ('InnerRef' in predicateObjects.keys()
                        and 'OuterRef' in predicateObjects.keys()):
                    predicateObjects['InnerRef'] = replaceVars(
                        str(predicateObjects['InnerRef']), 'join_condition',
                        'nan')
                    predicateObjects['OuterRef'] = replaceVars(
                        str(predicateObjects['OuterRef']), 'join_condition',
                        'nan')

                for element in predicateObjects:
                    f.write(
                        str(element) + ': \'' + predicateObjects[element] +
                        '\'\n')
                f.close()
                go_template.render_template(templatesDir + key + '.tmpl',
                                            tmpDir + key + '.yml',
                                            tmpDir + key + '.txt')
                writeResult(data[key][0]['ID'], key)
コード例 #3
0
ファイル: __init__.py プロジェクト: oeg-upm/Mapeathor
def writeFunctionMap(data, path):
    """
    Writes the function map temporal file from the template with the information in 'data' into the path 'path'
    """
    f = open(path + 'FunctionMap.yml', 'a+')
    f.write('FunctionID: ' + str(data) + '\n')
    f.close()
    go_template.render_template(templatesDir + 'FunctionMap.tmpl', tmpDir + 'FunctionMap.yml', tmpDir + 'FunctionMap.txt')
    writeResult(str(data), 'FunctionMap')
コード例 #4
0
ファイル: test_utils.py プロジェクト: rhollosy/go-template
    def test_add(self):
        test_dir = os.path.dirname(__file__)
        go_template.render_template(os.path.join(test_dir, 'sample.tmpl'),
                                    os.path.join(test_dir, 'values.yml'),
                                    os.path.join(test_dir, 'output.txt'))

        output_hash = sha256sum(os.path.join(test_dir, 'output.txt'))
        test_hash = sha256sum(os.path.join(test_dir, 'test.txt'))
        self.assertEqual(output_hash, test_hash)
コード例 #5
0
ファイル: __init__.py プロジェクト: oeg-upm/Mapeathor
def writeFunctionPOM(data, path):
    """
    Writes the Predicate_Object of function temporal file from the template with the information in 'data' into the path 'path'
    """
    for pom in data:
        f = open(path + 'FunctionPOM.yml', 'a+')
        if pom['Feature'] != 'fno:executes' and str(pom['Value'])[0] != '<':
            pom['Value'] = '\"' + pom['Value'] + '\"'
        for element in pom:
            f.write(str(element) + ': \'' + pom[element] + '\'\n')
        f.close()
        go_template.render_template(templatesDir + 'FunctionPOM.tmpl', tmpDir + 'FunctionPOM.yml', tmpDir + 'FunctionPOM.txt')
        writeResult(pom['FunctionID'], 'FunctionPOM')
コード例 #6
0
ファイル: __init__.py プロジェクト: oeg-upm/Mapeathor
def writeFunctionSource(data, path):
    """
    Writes the source of function temporal file from the template with the information in 'data' into the path 'path'
    """
    f = open(path + 'FunctionSource.yml', 'a+')
    config  = json.loads(open(templatesDir + 'config.json').read())
    if(data['Iterator'] != ''):
        data['Iterator'] = str(config['iterator']['before']) + str(data['Iterator']) + str(config['iterator']['after'])
    for element in data:
        f.write(str(element) + ': \'' + data[element] + '\'\n')
    f.close()
    go_template.render_template(templatesDir + 'FunctionSource.tmpl',tmpDir + 'FunctionSource.yml', tmpDir + 'FunctionSource.txt')
    writeResult(data['FunctionID'], 'FunctionSource')
コード例 #7
0
ファイル: __init__.py プロジェクト: daniel-dona/Mapeathor
def writePrefix(data, path):
    """
    Writes the prefixes temporal file from the template with the information in 'data' into the path 'path'
    """
    for prefix in data['Prefixes']:
        f = open(path + 'Prefixes.yml', 'a+')
        for element in prefix:
            if element == 'Prefix' and ':' in str(prefix[element]):
                prefix[element] = re.sub(':', '', str(prefix[element]))
            f.write(str(element) + ': ' + str(prefix[element]) + '\n')
        f.close()
        go_template.render_template(templatesDir + 'Prefixes.tmpl',
                                    tmpDir + 'Prefixes.yml',
                                    tmpDir + 'Prefixes.txt')
        writeResult('', 'Prefixes')
コード例 #8
0
ファイル: __init__.py プロジェクト: oeg-upm/Mapeathor
def writeSubjectTemp(data, path):
    """
    NOT IN USE
    Writes the subject temporal file from the template with the information in 'data' into the path 'path'
    """
    f = open(path + 'Subject.yml', 'a+')
    data['URI'] = replaceVars(data['URI'], data['SubjectType'], 'nan')
    for element in data:
        if element != 'Class':
            f.write(element + ': ' + data[element] + '\n')
        else:
            for i in range(0, len(data[element])):
                f.write(element + str(i) + ': ' + data[element][i] + '\n')
    f.close()
    go_template.render_template(templatesDir + 'Subject.tmpl',tmpDir + 'Subject.yml', tmpDir + 'Subject.txt')
    writeResult(data['ID'], 'Subject')