scrapli 2.0.0a2__py3-none-macosx_11_0_arm64.whl → 2.0.0a4__py3-none-macosx_11_0_arm64.whl

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/transport.py CHANGED
@@ -1,5 +1,6 @@
1
1
  """scrapli.transport"""
2
2
 
3
+ from abc import ABC, abstractmethod
3
4
  from ctypes import c_char_p, c_int
4
5
  from dataclasses import dataclass, field
5
6
  from enum import Enum
@@ -33,8 +34,74 @@ class TransportKind(str, Enum):
33
34
  TEST = "test_"
34
35
 
35
36
 
37
+ class Options(ABC):
38
+ """
39
+ Options is the base class for transport related option containers.
40
+
41
+ Args:
42
+ N/A
43
+
44
+ Returns:
45
+ None
46
+
47
+ Raises:
48
+ N/A
49
+
50
+ """
51
+
52
+ _transport_kind: TransportKind | None = None
53
+
54
+ @property
55
+ def transport_kind(self) -> TransportKind:
56
+ """
57
+ Returns/sets the encoded name of the selected transport kind
58
+
59
+ Should not be called directly/by users.
60
+
61
+ Args:
62
+ N/A
63
+
64
+ Returns:
65
+ TransportKind: the selected transport kind
66
+
67
+ Raises:
68
+ OptionsException: if any option apply returns a non-zero return code.
69
+
70
+ """
71
+ if isinstance(self, BinOptions):
72
+ self._transport_kind = TransportKind.BIN
73
+ elif isinstance(self, Ssh2Options):
74
+ self._transport_kind = TransportKind.SSH2
75
+ elif isinstance(self, TelnetOptions):
76
+ self._transport_kind = TransportKind.TELNET
77
+ else:
78
+ self._transport_kind = TransportKind.TEST
79
+
80
+ return self._transport_kind
81
+
82
+ @abstractmethod
83
+ def apply(self, ffi_mapping: LibScrapliMapping, ptr: DriverPointer) -> None:
84
+ """
85
+ Applies the options to the given driver pointer.
86
+
87
+ Should not be called directly/by users.
88
+
89
+ Args:
90
+ ffi_mapping: the handle to the ffi mapping singleton
91
+ ptr: the pointer to the underlying cli or netconf object
92
+
93
+ Returns:
94
+ None
95
+
96
+ Raises:
97
+ OptionsException: if any option apply returns a non-zero return code.
98
+
99
+ """
100
+ raise NotImplementedError
101
+
102
+
36
103
  @dataclass
37
- class BinOptions:
104
+ class BinOptions(Options):
38
105
  """
39
106
  Options holds bin transport options to pass to the ffi layer.
40
107
 
@@ -154,7 +221,7 @@ class BinOptions:
154
221
 
155
222
 
156
223
  @dataclass
157
- class Ssh2Options:
224
+ class Ssh2Options(Options):
158
225
  """
159
226
  Options holds ssh2 transport options to pass to the ffi layer.
160
227
 
@@ -195,7 +262,7 @@ class Ssh2Options:
195
262
 
196
263
 
197
264
  @dataclass
198
- class TelnetOptions:
265
+ class TelnetOptions(Options):
199
266
  """
200
267
  Options holds telnet transport options to pass to the ffi layer.
201
268
 
@@ -231,7 +298,7 @@ class TelnetOptions:
231
298
 
232
299
 
233
300
  @dataclass
234
- class TestOptions:
301
+ class TestOptions(Options):
235
302
  """
236
303
  Options holds test transport options to pass to the ffi layer.
237
304
 
@@ -273,129 +340,3 @@ class TestOptions:
273
340
  status = ffi_mapping.options_mapping.transport_test.set_f(ptr, self._f)
274
341
  if status != 0:
275
342
  raise OptionsException("failed to set test transport f")
