naas_abi_core.utils.onto2py.__main__
What it is
- The module entry point for running
onto2pyviapython -m .... - Converts a Turtle (
.ttl) file into generated Python code and writes it to an output file.
Public API
main()- CLI-style function that:
- Reads
<ttl_file>and<output_file>fromsys.argv. - Calls
onto2py(ttl_file)to generate Python source code. - Writes the generated code to
<output_file>. - Exits with status
1on incorrect usage or conversion/write errors.
- Reads
- CLI-style function that:
Configuration/Dependencies
- Standard library:
sysfor CLI argument handling and exit codes.
- Internal dependency:
from .onto2py import onto2py(must be available and callable asonto2py(ttl_file)).
Usage
Run as a module (expects two arguments: input TTL file and output Python file):
python -m naas_abi_core.utils.onto2py input.ttl output.pyProgrammatic invocation (uses sys.argv):
from naas_abi_core.utils.onto2py.__main__ import main
# Ensure sys.argv is set appropriately before calling main()
main()Caveats
- Requires at least two CLI arguments; otherwise prints usage and exits with code
1. - Any exception during conversion or file writing is caught, printed, and causes exit code
1. - The success/error messages include Unicode symbols (✅ / ❌).