This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from simphony/use-simphony-metaparser
Using simphony metaparser instead of direct yaml parsing.
- Loading branch information
Showing
120 changed files
with
987 additions
and
831 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
language: python | ||
sudo: false | ||
python: | ||
- '2.7' | ||
- '2.7' | ||
virtualenv: | ||
system_site_packages: false | ||
addons: | ||
apt: | ||
packages: | ||
- python-pip | ||
- libhdf5-serial-dev | ||
- python-pip | ||
- libhdf5-serial-dev | ||
cache: | ||
directories: | ||
- "$HOME/.cache" | ||
- "$HOME/.ccache" | ||
- "$HOME/.cache" | ||
- "$HOME/.ccache" | ||
before_install: | ||
- ccache -s | ||
- export PATH=/usr/lib/ccache:${PATH} | ||
- pip install --upgrade pip | ||
- ccache -s | ||
- export PATH=/usr/lib/ccache:${PATH} | ||
- pip install --upgrade pip | ||
install: | ||
- pip install numexpr | ||
- pip install -r dev_requirements.txt | ||
- python setup.py develop | ||
- pushd examples/plugin | ||
- python setup.py develop | ||
- popd | ||
- pip install -r requirements.txt | ||
- pip install -r dev_requirements.txt | ||
- python setup.py develop | ||
- pushd examples/plugin | ||
- python setup.py develop | ||
- popd | ||
- python setup.py build_meta | ||
script: | ||
- flake8 . | ||
- py.test -v | ||
- sphinx-build -W doc/source doc/build/sphinx | ||
- flake8 . | ||
- py.test -v | ||
- sphinx-build -W doc/source doc/build/sphinx | ||
after_success: | ||
- pip install codecov | ||
- codecov | ||
- pip install codecov | ||
- codecov | ||
notifications: | ||
slack: | ||
secure: a3aAlsxs2uPa1ggrDQouECqMGfR9DaZQBOVUmdGeOK6LHq+Pta/KbgUbiwA42c3QbR9WfI+J3oRuC9ZrZDo6d/DmobTCBTutWsTPs/LIJIZVfdbvYyJWzzeFTE9ca4iwHiQiZlG3d6EVQYVEf3cWuE89o0YEmRLmxAy99MPAtWM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numexpr | ||
git+https://github.com/simphony/simphony-metaparser.git@master#egg=simphony_metaparser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
from __future__ import print_function | ||
|
||
import os | ||
from scripts.utils import to_camel_case | ||
from simphony_metaparser.utils import traverse | ||
|
||
from scripts.utils import cuba_key_to_meta_class_module_name, \ | ||
cuba_key_to_meta_class_name | ||
|
||
|
||
class APIGenerator(object): | ||
def generate(self, simphony_metadata_dict, out_path): | ||
def generate(self, ontology, output): | ||
""" | ||
Generates the api.py with the appropriate imports. | ||
The imports are alphabetically ordered. | ||
ontology: Ontology | ||
The node of the ontology | ||
output: file | ||
The file on which to write the result | ||
""" | ||
|
||
for key in sorted(simphony_metadata_dict['CUDS_KEYS'].keys()): | ||
with open(os.path.join(out_path, "api.py"), 'ab') as api_file: | ||
print( | ||
'from .{} import {} # noqa'.format( | ||
key.lower(), | ||
to_camel_case(key) | ||
), | ||
sep='\n', | ||
file=api_file | ||
lines = [] | ||
for cuds_item, _ in traverse(ontology.root_cuds_item): | ||
lines.append('from .{} import {} # noqa\n'.format( | ||
cuba_key_to_meta_class_module_name(cuds_item.name), | ||
cuba_key_to_meta_class_name(cuds_item.name) | ||
) | ||
) | ||
|
||
for line in sorted(lines): | ||
output.write(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
from simphony_metaparser.utils import traverse, without_cuba_prefix | ||
|
||
|
||
class CUBAEnumGenerator(object): | ||
"""Generator class for cuba.py enumeration. | ||
""" | ||
|
||
def generate(self, cuba_dict, simphony_metadata_dict, output): | ||
def generate(self, ontology, output): | ||
"""Generates the cuba file from the yaml-extracted dictionary | ||
of cuba and simphony_metadata files. Writes the generated code | ||
in the file object output | ||
""" | ||
lines = [ | ||
'# code auto-generated by the\n', | ||
'# simphony-metadata/scripts/generate.py script.\n', | ||
'# cuba.yml VERSION: {}\n'.format(cuba_dict['VERSION']), | ||
'# cuba.yml\n', | ||
'from enum import Enum, unique\n', | ||
'\n', | ||
'\n', | ||
'@unique\n', | ||
'class CUBA(Enum):\n' | ||
] | ||
template = ' {keyword} = "{keyword}"\n' | ||
template = ' {cuba_name} = "{cuba_name}"\n' | ||
|
||
all_keys = set( | ||
cuba_dict['CUBA_KEYS']) | set(simphony_metadata_dict['CUDS_KEYS']) | ||
all_keys = set(d.name for d in ontology.data_types) | ||
all_keys.update([d.name for d, _ in traverse(ontology.root_cuds_item)]) | ||
|
||
for keyword in sorted(list(all_keys)): | ||
lines.append(template.format(keyword=keyword)) | ||
lines.append( | ||
template.format( | ||
cuba_name=without_cuba_prefix(keyword))) | ||
|
||
output.writelines(lines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.