276
-
277
-
278
- @dataclass
279
- class Options:
280
- """
281
- Options holds transport options to pass to the ffi layer.
282
-
283
- Only one flavor of transport options can be set at a time. The active option determines the
284
- transport to be used for the connection.
285
-
286
- Args:
287
- bin: the bin transport options
288
- ssh2: the ssh2 transport options
289
- telnet: the telnet transport options
290
- test: the test transport options
291
-
292
- Returns:
293
- None
294
-
295
- Raises:
296
- N/A
297
-
298
- """
299
-
300
- bin: BinOptions | None = None
301
- ssh2: Ssh2Options | None = None
302
- telnet: TelnetOptions | None = None
303
- test: TestOptions | None = None
304
-
305
- _transport_kind: bytes | None = field(init=False, default=None, repr=False)
306
-
307
- def __post_init__(self) -> None:
308
- _set_fields = [f for f in [self.bin, self.ssh2, self.telnet, self.test] if f is not None]
309
-
310
- if len(_set_fields) == 0:
311
- self.bin = BinOptions()
312
-
313
- return
314
-
315
- if len(_set_fields) == 1:
316
- return
317
-
318
- raise OptionsException("more than one transport set")
319
-
320
- def apply(self, ffi_mapping: LibScrapliMapping, ptr: DriverPointer) -> None:
321
- """
322
- Applies the options to the given driver pointer.
323
-
324
- Should not be called directly/by users.
325
-
326
- Args:
327
- ffi_mapping: the handle to the ffi mapping singleton
328
- ptr: the pointer to the underlying cli or netconf object
329
-
330
- Returns:
331
- None
332
-
333
- Raises:
334
- OptionsException: if any option apply returns a non-zero return code.
335
-
336
- """
337
- if self.bin:
338
- self.bin.apply(ffi_mapping, ptr)
339
- elif self.ssh2:
340
- self.ssh2.apply(ffi_mapping, ptr)
341
- elif self.telnet:
342
- self.telnet.apply(ffi_mapping, ptr)
343
- elif self.test:
344
- self.test.apply(ffi_mapping, ptr)
345
-
346
- def get_transport_kind(self) -> bytes:
347
- """
348
- Returns the encoded name of the selected transport kind
349
-
350
- Should not be called directly/by users.
351
-
352
- Args:
353
- N/A
354
-
355
- Returns:
356
- bytes: the encoded name of the selected transport kind
357
-
358
- Raises:
359
- OptionsException: if any option apply returns a non-zero return code.
360
-
361
- """
362
- if self.bin:
363
- self._transport_kind = TransportKind.BIN.encode(encoding="utf-8")
364
- elif self.ssh2:
365
- self._transport_kind = TransportKind.SSH2.encode(encoding="utf-8")
366
- elif self.telnet:
367
- self._transport_kind = TransportKind.TELNET.encode(encoding="utf-8")
368
- else:
369
- self._transport_kind = TransportKind.TEST.encode(encoding="utf-8")
370
-
371
- return self._transport_kind
372
-
373
- def __repr__(self) -> str:
374
- """
375
- Magic repr method for Options object
376
-
377
- Args:
378
- N/A
379
-
380
- Returns:
381
- str: repr for Options object
382
-
383
- Raises:
384
- N/A
385
-
386
- """
387
- if self.bin:
388
- return (
389
- # it will probably be "canonical" to import Options as SessionOptions, so we'll make
390
- # the repr do that too
391
- f"Transport{self.__class__.__name__}("
392
- f"bin={self.bin!r}, "
393
- )
394
-
395
- if self.ssh2:
396
- return f"Transport{self.__class__.__name__}(" f"ssh2={self.ssh2!r}, "
397
-
398
- if self.telnet:
399
- return f"Transport{self.__class__.__name__}(" f"telnet={self.telnet!r}, "
400
-
401
- return f"Transport{self.__class__.__name__}(" f"test={self.test!r}, "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapli
3
- Version: 2.0.0a2
3
+ Version: 2.0.0a4
4
4
  Summary: Fast, flexible, sync/async, Python 3.10+ screen scraping client specifically for network devices
5
5
  Author-email: Carl Montanari <carl.r.montanari@gmail.com>
6
6
  License-Expression: MIT
