Skip to content

Commit

Permalink
custom namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-ap committed Mar 14, 2024
1 parent 0cb5086 commit a83f705
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/colt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
from: ontologies/
to: ontologies/out
package_name: ColtTest
namespace: Rdf.Colt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: "The name of the code library package generated."
required: true
default: "OntologyLibrary"
namespace:
description: ""
required: false
default: "Auto.Ontology"
runs:
using: "docker"
image: "Dockerfile"
10 changes: 8 additions & 2 deletions src/LibraryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
if not os.path.exists(from_dir):
os.makedirs(from_dir)

namespace = os.environ.get("INPUT_NAMESPACE")
if namespace is None:
namespace = f"Auto.Ontology.{package_name}"


print(f"Package name: {package_name}")
print(f"Collecting ontologies from: {from_dir}")
print(f"Saving code library to: {to_dir}")
print(f"Using namespace {namespace}")

def short_name(s: str) -> str:
try:
Expand Down Expand Up @@ -113,8 +119,8 @@ def clean_class_name(o: Ontology) -> str:
return r

def ontology_class(o: Ontology, fields: list) -> str:
r = f"namespace Auto.Ontology.{package_name};\n\n"
comment = f"This class is automatically generated from the <{o.base}> ontology.\nThe intended use is:\n<code>using Auto.Ontology.{package_name};</code>"
r = f"namespace {namespace};\n\n"
comment = f"This class is automatically generated from the <{o.base}> ontology.\nThe intended use is:\n<code>using {namespace};</code>"

class_name = clean_class_name(o)

Expand Down

0 comments on commit a83f705

Please sign in to comment.