-
Notifications
You must be signed in to change notification settings - Fork 4
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 #52 from emmo-repo/dic2owl
Update `dic2owl` to new annotated ontology schema. This PR includes several updates to CI and linting as well. The `dic2owl` package is updated to v0.2.0.
- Loading branch information
Showing
15 changed files
with
1,230 additions
and
432 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
""" | ||
# Retrieve dependencies | ||
Retrieve dependencies from a `requirements.txt`-style file. | ||
""" | ||
import argparse | ||
from pathlib import Path | ||
import re | ||
from typing import Set | ||
|
||
|
||
def main(argv_input: list = None) -> Set[str]: | ||
"""Retrieve dependencies""" | ||
parser = argparse.ArgumentParser( | ||
description=main.__doc__, | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"requirements_files", | ||
metavar="FILE", | ||
type=Path, | ||
nargs="+", | ||
help="The path(s) to one or several requirements.txt-style file(s).", | ||
) | ||
args = parser.parse_args(argv_input) | ||
|
||
requirements_regex = re.compile( | ||
r"^(?P<name>[A-Za-z0-9_-]+)(~=|>=|==).*\n$" | ||
) | ||
dependencies = set() | ||
for file in args.requirements_files: | ||
if not file.exists(): | ||
raise FileNotFoundError(f"Could not find {file} !") | ||
with open(file.resolve(), "r") as handle: | ||
for line in handle.readlines(): | ||
match = requirements_regex.fullmatch(line) | ||
if match is None: | ||
raise ValueError( | ||
( | ||
"Couldn't determine package name from line:\n\n " | ||
f"{line}" | ||
) | ||
) | ||
dependencies.add(match.group("name")) | ||
return dependencies | ||
|
||
|
||
if __name__ == "__main__": | ||
from sys import argv | ||
|
||
parsed_dependencies = main(argv[1:]) | ||
grep_extended_regex = f"({'|'.join(parsed_dependencies)})" | ||
print(grep_extended_regex) |
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
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ old | |
__pycache__ | ||
*.pyc | ||
|
||
.mypy* | ||
|
||
*.dic | ||
*.cif | ||
|
||
|
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 @@ | ||
cif_core.ttl | ||
catalog-v001.xml |
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,3 +1,16 @@ | ||
__version__ = "0.1.0" | ||
__author__ = "Jesper Friis" | ||
__author_email__ = "[email protected]" | ||
""" | ||
# `dic2owl` Python package | ||
This is a tool to generate ontologies from a CIF `.dic`-file. | ||
It can be used either by importing and using the `dic2owl.dic2owl.main` | ||
function or running it via the `dic2owl` CLI, which will be automatically | ||
installed when `pip install`-ing this package. | ||
For more information on how to run the CLI, run `dic2owl --help` in your | ||
terminal. | ||
""" | ||
# pylint: disable=line-too-long | ||
|
||
__version__ = "0.2.0" | ||
__author__ = "Jesper Friis <[email protected]>, Casper Welzel Andersen <[email protected]>, Francesca Lønstad Bleken <[email protected]>" | ||
__author_email__ = "[email protected]" |
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.