@@ -1,23 +1,23 @@
1
- scrapli/__init__.py,sha256=qcOX4L_nCkch_3r5etnPI3XlktJTdsqBHyBuJhNBdPk,929
1
+ scrapli/__init__.py,sha256=8EEtOO1ZjuAWHUnHduW-hL7Rvvxh1Omns3f9TtU9bpE,963
2
2
  scrapli/auth.py,sha256=LMYD31AMK0pyTa0RQo9I3ap3F1onmDylb2zQsHl6zrw,7907
3
- scrapli/cli.py,sha256=-WzN7uHnkgmmH6vdINp9Tr5rVAmoecSqvvpiWxY5dog,48186
3
+ scrapli/cli.py,sha256=6tHDilvmYW1DxAJyXNa65zQZRxlDBL9Z4zeCR6GOcyU,46942
4
4
  scrapli/cli_decorators.py,sha256=Mj1BfouFiAWb2bbVvhBgc9qqJou6mf-ClvK3Ngy1dJA,4412
5
5
  scrapli/cli_parse.py,sha256=b9l2w7TSKpHwNGumCsENvRO1R4NMKnOe5v2vfrweTUA,5171
6
6
  scrapli/cli_result.py,sha256=YkgAJ4LiEOiC46376EZjbRqoZzERyVmtwbU8VQ7Nl84,4914
7
7
  scrapli/exceptions.py,sha256=RNU720WL6efW_4Pdjruzp0M-Se-zQR3mFcsrzscvaPA,1524
8
- scrapli/ffi.py,sha256=QgPj1OK8t2swrt_T1nwRHR92DTwhBC_E4r5s6wOCHTI,2149
9
- scrapli/ffi_mapping.py,sha256=7tnL1mwBYc1dlSH6l2YG_a_5_6BaXmFZiMY1SkE9nOw,5017
10
- scrapli/ffi_mapping_cli.py,sha256=lIy4mD5MH0DT2fxgDH0WAG5zlsK5UXrzDh817q2VQRY,18503
11
- scrapli/ffi_mapping_netconf.py,sha256=zPciAB6gP_Zy8d6pwW6MnrSvrp0i5fg4HKgQ_PHqggg,44314
8
+ scrapli/ffi.py,sha256=ao0D9NZLo1zv6r9-z06hAiNgch_2QV6XYyIfBfawMOI,2149
9
+ scrapli/ffi_mapping.py,sha256=bMB6XkJimV9xZ83jg01m2jWZevwCaRf-0LGxaYct_54,4994
10
+ scrapli/ffi_mapping_cli.py,sha256=4m_e4WoLlgr3s_2aS-N92HrFEvRHz_eMrlorNW_x6xk,18218
11
+ scrapli/ffi_mapping_netconf.py,sha256=G7VmR-pIQI5G4SEkDYoAtDVa_pfDaTRM2U9chfXhqaY,42156
12
12
  scrapli/ffi_mapping_options.py,sha256=X2Y-B_K1e2f7aSbJ5pNktT3X7tDpdu_RZ1TX-ba75nI,27557
13
- scrapli/ffi_types.py,sha256=ZG9LqeNQ34FR4KGCEj4S0Al9qEMCIc8306Xfe8YTOUk,3230
13
+ scrapli/ffi_types.py,sha256=aYZ0YTUyU_jgowrQgwBTm_iL4A6BMLl8-hMf1P8-9b4,4501
14
14
  scrapli/helper.py,sha256=hiVHcczqFqhF0qAyiBn0mioL_fsI2pszCoM9VS_KYsw,1628
15
- scrapli/netconf.py,sha256=rf0YpTCZLVYkx3DZY2lCPg3dKZ_lgUG_JtfSfF2ts1Q,83819
15
+ scrapli/netconf.py,sha256=T_Op82Qjo5P3WCb-OMOiAYqgu82oqzuymet4AmGFUD0,80054
16
16
  scrapli/netconf_decorators.py,sha256=C5yk5Gq7OD_V1g6rVOi8qzeA5MQHEI3B2IUXxyj0IIU,4464
