def main(): global arrays, dimensions, subs, variables with open(filepath, 'r') as f: text = f.read() #Comment pattern comments = re.compile(r"\n(?:[cC][\s\S]*?\n)+") #Pattern to find cgas subroutines in the Fortran file. find_csubs = re.compile(r"SUBROUTINE CGAS([0-9]+)([\S\s]*?)END[\s]*\n") #Pattern to find gas subroutines in the Fortran file. text = re.sub(comments, "\n", text) subs = re.findall(find_csubs, text) for sub in subs: i = int(sub[0]) if i in gas_dict: dimensions[i] = get_dimensions(sub[1]) arrays[i] = {} arrays[i] = get_arrays(sub[1], dimensions[i], arrays[i]) arrays[i] = get_flat_arrays(sub[1], arrays[i], dimensions[i]) arrays[i] = get_multi_arrays(sub[1], arrays[i], dimensions[i]) for gas in gas_dict: formula = gas_dict[gas]['formula'] i = 0 for pair in formula: element = utils.getSingle(pair) number = pair[element] if element not in elements: elements[element] = get_element_data(element, number, i, arrays[gas], dimensions[gas]) i += 1 write_data(elements)
def getById(id): """ GET /<id> Return a single recipe depending on the requested MIME-type. Render a template with Microdata if text/html is requested. :param id: the id of the requested resource """ if 'text/html' in request.headers.get('Accept'): entry = Resource(graph, URIRef(LOCAL[id])) recipe = Recipe().deserialize(entry) return render_template('recipe/recipe.html', recipe=recipe) elif 'application/json+ld' in request.headers.get('Accept'): return getSingle(graph, LOCAL, id).serialize(format='json-ld') return getSingle(graph, LOCAL, id)
def getRDFIngredient(id): if 'application/json+ld' in request.headers.get('Accept'): return getSingle(graph, LOCAL, id).serialize(format='json-ld') return getSingle(graph, LOCAL, id)