Debian Codegraph @

ansible_collections/community/general/plugins/module_utils/_onepassword.py

raw
1 # Copyright (c) Ansible project
2 # Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause)
3 # SPDX-License-Identifier: BSD-2-Clause
4
5 # Note that this module util is **PRIVATE** to the collection. It can have breaking changes at any time.
6 # Do not use this from other collections or standalone plugins/modules!
7
8 from __future__ import annotations
9
10 import os
11
12
13 class OnePasswordConfig:
14 _config_file_paths = (
15 "~/.op/config",
16 "~/.config/op/config",
17 "~/.config/.op/config",
18 )
19
20 def __init__(self) -> None:
21 self._config_file_path = ""
22
23 @property
24 def config_file_path(self) -> str | None:
25 if self._config_file_path:
26 return self._config_file_path
27
28 for path in self._config_file_paths:
29 realpath = os.path.expanduser(path)
30 if os.path.exists(realpath):
31 self._config_file_path = realpath
32 return self._config_file_path
33
34 return None