Skip to content

Commit

Permalink
Merge pull request #165 from OkieOth/stefan_g
Browse files Browse the repository at this point in the history
add function to modelFuncs
  • Loading branch information
OkieOth authored Jun 25, 2024
2 parents 8dc2974 + 79a05a8 commit c2bb557
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
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

0 comments on commit c2bb557

Please sign in to comment.