Debian Codegraph @

ansible_collections/containers/podman/plugins/module_utils/inventory/utils.py

raw
1 import os
2
3
4 def verify_inventory_file(self, path: str) -> bool:
5
6 unused, ext = os.path.splitext(path)
7 if ext not in (".yml", ".yaml"):
8 return False
9 try:
10 with open(path, "r", encoding="utf-8") as f:
11 header = f.read(2048)
12 return (
13 (f"plugin: {self.NAME}\n" in header)
14 or (f"plugin: '{self.NAME}'" in header)
15 or (f'plugin: "{self.NAME}"' in header)
16 )
17 except Exception:
18 return False