nie-ine / knora-utilities

a toolset for Knora
GNU General Public License v3.0
3 stars 0 forks source link

Generate import statements of generated classes during the execution of ttl2py.py #3

Closed rfbaumgartner closed 4 years ago

rfbaumgartner commented 6 years ago

Now executing ttl2py.py generates a folder structure containing the classes of the ontology:

ontologies
  agent
    classes
      Agenty.py
      Group.py
      ...
    properties
      actsIn.py
      ...
...

I wish that the script also generates a file with the following structure:

from ontologies.agent.classes.Agent imports Agent
from ontologies.agent.classes.Group imports Group
...
from ontologies.agent.properties.actsIn import ActsIn
...

This file should be put next to the new folder ontologies. Executing it will import all the existing classes in said folder and reveal errors in the code.

This serves several purposes:

rfbaumgartner commented 6 years ago

So far, I use the following command (in the folder that contains the ontologies folder):

 grep -r -e '^class' ontologies | sed 's/.py:class/ import /' | sed 's/(.*):.*$//' | sed 's/\//./g' | sed 's/ontologies/from ontologies/' | grep -v '#' | python3