annet 0.16.23__py3-none-any.whl → 0.16.25__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.

annet/annlib/jsontools.py CHANGED
@@ -4,6 +4,7 @@ import copy
4
4
  import fnmatch
5
5
  import json
6
6
  from collections.abc import Mapping, Sequence
7
+ from operator import itemgetter
7
8
  from typing import Any, Dict, List, Optional
8
9
 
9
10
  import jsonpatch
@@ -73,7 +74,7 @@ def _ensure_pointer_exists(doc: Dict[str, Any], pointer: jsonpointer.JsonPointer
73
74
 
74
75
  def make_patch(old: Dict[str, Any], new: Dict[str, Any]) -> List[Dict[str, Any]]:
75
76
  """Generate a JSON patch by comparing the old document with the new one."""
76
- return jsonpatch.make_patch(old, new).patch
77
+ return sorted(jsonpatch.make_patch(old, new).patch, key=itemgetter("path"))
77
78
 
78
79
 
79
80
  def apply_patch(content: Optional[bytes], patch_bytes: bytes) -> bytes:
annet/api/__init__.py CHANGED
@@ -799,12 +799,20 @@ def guess_hw(config_text: str):
799
799
  hw = hw_provider.vendor_to_hw(vendor)
800
800
  fmtr = tabparser.make_formatter(hw)
801
801
  rb = rulebook.get_rulebook(hw)
802
- config = tabparser.parse_to_tree(config_text, fmtr.split)
802
+ try:
803
+ config = tabparser.parse_to_tree(config_text, fmtr.split)
804
+ except Exception:
805
+ continue
803
806
  pre = patching.make_pre(patching.make_diff({}, config, rb, []))
804
807
  metric = _count_pre_score(pre)
805
808
  scores[metric] = hw
809
+
810
+ if not scores:
811
+ raise RuntimeError("No formatter was guessed")
812
+
806
813
  max_score = max(scores.keys())
807
814
  hw = scores[max_score]
815
+
808
816
  return hw, max_score
809
817
 
810
818
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: annet
3
- Version: 0.16.23
3
+ Version: 0.16.25
4
4
  Summary: annet
5
5
  Home-page: https://github.com/annetutil/annet
6
6
  License: MIT
@@ -46,7 +46,7 @@ annet/annlib/command.py,sha256=uuBddMQphtn8P5MO5kzIa8_QrtMns-k05VeKv1bcAuA,1043
46
46
  annet/annlib/diff.py,sha256=MZ6eQAU3cadQp8KaSE6uAYFtcfMDCIe_eNuVROnYkCk,4496
47
47
  annet/annlib/errors.py,sha256=jBcSFzY6Vj-FxR__vqjFm-87AwYQ0xHuAopTirii5AU,287
48
48
  annet/annlib/filter_acl.py,sha256=0w1VF6WcONiTYTQh0yWi6_j9rCTc_kMLAUMr0hbdkNU,7203
49
- annet/annlib/jsontools.py,sha256=DVmA6kmKGSCsKrFnag4EMR1WKe39Owlvzpfdo726ufk,5471
49
+ annet/annlib/jsontools.py,sha256=BS7s4rI8R9c_y3zz0zYl1l6con65oQ0MvfsC1dsXZts,5535
50
50
  annet/annlib/lib.py,sha256=eJ4hcVuQ6pdYBzLs4YKCHFtq45idOfZCYp92XfF7_QI,15317
51
51
  annet/annlib/output.py,sha256=_SjJ6G6bejvnTKqNHw6xeio0FT9oO3OIkLaOC3cEga4,7569
52
52
  annet/annlib/patching.py,sha256=2CpAT3T43IUFJR57qTYSwjQ0smg0uHWN43df4n1WArs,19937
@@ -67,7 +67,7 @@ annet/annlib/rbparser/platform.py,sha256=hnxznTfV9txXi1PkR1hZrprTrQJvlwgqXVL8vXk
67
67
  annet/annlib/rbparser/syntax.py,sha256=iZ7Y-4QQBw4L3UtjEh54qisiRDhobl7HZxFNdP8mi54,3577
68
68
  annet/annlib/rulebook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
69
69
  annet/annlib/rulebook/common.py,sha256=bx_Iwui-JJeyctUPF1OsEll0Aa-IQZadBPQjaeuoWgw,16638
70
- annet/api/__init__.py,sha256=7EB3d89kGXKf4Huw7cqyOULTGC9ydL4sHiVw8K0Aeqg,33722
70
+ annet/api/__init__.py,sha256=dgdyBDeFhBVBwKB8QVOOTZ2LZvi0fEcVGfOQEUQyDHo,33863
71
71
  annet/configs/context.yml,sha256=RVLrKLIHpCty7AGwOnmqf7Uu0iZQCn-AjYhophDJer8,259
72
72
  annet/configs/logging.yaml,sha256=EUagfir99QqA73Scc3k7sfQccbU3E1SvEQdyhLFtCl4,997
73
73
  annet/generators/__init__.py,sha256=rVHHDTPKHPZsml1eNEAj3o-8RweFTN8J7LX3tKMXdIY,16402
@@ -164,10 +164,10 @@ annet_generators/rpl_example/__init__.py,sha256=z4-gsDv06BBpgTwRohc50VBQYFD26QVu
164
164
  annet_generators/rpl_example/items.py,sha256=6x7b0wZ7Vjn6yCaJ-aGbpTHm7fyqO77b-LRqzzhEbh4,615
165
165
  annet_generators/rpl_example/policy_generator.py,sha256=KFCqn347CIPcnllOHfINYeKgNSr6Wl-bdM5Xj_YKhYM,11183
166
166
  annet_generators/rpl_example/route_policy.py,sha256=QjxFjkePHfTo2CpMeRVaDqZXNXLM-gGlE8EocHuOR4Y,1189
167
- annet-0.16.23.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
168
- annet-0.16.23.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
169
- annet-0.16.23.dist-info/METADATA,sha256=1zBWYojg8yokwhWjMABjKBWyYng1OdNsZZ4G4b2rXH0,728
170
- annet-0.16.23.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
171
- annet-0.16.23.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
172
- annet-0.16.23.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
173
- annet-0.16.23.dist-info/RECORD,,
167
+ annet-0.16.25.dist-info/AUTHORS,sha256=rh3w5P6gEgqmuC-bw-HB68vBCr-yIBFhVL0PG4hguLs,878
168
+ annet-0.16.25.dist-info/LICENSE,sha256=yPxl7dno02Pw7gAcFPIFONzx_gapwDoPXsIsh6Y7lC0,1079
169
+ annet-0.16.25.dist-info/METADATA,sha256=uhwaIv4HybNV5NDUTlXoDfRE1Ynbd96MaHfLh6rMojQ,728
170
+ annet-0.16.25.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
171
+ annet-0.16.25.dist-info/entry_points.txt,sha256=5lIaDGlGi3l6QQ2ry2jZaqViP5Lvt8AmsegdD0Uznck,192
172
+ annet-0.16.25.dist-info/top_level.txt,sha256=QsoTZBsUtwp_FEcmRwuN8QITBmLOZFqjssRfKilGbP8,23
173
+ annet-0.16.25.dist-info/RECORD,,