annet 3.14.3__py3-none-any.whl → 3.15.0__py3-none-any.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.

Potentially problematic release.


This version of annet might be problematic. Click here for more details.

@@ -143,6 +143,14 @@
143
143
  "PC.Whitebox.Ufispace.S.S9300": " S93\\d\\d",
144
144
  "PC.Whitebox.Ufispace.S.S9300.S9301_32DB": " S9301-32DB",
145
145
  "PC.Whitebox.Ufispace.S.S9300.S9321_64EO": " S9321-64EO",
146
+ "PC.Whitebox.NADDOD": "NADDOD",
147
+ "PC.Whitebox.NADDOD.N": " N",
148
+ "PC.Whitebox.NADDOD.N.N9500": " N95\\d\\d",
149
+ "PC.Whitebox.NADDOD.N.N9500.N9500_64OC": " N9500-64OC",
150
+ "PC.Whitebox.FSCOM": "FSCOM",
151
+ "PC.Whitebox.FSCOM.N": " N",
152
+ "PC.Whitebox.FSCOM.N.N9600": " N96\\d\\d",
153
+ "PC.Whitebox.FSCOM.N.N9600.N9600_64OD": " N9600-64OD",
146
154
  "PC.Nebius": "^Nebius",
147
155
  "PC.Nebius.Octoport": " NB-D-M-CSM-R",
148
156
  "PC.Avocent": " [Aa]vocent",
@@ -52,13 +52,14 @@ def _parse_tree_with_params(raw_tree, scheme, context=None):
52
52
  for (raw_rule, children) in raw_tree.items():
53
53
  (row, params) = _parse_raw_rule(raw_rule, scheme)
54
54
  row_type = "normal"
55
+
55
56
  if row.startswith("!"):
56
57
  row = row[1:].strip()
57
58
  if len(row) == 0:
58
59
  continue
59
60
  row_type = "ignore"
60
- elif row.startswith(r"%context="):
61
- context = _parse_context(context, row)
61
+ elif context_raw := params.get("context"):
62
+ context = _parse_context(context, context_raw)
62
63
  continue
