Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to modelFuncs #165

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,5 @@
"module": "unittest",
"args": ["-v","${file}"]
}

]
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 6.7.0
* add 'getProperty' function to modelFuncs

# 6.6.0
* add additional functions to modelFuncs

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.0
6.7.0
18 changes: 18 additions & 0 deletions yacg/model/modelFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ def hasProperty(propertyName, typeObj):
return False


def getProperty(propertyName, typeObj):
"""checks whether the type, which was provided as parameter, has a property with the given name,
and returns that property accordingly.
Returns the corresponding property or 'None', if no such property is available

Keyword arguments:
propertyName -- name of the property to look for
typeObj -- type object to check up
"""

if not hasattr(typeObj, 'properties'):
return False
for property in typeObj.properties:
if property.name == propertyName:
return property
return None


def hasKey(typeObj):
"""checks if a specific type object has a property that is marked as
unique key.
Expand Down
Loading