scrapli 2.0.0a2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scrapli-2.0.0a2/LICENSE +21 -0
- scrapli-2.0.0a2/MANIFEST.in +5 -0
- scrapli-2.0.0a2/PKG-INFO +49 -0
- scrapli-2.0.0a2/README.md +1 -0
- scrapli-2.0.0a2/pyproject.toml +112 -0
- scrapli-2.0.0a2/requirements-dev.txt +8 -0
- scrapli-2.0.0a2/requirements-genie.txt +2 -0
- scrapli-2.0.0a2/requirements-textfsm.txt +2 -0
- scrapli-2.0.0a2/requirements.txt +0 -0
- scrapli-2.0.0a2/scrapli/__init__.py +30 -0
- scrapli-2.0.0a2/scrapli/auth.py +216 -0
- scrapli-2.0.0a2/scrapli/cli.py +1414 -0
- scrapli-2.0.0a2/scrapli/cli_decorators.py +148 -0
- scrapli-2.0.0a2/scrapli/cli_parse.py +161 -0
- scrapli-2.0.0a2/scrapli/cli_result.py +197 -0
- scrapli-2.0.0a2/scrapli/definitions/__init__.py +1 -0
- scrapli-2.0.0a2/scrapli/definitions/arista_eos.yaml +64 -0
- scrapli-2.0.0a2/scrapli/definitions/cisco_iosxe.yaml +63 -0
- scrapli-2.0.0a2/scrapli/definitions/cisco_iosxr.yaml +47 -0
- scrapli-2.0.0a2/scrapli/definitions/cisco_nxos.yaml +64 -0
- scrapli-2.0.0a2/scrapli/definitions/juniper_junos.yaml +85 -0
- scrapli-2.0.0a2/scrapli/definitions/nokia_srlinux.yaml +35 -0
- scrapli-2.0.0a2/scrapli/exceptions.py +49 -0
- scrapli-2.0.0a2/scrapli/ffi.py +76 -0
- scrapli-2.0.0a2/scrapli/ffi_mapping.py +202 -0
- scrapli-2.0.0a2/scrapli/ffi_mapping_cli.py +646 -0
- scrapli-2.0.0a2/scrapli/ffi_mapping_netconf.py +1612 -0
- scrapli-2.0.0a2/scrapli/ffi_mapping_options.py +1031 -0
- scrapli-2.0.0a2/scrapli/ffi_types.py +154 -0
- scrapli-2.0.0a2/scrapli/helper.py +95 -0
- scrapli-2.0.0a2/scrapli/lib/__init__.py +1 -0
- scrapli-2.0.0a2/scrapli/lib/libscrapli.so.0.0.1-alpha.10 +0 -0
- scrapli-2.0.0a2/scrapli/netconf.py +2804 -0
- scrapli-2.0.0a2/scrapli/netconf_decorators.py +148 -0
- scrapli-2.0.0a2/scrapli/netconf_result.py +72 -0
- scrapli-2.0.0a2/scrapli/py.typed +0 -0
- scrapli-2.0.0a2/scrapli/session.py +122 -0
- scrapli-2.0.0a2/scrapli/transport.py +401 -0
- scrapli-2.0.0a2/scrapli.egg-info/PKG-INFO +49 -0
- scrapli-2.0.0a2/scrapli.egg-info/SOURCES.txt +43 -0
- scrapli-2.0.0a2/scrapli.egg-info/dependency_links.txt +1 -0
- scrapli-2.0.0a2/scrapli.egg-info/requires.txt +28 -0
- scrapli-2.0.0a2/scrapli.egg-info/top_level.txt +1 -0
- scrapli-2.0.0a2/setup.cfg +4 -0
- scrapli-2.0.0a2/setup.py +378 -0
scrapli-2.0.0a2/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Carl Montanari
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
scrapli-2.0.0a2/PKG-INFO
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: scrapli
|
3
|
+
Version: 2.0.0a2
|
4
|
+
Summary: Fast, flexible, sync/async, Python 3.10+ screen scraping client specifically for network devices
|
5
|
+
Author-email: Carl Montanari <carl.r.montanari@gmail.com>
|
6
|
+
License-Expression: MIT
|
7
|
+
Project-URL: Changelog, https://carlmontanari.github.io/scrapli/changelog
|
8
|
+
Project-URL: Docs, https://carlmontanari.github.io/scrapli/
|
9
|
+
Project-URL: Homepage, https://github.com/carlmontanari/scrapli
|
10
|
+
Keywords: netconf,network,ssh,telnet,async
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
12
|
+
Classifier: Operating System :: MacOS
|
13
|
+
Classifier: Programming Language :: Python
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
20
|
+
Requires-Python: >=3.10
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
License-File: LICENSE
|
23
|
+
Provides-Extra: dev
|
24
|
+
Requires-Dist: nox==2025.5.1; extra == "dev"
|
25
|
+
Requires-Dist: black<26.0.0,>=25.1.0; extra == "dev"
|
26
|
+
Requires-Dist: isort<7.0.0,>=6.0.1; extra == "dev"
|
27
|
+
Requires-Dist: ruff<1.0.0,>=0.11.8; extra == "dev"
|
28
|
+
Requires-Dist: mypy<2.0.0,>=1.15.0; extra == "dev"
|
29
|
+
Requires-Dist: pytest<9.0.0,>=8.3.5; extra == "dev"
|
30
|
+
Requires-Dist: pytest-cov<7.0.0,>=6.1.1; extra == "dev"
|
31
|
+
Requires-Dist: pytest-asyncio<1.0.0,>=0.26.0; extra == "dev"
|
32
|
+
Requires-Dist: pyats>=20.2; extra == "dev"
|
33
|
+
Requires-Dist: genie>=20.2; extra == "dev"
|
34
|
+
Requires-Dist: ntc-templates<8.0.0,>=1.1.0; extra == "dev"
|
35
|
+
Requires-Dist: textfsm<2.0.0,>=1.1.0; extra == "dev"
|
36
|
+
Provides-Extra: full
|
37
|
+
Requires-Dist: ntc-templates<8.0.0,>=1.1.0; extra == "full"
|
38
|
+
Requires-Dist: textfsm<2.0.0,>=1.1.0; extra == "full"
|
39
|
+
Requires-Dist: pyats>=20.2; extra == "full"
|
40
|
+
Requires-Dist: genie>=20.2; extra == "full"
|
41
|
+
Provides-Extra: textfsm
|
42
|
+
Requires-Dist: ntc-templates<8.0.0,>=1.1.0; extra == "textfsm"
|
43
|
+
Requires-Dist: textfsm<2.0.0,>=1.1.0; extra == "textfsm"
|
44
|
+
Provides-Extra: genie
|
45
|
+
Requires-Dist: pyats>=20.2; extra == "genie"
|
46
|
+
Requires-Dist: genie>=20.2; extra == "genie"
|
47
|
+
Dynamic: license-file
|
48
|
+
|
49
|
+
<p center><a href=""><img src=https://github.com/carlmontanari/scrapli/blob/main/scrapli.svg?sanitize=true/></a></p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p center><a href=""><img src=https://github.com/carlmontanari/scrapli/blob/main/scrapli.svg?sanitize=true/></a></p>
|
@@ -0,0 +1,112 @@
|
|
1
|
+
[build-system]
|
2
|
+
build-backend = "setuptools.build_meta"
|
3
|
+
requires = ["setuptools", "wheel", "ziglang==0.14.1"]
|
4
|
+
|
5
|
+
[project]
|
6
|
+
name = "scrapli"
|
7
|
+
description = "Fast, flexible, sync/async, Python 3.10+ screen scraping client specifically for network devices"
|
8
|
+
readme = "README.md"
|
9
|
+
keywords = ["netconf", "network", "ssh", "telnet", "async"]
|
10
|
+
license = "MIT"
|
11
|
+
authors = [{ name = "Carl Montanari", email = "carl.r.montanari@gmail.com" }]
|
12
|
+
requires-python = ">=3.10"
|
13
|
+
classifiers = [
|
14
|
+
"Operating System :: POSIX :: Linux",
|
15
|
+
"Operating System :: MacOS",
|
16
|
+
"Programming Language :: Python",
|
17
|
+
"Programming Language :: Python :: 3.10",
|
18
|
+
"Programming Language :: Python :: 3.11",
|
19
|
+
"Programming Language :: Python :: 3.12",
|
20
|
+
"Programming Language :: Python :: 3.13",
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
23
|
+
]
|
24
|
+
dynamic = ["dependencies", "optional-dependencies", "version"]
|
25
|
+
[project.urls]
|
26
|
+
Changelog = "https://carlmontanari.github.io/scrapli/changelog"
|
27
|
+
Docs = "https://carlmontanari.github.io/scrapli/"
|
28
|
+
Homepage = "https://github.com/carlmontanari/scrapli"
|
29
|
+
|
30
|
+
[tool.setuptools]
|
31
|
+
packages = ["scrapli", "scrapli.definitions", "scrapli.lib"]
|
32
|
+
|
33
|
+
[tool.setuptools.dynamic]
|
34
|
+
version = { attr = "scrapli.__version__" }
|
35
|
+
dependencies = { file = "requirements.txt" }
|
36
|
+
optional-dependencies.dev = { file = [
|
37
|
+
"requirements-dev.txt",
|
38
|
+
"requirements-genie.txt",
|
39
|
+
"requirements-textfsm.txt",
|
40
|
+
] }
|
41
|
+
optional-dependencies.full = { file = [
|
42
|
+
"requirements-textfsm.txt",
|
43
|
+
"requirements-genie.txt",
|
44
|
+
] }
|
45
|
+
optional-dependencies.textfsm = { file = "requirements-textfsm.txt" }
|
46
|
+
optional-dependencies.genie = { file = "requirements-genie.txt" }
|
47
|
+
|
48
|
+
[tool.setuptools.package-data]
|
49
|
+
scrapli = [
|
50
|
+
"py.typed",
|
51
|
+
"scrapli/definitions/*.yaml",
|
52
|
+
"scrapli/lib/*.so.*",
|
53
|
+
"scrapli/lib/*.dylib",
|
54
|
+
]
|
55
|
+
|
56
|
+
[tool.black]
|
57
|
+
line-length = 100
|
58
|
+
target-version = ["py313"]
|
59
|
+
|
60
|
+
[tool.isort]
|
61
|
+
profile = "black"
|
62
|
+
line_length = 100
|
63
|
+
multi_line_output = 3
|
64
|
+
include_trailing_comma = true
|
65
|
+
|
66
|
+
[tool.mypy]
|
67
|
+
python_version = "3.13"
|
68
|
+
pretty = true
|
69
|
+
ignore_missing_imports = true
|
70
|
+
warn_redundant_casts = true
|
71
|
+
warn_unused_configs = true
|
72
|
+
strict_optional = true
|
73
|
+
|
74
|
+
[tool.ruff]
|
75
|
+
include = ["setup.py", "scrapli/**.py", "tests/**.py"]
|
76
|
+
line-length = 100
|
77
|
+
|
78
|
+
[tool.ruff.lint]
|
79
|
+
select = [
|
80
|
+
"FIX",
|
81
|
+
"D",
|
82
|
+
"PL",
|
83
|
+
"ERA",
|
84
|
+
"C90",
|
85
|
+
"N",
|
86
|
+
"PERF",
|
87
|
+
"E",
|
88
|
+
"W",
|
89
|
+
"D",
|
90
|
+
"F",
|
91
|
+
"UP",
|
92
|
+
"FURB",
|
93
|
+
"RUF",
|
94
|
+
]
|
95
|
+
ignore = [
|
96
|
+
"D105", # Missing docstring in magic method
|
97
|
+
"D107", # Missing docstring in `__init__`
|
98
|
+
"D212", # Multi-line docstring summary should start at the first line
|
99
|
+
"D415", # First line should end with a period, question mark, or exclamation point
|
100
|
+
"N818", # Exception name `foo` should be named with an Error suffix
|
101
|
+
"UP015", # Unnecessary mode argument
|
102
|
+
]
|
103
|
+
|
104
|
+
[tool.ruff.lint.pydocstyle]
|
105
|
+
convention = "google"
|
106
|
+
|
107
|
+
[tool.ruff.lint.per-file-ignores]
|
108
|
+
"scrapli/ffi_mapping_*.py" = ["PLR0913"]
|
109
|
+
"tests/**.py" = ["D", "E501", "PLR0913"]
|
110
|
+
|
111
|
+
[tool.pytest.ini_options]
|
112
|
+
asyncio_default_fixture_loop_scope = "function"
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"""scrapli"""
|
2
|
+
|
3
|
+
from scrapli.auth import LookupKeyValue
|
4
|
+
from scrapli.auth import Options as AuthOptions
|
5
|
+
from scrapli.cli import Cli
|
6
|
+
from scrapli.netconf import Netconf
|
7
|
+
from scrapli.netconf import Options as NetconfOptions
|
8
|
+
from scrapli.session import Options as SessionOptions
|
9
|
+
from scrapli.transport import BinOptions as TransportBinOptions
|
10
|
+
from scrapli.transport import Options as TransportOptions
|
11
|
+
from scrapli.transport import Ssh2Options as TransportSsh2Options
|
12
|
+
from scrapli.transport import TelnetOptions as TransportTelnetOptions
|
13
|
+
from scrapli.transport import TestOptions as TransportTestOptions
|
14
|
+
|
15
|
+
__version__ = "2.0.0-alpha.2"
|
16
|
+
__definitions_version__ = "471f12e"
|
17
|
+
|
18
|
+
__all__ = (
|
19
|
+
"AuthOptions",
|
20
|
+
"Cli",
|
21
|
+
"LookupKeyValue",
|
22
|
+
"Netconf",
|
23
|
+
"NetconfOptions",
|
24
|
+
"SessionOptions",
|
25
|
+
"TransportBinOptions",
|
26
|
+
"TransportOptions",
|
27
|
+
"TransportSsh2Options",
|
28
|
+
"TransportTelnetOptions",
|
29
|
+
"TransportTestOptions",
|
30
|
+
)
|
@@ -0,0 +1,216 @@
|
|
1
|
+
"""scrapli.auth"""
|
2
|
+
|
3
|
+
from ctypes import c_char_p
|
4
|
+
from dataclasses import dataclass, field
|
5
|
+
|
6
|
+
from scrapli.exceptions import OptionsException
|
7
|
+
from scrapli.ffi_mapping import LibScrapliMapping
|
8
|
+
from scrapli.ffi_types import (
|
9
|
+
DriverPointer,
|
10
|
+
to_c_string,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
@dataclass
|
15
|
+
class LookupKeyValue:
|
16
|
+
"""
|
17
|
+
Options a "lookup" key/value pair.
|
18
|
+
|
19
|
+
Used in conjuection with platform definition templating like `__lookup::enable` where "enable"
|
20
|
+
is the key to "lookup" in the list of lookup key/values.
|
21
|
+
|
22
|
+
Args:
|
23
|
+
key: the name of the lookup key
|
24
|
+
value: the value of the lookup key
|
25
|
+
|
26
|
+
Returns:
|
27
|
+
None
|
28
|
+
|
29
|
+
Raises:
|
30
|
+
N/A
|
31
|
+
|
32
|
+
"""
|
33
|
+
|
34
|
+
key: str
|
35
|
+
value: str
|
36
|
+
|
37
|
+
_key: c_char_p | None = field(init=False, default=None, repr=False)
|
38
|
+
_value: c_char_p | None = field(init=False, default=None, repr=False)
|
39
|
+
|
40
|
+
def _get_c_strings(self) -> tuple[c_char_p, c_char_p]:
|
41
|
+
self._key = to_c_string(self.key)
|
42
|
+
self._value = to_c_string(self.value)
|
43
|
+
|
44
|
+
return self._key, self._value
|
45
|
+
|
46
|
+
def __repr__(self) -> str:
|
47
|
+
return f"{self.__class__.__name__}(key='{self.key}', value='REDACTED')"
|
48
|
+
|
49
|
+
|
50
|
+
@dataclass
|
51
|
+
class Options:
|
52
|
+
"""
|
53
|
+
Options holds auth related options to pass to the ffi layer.
|
54
|
+
|
55
|
+
All arguments are optional, though you will almost certainly need to provide *some* -- for
|
56
|
+
example a username and password or key.
|
57
|
+
|
58
|
+
Args:
|
59
|
+
username: the username to use for the connection
|
60
|
+
password: the password to use for the connection
|
61
|
+
private_key_path: filepath to the ssh private key to use
|
62
|
+
private_key_passphrase: the private key passphrase if set
|
63
|
+
lookups: a list of key/values that can be "looked up" from a connection -- used in
|
64
|
+
conjunction with platform definition templating like `__lookup::enable` where "enable"
|
65
|
+
is the key to "lookup" in the list of lookup key/values.
|
66
|
+
in_session_auth_bypass: whether to bypass attempting in session authentication -- only
|
67
|
+
applicable to "bin" and "telnet" transports.
|
68
|
+
username_pattern: the regex pattern to use to look for a username prompt
|
69
|
+
password_pattern: the regex pattern to use to look for a password prompt
|
70
|
+
private_key_passphrase_pattern: the regex pattern to use to look for a passphrase prompt
|
71
|
+
|
72
|
+
Returns:
|
73
|
+
None
|
74
|
+
|
75
|
+
Raises:
|
76
|
+
N/A
|
77
|
+
|
78
|
+
"""
|
79
|
+
|
80
|
+
username: str | None = None
|
81
|
+
password: str | None = None
|
82
|
+
private_key_path: str | None = None
|
83
|
+
private_key_passphrase: str | None = None
|
84
|
+
lookups: list[LookupKeyValue] | None = None
|
85
|
+
in_session_auth_bypass: bool | None = None
|
86
|
+
username_pattern: str | None = None
|
87
|
+
password_pattern: str | None = None
|
88
|
+
private_key_passphrase_pattern: str | None = None
|
89
|
+
|
90
|
+
_username: c_char_p | None = field(init=False, default=None, repr=False)
|
91
|
+
_password: c_char_p | None = field(init=False, default=None, repr=False)
|
92
|
+
_private_key_path: c_char_p | None = field(init=False, default=None, repr=False)
|
93
|
+
_private_key_passphrase: c_char_p | None = field(init=False, default=None, repr=False)
|
94
|
+
_username_pattern: c_char_p | None = field(init=False, default=None, repr=False)
|
95
|
+
_password_pattern: c_char_p | None = field(init=False, default=None, repr=False)
|
96
|
+
_private_key_passphrase_pattern: c_char_p | None = field(init=False, default=None, repr=False)
|
97
|
+
|
98
|
+
def apply( # noqa: C901, PLR0912
|
99
|
+
self, ffi_mapping: LibScrapliMapping, ptr: DriverPointer
|
100
|
+
) -> None:
|
101
|
+
"""
|
102
|
+
Applies the options to the given driver pointer.
|
103
|
+
|
104
|
+
Should not be called directly/by users.
|
105
|
+
|
106
|
+
Args:
|
107
|
+
ffi_mapping: the handle to the ffi mapping singleton
|
108
|
+
ptr: the pointer to the underlying cli or netconf object
|
109
|
+
|
110
|
+
Returns:
|
111
|
+
None
|
112
|
+
|
113
|
+
Raises:
|
114
|
+
OptionsException: if any option apply returns a non-zero return code.
|
115
|
+
|
116
|
+
"""
|
117
|
+
if self.username is not None:
|
118
|
+
self._username = to_c_string(self.username)
|
119
|
+
|
120
|
+
status = ffi_mapping.options_mapping.auth.set_username(ptr, self._username)
|
121
|
+
if status != 0:
|
122
|
+
raise OptionsException("failed to set auth username")
|
123
|
+
|
124
|
+
if self.password is not None:
|
125
|
+
self._password = to_c_string(self.password)
|
126
|
+
|
127
|
+
status = ffi_mapping.options_mapping.auth.set_password(ptr, self._password)
|
128
|
+
if status != 0:
|
129
|
+
raise OptionsException("failed to set auth password")
|
130
|
+
|
131
|
+
if self.private_key_path is not None:
|
132
|
+
self._private_key_path = to_c_string(self.private_key_path)
|
133
|
+
|
134
|
+
status = ffi_mapping.options_mapping.auth.set_private_key_path(
|
135
|
+
ptr, self._private_key_path
|
136
|
+
)
|
137
|
+
if status != 0:
|
138
|
+
raise OptionsException("failed to set auth private key path")
|
139
|
+
|
140
|
+
if self.private_key_passphrase is not None:
|
141
|
+
self._private_key_passphrase = to_c_string(self.private_key_passphrase)
|
142
|
+
|
143
|
+
status = ffi_mapping.options_mapping.auth.set_private_key_passphrase(
|
144
|
+
ptr, self._private_key_passphrase
|
145
|
+
)
|
146
|
+
if status != 0:
|
147
|
+
raise OptionsException("failed to set auth private key passphrase")
|
148
|
+
|
149
|
+
if self.lookups is not None:
|
150
|
+
for lookup in self.lookups:
|
151
|
+
status = ffi_mapping.options_mapping.auth.set_lookup_key_value(
|
152
|
+
ptr, *lookup._get_c_strings()
|
153
|
+
)
|
154
|
+
if status != 0:
|
155
|
+
raise OptionsException("failed to set auth lookup key/value")
|
156
|
+
|
157
|
+
if self.in_session_auth_bypass is not None:
|
158
|
+
status = ffi_mapping.options_mapping.auth.set_in_session_auth_bypass(ptr)
|
159
|
+
if status != 0:
|
160
|
+
raise OptionsException("failed to set session in session auth bypass")
|
161
|
+
|
162
|
+
if self.username_pattern is not None:
|
163
|
+
self._username_pattern = to_c_string(self.username_pattern)
|
164
|
+
|
165
|
+
status = ffi_mapping.options_mapping.auth.set_username_pattern(
|
166
|
+
ptr, self._username_pattern
|
167
|
+
)
|
168
|
+
if status != 0:
|
169
|
+
raise OptionsException("failed to set auth username pattern")
|
170
|
+
|
171
|
+
if self.password_pattern is not None:
|
172
|
+
self._password_pattern = to_c_string(self.password_pattern)
|
173
|
+
|
174
|
+
status = ffi_mapping.options_mapping.auth.set_password_pattern(
|
175
|
+
ptr, self._password_pattern
|
176
|
+
)
|
177
|
+
if status != 0:
|
178
|
+
raise OptionsException("failed to set auth password pattern")
|
179
|
+
|
180
|
+
if self.private_key_passphrase_pattern is not None:
|
181
|
+
self._private_key_passphrase_pattern = to_c_string(self.private_key_passphrase_pattern)
|
182
|
+
|
183
|
+
status = ffi_mapping.options_mapping.auth.set_private_key_passphrase_pattern(
|
184
|
+
ptr, self._private_key_passphrase_pattern
|
185
|
+
)
|
186
|
+
if status != 0:
|
187
|
+
raise OptionsException("failed to set auth private key passphrase pattern")
|
188
|
+
|
189
|
+
def __repr__(self) -> str:
|
190
|
+
"""
|
191
|
+
Magic repr method for Options object
|
192
|
+
|
193
|
+
Args:
|
194
|
+
N/A
|
195
|
+
|
196
|
+
Returns:
|
197
|
+
str: repr for Options object
|
198
|
+
|
199
|
+
Raises:
|
200
|
+
N/A
|
201
|
+
|
202
|
+
"""
|
203
|
+
return (
|
204
|
+
# it will probably be "canonical" to import Options as AuthOptions, so we'll make
|
205
|
+
# the repr do that too
|
206
|
+
f"Auth{self.__class__.__name__}("
|
207
|
+
f"username={self.username!r}, "
|
208
|
+
"password=REDACTED, "
|
209
|
+
f"private_key_path={self.private_key_path!r} "
|
210
|
+
f"private_key_passphrase={self.private_key_passphrase!r} "
|
211
|
+
f"lookups={self.lookups!r}) "
|
212
|
+
f"in_session_auth_bypass={self.in_session_auth_bypass!r}) "
|
213
|
+
f"username_pattern={self.username_pattern!r}) "
|
214
|
+
f"password_pattern={self.password_pattern!r}) "
|
215
|
+
f"private_key_passphrase_pattern={self.private_key_passphrase_pattern!r}) "
|
216
|
+
)
|