63
64
  tree[raw_rule] = {
64
65
  "row": row,
@@ -75,8 +76,8 @@ def _parse_raw_rule(raw_rule, scheme):
75
76
  try:
76
77
  index = raw_rule.index("%")
77
78
  params = {
78
- key: (value if len(value) != 0 else "1")
79
- for (key, value) in re.findall(r"\s%([a-zA-Z_]\w*)(?:=([^\s]*))?", raw_rule)
79
+ key: (value.strip() if len(value.strip()) != 0 else "1")
80
+ for (key, value) in re.findall(r"%([a-zA-Z_]\w*)(?:=([^%]*))?", raw_rule[index:])
80
81
  }
81
82
  if params:
82
83
  raw_rule = raw_rule[:index].strip()
@@ -85,7 +86,7 @@ def _parse_raw_rule(raw_rule, scheme):
85
86
 
86
87
  row = re.sub(r"\s+", " ", raw_rule.strip())
87
88
  params = _fill_and_validate(params, scheme, raw_rule)
88
- return (row, params)
89
+ return row, params
89
90
 
90
91
 
91
92
  def _fill_and_validate(params, scheme, raw_rule):
@@ -109,8 +110,5 @@ def match_context(ifcontext, context):
109
110
 
110
111
 
111
112
  def _parse_context(context, row):
112
- keyword = r"%context="
113
- if not row.startswith(keyword):
114
- raise ValueError(row)
115
- name, value = row[len(keyword):].strip().split(":")
113
+ name, value = row.strip().split(":")
116
114
  return lib.merge_dicts(context, {name: value})
annet/implicit.py CHANGED
@@ -25,7 +25,7 @@ def compile_tree(tree):
25
25
  rule = {
26
26
  "type": attrs["type"],
27
27
  "children": compile_tree(attrs["children"]) if attrs.get("children") else odict(),
28
- "regexp": syntax.compile_row_regexp(attrs["row"]),
28
+ "regexp": attrs["params"]["regexp"] or syntax.compile_row_regexp(attrs["row"]),
29
29
  }
30
30
  rules[attrs["row"]] = rule
31
31
  return rules
@@ -66,13 +66,14 @@ def _implicit_tree(device):
66
66
  elif device.hw.Huawei.Quidway.S5700.S5735I:
67
67
  text = """
68
68
  !interface *
69
- !port link-type access
69
+ port link-type access %regexp=port link-type .*
70
70
  interface NULL0
71
71
  """
72
72
  elif device.hw.Huawei.Quidway.S2x:
73
73
  text = """
74
74
  !interface *
75
- !port link-type hybrid
75
+ port link-type hybrid %regexp=port link-type .*
76
+ dot1x enable
76
77
  interface NULL0
77
78
  """
78
79
  else:
@@ -179,8 +180,14 @@ def _implicit_tree(device):
179
180
  system mtu routing 1500
180
181
  system mtu jumbo 9000
181
182
  """
183
+
182
184
  return parse_text(text)
183
185
 
184
186
 
185
187
  def parse_text(text):
186
- return syntax.parse_text(text, {})
188
+ return syntax.parse_text(text, {
189
+ "regexp": {
190
+ "default": None,
191
+ "validator": lambda x: syntax.compile_row_regexp(x),
192
+ },
193
+ })
@@ -18,7 +18,6 @@ MULTILINE_DIFF_LOGIC = "common.multiline_diff"
18
18
  # =====
19
19
  @functools.lru_cache()
20
20
  def compile_patching_text(text, vendor):
21
-
22
21
  return _compile_patching(
23
22
  tree=syntax.parse_text(text, params_scheme={
24
23
  "global": {
@@ -45,6 +44,10 @@ def compile_patching_text(text, vendor):
45
44
  "validator": valid_bool,
46
45
  "default": False,
47
46
  },
47
+ "context": {
48
+ "validator": str,
49
+ "default": None,
50
+ },
48
51
  "rewrite": {
49
52
  "validator": valid_bool,
50
53
  "default": False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: annet
3
- Version: 3.14.3
3
+ Version: 3.15.0
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -11,7 +11,7 @@ annet/diff.py,sha256=kD_2kxz5wc2TP10xj-BHs6IPq1yNKkXxIco8czjeC6M,9497
11
11
  annet/filtering.py,sha256=ZtqxPsKdV9reZoRxtQyBg22BqyMqd-2SotYcxZ-68AQ,903
12
12
  annet/gen.py,sha256=y9e7P551uJ-thjBS2p-ZRMgwQa8kPF_JAoEXJ3am77Y,30683
13
13
  annet/hardware.py,sha256=O2uadehcavZ10ssPr-db3XYHK8cpbG7C7XFkO-I6r_s,1161
14
- annet/implicit.py,sha256=SkACAc32eUGJSHfUIDL3cWoBguST42-HJDzScJuvJIc,6626
14
+ annet/implicit.py,sha256=K6vuX0Y7nR1FWP_pJV33R9AiHhQARkvpa2Pu-KTg1u0,6869
15
15
  annet/lib.py,sha256=4N4X6jCCrig5rk7Ua4AofrV9zK9jhzkBq57fLsfBJjw,4812
16
16
  annet/output.py,sha256=se8EpyNS9f9kPOlOaAV0ht4DjzDoBr8F2UafiezLPYw,7743
17
17
  annet/parallel.py,sha256=yM53RYaSpbIOUuBx4y07B_3jW8J-w3taiZWjcq_1r6A,17397
@@ -63,7 +63,7 @@ annet/annlib/types.py,sha256=VHU0CBADfYmO0xzB_c5f-mcuU3dUumuJczQnqGlib9M,852
63
63
  annet/annlib/netdev/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
64
  annet/annlib/netdev/db.py,sha256=fI_u5aya4l61mbYSjj4JwlVfi3s7obt2jqERSuXGRUI,1634
65
65
  annet/annlib/netdev/devdb/__init__.py,sha256=I-NKzenyjsmUKpmIerQOfZExnnnDpPdNZLdRanyu-Nk,1020
66
- annet/annlib/netdev/devdb/data/devdb.json,sha256=ptegQaH_HxmAEePlMx52GaiobM2xp1RXEJcvR7IAHGY,7174
66
+ annet/annlib/netdev/devdb/data/devdb.json,sha256=6XuEDvL97_q9_i6mh4HNMtvjz5tKCiWPjDKjbgZZsoc,7525
67
67
  annet/annlib/netdev/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
68
  annet/annlib/netdev/views/dump.py,sha256=rIlyvnA3uM8bB_7oq1nS2KDxTp6dQh2hz-FbNhYIpOU,4630
69
69
  annet/annlib/netdev/views/hardware.py,sha256=XvHtRn29SROKtxqMyr86oc1ItUKy36N98ppfuJQL8PY,3235
@@ -72,7 +72,7 @@ annet/annlib/rbparser/acl.py,sha256=I_1VUZQgF-s4dYTxyEDxQ-GkAP2MeXonzzsc2xROpTM,
72
72
  annet/annlib/rbparser/deploying.py,sha256=ACT8QNhDAhJx3ZKuGh2nYBOrpdka2qEKuLDxvQAGKLk,1649
73
73
  annet/annlib/rbparser/ordering.py,sha256=XknggB92N4IbhHBZZHL0StwCCITt8mkho4D4Nu5Kb4k,2185
74
74
  annet/annlib/rbparser/platform.py,sha256=d1jFH8hGMOf_qiveKE4H-c0OfNnzwmt2VYpSiSOn9qc,42
75
- annet/annlib/rbparser/syntax.py,sha256=PlKyWqS3zwPwumILmKIci-DmEAbfZp8YycpW1mNqADM,3602
75
+ annet/annlib/rbparser/syntax.py,sha256=Q-AIjoRnM54pNLKknAxmGdXLg5vpikh6Lal-J330TjY,3530
76
76
  annet/annlib/rulebook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
77
  annet/annlib/rulebook/common.py,sha256=6A3sOkOanDRTuR7F426zakShGaGKRBmBLDCnqBbBJr8,13531
78
78
  annet/api/__init__.py,sha256=5YzScmeCDsHiDhtT3RwY_lMuikRZ6o7CVrlnJCln2A8,34116
@@ -118,7 +118,7 @@ annet/rpl_generators/rd.py,sha256=mw5-ictMdCQbkFcMi4R8iKqwmOp52Y9HnQuEitT6yrc,26
118
118
  annet/rulebook/__init__.py,sha256=AmcqrLYaoU1-sO2vmtjWZbzsZ44_w7nXncoEVa_hpyk,3997
119
119
  annet/rulebook/common.py,sha256=zK1s2c5lc5HQbIlMUQ4HARQudXSgOYiZ_Sxc2I_tHqg,721
120
120
  annet/rulebook/deploying.py,sha256=9CMeOUw5L1OWdrccSRfpJyH9H_jH7xWNU1JldviBNrk,3015
121
- annet/rulebook/patching.py,sha256=7iZvtjR7T8_bK6mCsGlC5uPmntCDQ9OkkDHRWupnMNA,5045
121
+ annet/rulebook/patching.py,sha256=BrA6i2LeJm89Q0esKerPjA7cW__jou26HLlFCJ8E_0w,5151
122
122
  annet/rulebook/arista/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
123
  annet/rulebook/arista/aaa.py,sha256=7fBTwBnz9SOqYbwG8GBeEQTJG0e4uC4HkuZJeMG-kAY,2250
124
124
  annet/rulebook/arista/iface.py,sha256=bgj6a3r__-OE6VyYbSfnD6ps2QJKyX028W7IFJww-UY,720
@@ -199,8 +199,8 @@ annet/vendors/library/optixtrans.py,sha256=VdME69Ca4HAEgoaKN21fZxnmmsqqaxOe_HZja
199
199
  annet/vendors/library/pc.py,sha256=vfv31_NPi7M-4AUDL89UcpawK2E6xvCpELA209cd1ho,1086
200
200
  annet/vendors/library/ribbon.py,sha256=DDOBq-_-FL9dCxqXs2inEWZ-pvw-dJ-A-prA7cKMhec,1216
201
201
  annet/vendors/library/routeros.py,sha256=iQa7m_4wjuvcgBOI9gyZwlw1BvzJfOkvUbyoEk-NI9I,1254
202
- annet-3.14.3.dist-info/licenses/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
203
- annet-3.14.3.dist-info/licenses/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
202
+ annet-3.15.0.dist-info/licenses/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
203
+ annet-3.15.0.dist-info/licenses/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
204
204
  annet_generators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
205
205
  annet_generators/example/__init__.py,sha256=OJ77uj8axc-FIyIu_Xdcnzmde3oQW5mk5qbODkhuVc8,355
206
206
  annet_generators/example/hostname.py,sha256=RloLzNVetEoWPLITzfJ13Nk3CC0yi-cZB1RTd6dnuhI,2541
@@ -213,8 +213,8 @@ annet_generators/rpl_example/generator.py,sha256=EWah19gOH8G-QyNyWqxCqdRi0BK7GbM
213
213
  annet_generators/rpl_example/items.py,sha256=HPgxScDvSqJPdz0c2SppDrH82DZYC4zUaniQwcWmh4A,1176
214
214
  annet_generators/rpl_example/mesh.py,sha256=z_WgfDZZ4xnyh3cSf75igyH09hGvtexEVwy1gCD_DzA,288
215
215
  annet_generators/rpl_example/route_policy.py,sha256=z6nPb0VDeQtKD1NIg9sFvmUxBD5tVs2frfNIuKdM-5c,2318
216
- annet-3.14.3.dist-info/METADATA,sha256=oOmmrA_5GQH9B_GK2zSet72zauJiZs47naDVeX7JwIQ,816
217
- annet-3.14.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
218
- annet-3.14.3.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
219
- annet-3.14.3.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
220
- annet-3.14.3.dist-info/RECORD,,
216
+ annet-3.15.0.dist-info/METADATA,sha256=wge239q2HwJbhQ3Ril7PHaryvJgliyiz8O9FCLSbbQ0,816
217
+ annet-3.15.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
218
+ annet-3.15.0.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
219
+ annet-3.15.0.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
220
+ annet-3.15.0.dist-info/RECORD,,
File without changes