diff options
Diffstat (limited to 'muppet/puppet/strings.py')
-rw-r--r-- | muppet/puppet/strings.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/muppet/puppet/strings.py b/muppet/puppet/strings.py index f308985..0f4930d 100644 --- a/muppet/puppet/strings.py +++ b/muppet/puppet/strings.py @@ -1,6 +1,7 @@ """Python wrapper around puppet strings.""" import subprocess +from typing import Any def puppet_strings(path: str) -> bytes: @@ -13,3 +14,21 @@ def puppet_strings(path: str) -> bytes: check=True, stdout=subprocess.PIPE) return cmd.stdout + + +def isprivate(entry: dict[str, Any]) -> bool: + """ + Is the given puppet declaration marked private. + + Assumes input is a dictionary as returned by puppet strings, one + of the entries in (for example) 'puppet_classes'. + + Currently only checks for an "@api private" tag. + """ + if ds := entry.get('docstring'): + if tags := ds.get('tags'): + for tag in tags: + if tag.get('tag_name') == 'api' and \ + tag.get('text') == 'private': + return True + return False |