17
17
  scrapli/netconf_result.py,sha256=JHvNa5KX6gEf5iwJxCc9Hlcg5ljhRWkd0aoGaXAtYPw,1174
18
18
  scrapli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  scrapli/session.py,sha256=8f3XvpZ-4-uw4uuRBVtQMbo8Ftzwu99uCwDL9_UQkO8,4275
20
- scrapli/transport.py,sha256=v_S4td5kezlUwqANwZh5pQhxgW2jEPCvCe97C8e0fmA,11313
20
+ scrapli/transport.py,sha256=vg6uMpsXrx6kOyNxnyg0OZ74w2U9rj1aPk0oz__2D0c,9506
21
21
  scrapli/definitions/__init__.py,sha256=d-XZBK_ZjN4Sy6SmhJL-T4imYY_UioM8gSiX-PKVDuE,26
22
22
  scrapli/definitions/arista_eos.yaml,sha256=ZR3BmdmGScJobQQZfW7gwOLj5wGxdpZ1omgraw9KgCc,1714
23
23
  scrapli/definitions/cisco_iosxe.yaml,sha256=nnqi8qQmFmKX4BgnuLMJqj0hAyqkVRmSfmDLsJKBFaA,1699
@@ -26,9 +26,9 @@ scrapli/definitions/cisco_nxos.yaml,sha256=ih_FiqkBJk3pgGou29DGN0tjrdkF_qqH5bJOa
26
26
  scrapli/definitions/juniper_junos.yaml,sha256=bWErL-XgxwwnZv4R9MsSZFLla0VnVhrHqDQ3pZJ9-1I,2491
27
27
  scrapli/definitions/nokia_srlinux.yaml,sha256=2TrpoVCIwi-E_IzTsuQjmKBR4lSz_24c2mhhwv6e1ec,1042
28
28
  scrapli/lib/__init__.py,sha256=emX2ZjmnwMNIozlcKNDDXr_4zlryoLD8h2fM-CO3KZY,18
29
- scrapli/lib/libscrapli.0.0.1-alpha.10.dylib,sha256=-oOvGZigabVog8nUl9dajxGR8JqW1ZWHAJj-spKErVM,12922712
30
- scrapli-2.0.0a2.dist-info/licenses/LICENSE,sha256=IeyhkG2h_dAvJ7nAF0S4GSUg045jwI27YADV_KSJi50,1071
31
- scrapli-2.0.0a2.dist-info/METADATA,sha256=LIVee3xM1hOhkQb4R7JB0adJsPeRD0E5oJFwWWDmtJs,2286
32
- scrapli-2.0.0a2.dist-info/WHEEL,sha256=jc2C2uw104ioj1TL9cE0YO67_kdAwX4W8JgYPomxr5M,105
33
- scrapli-2.0.0a2.dist-info/top_level.txt,sha256=piC9TaaPt0z-1Ryrs69hDvsIQkmE5ceDAAW5donUvsI,8
34
- scrapli-2.0.0a2.dist-info/RECORD,,
29
+ scrapli/lib/libscrapli.0.0.1-alpha.13.dylib,sha256=r6iXD-yJZSNRfh0Ga4mhTdbtJde93auDJFA1HZ6KJwQ,5484120
30
+ scrapli-2.0.0a4.dist-info/licenses/LICENSE,sha256=IeyhkG2h_dAvJ7nAF0S4GSUg045jwI27YADV_KSJi50,1071
31
+ scrapli-2.0.0a4.dist-info/METADATA,sha256=-h27C1hAYIbru9lW7bSHBSJTjXOxYmGtq2KyNDamlUk,2286
32
+ scrapli-2.0.0a4.dist-info/WHEEL,sha256=jc2C2uw104ioj1TL9cE0YO67_kdAwX4W8JgYPomxr5M,105
33
+ scrapli-2.0.0a4.dist-info/top_level.txt,sha256=piC9TaaPt0z-1Ryrs69hDvsIQkmE5ceDAAW5donUvsI,8
34
+ scrapli-2.0.0a4.dist-info/RECORD,,
Binary file