netbox-device-view 0.1.11__py3-none-any.whl → 0.1.13__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.
@@ -10,25 +10,18 @@ def process_interfaces(interfaces, ports_chassis, dev):
10
10
  for itf in interfaces:
11
11
  if itf.type == "virtual" or itf.type == "lag":
12
12
  continue
13
- # Convert to lowercase and replace common separators with hyphens
14
- # This replaces the original regex matching and if/else block
15
- stylename = re.sub(r"[/\.\s\+]+", "-", itf.name.lower())
16
-
17
- # Clean up multiple hyphens and leading/trailing hyphens
18
- stylename = re.sub(r"-+", "-", stylename).strip("-")
19
-
20
- # If the name becomes empty after cleaning, use a fallback
21
- if not stylename:
22
- stylename = f"iface-{itf.pk}" # Use a unique fallback
23
-
24
- # Assign the generated stylename back to the object property
25
- itf.stylename = stylename
26
-
27
- # Check if the stylename exists and starts with a digit or a hyphen
28
- # This replaces the original 'if itf.stylename.isdigit():' line
29
- if itf.stylename and (
30
- itf.stylename[0].isdigit() or itf.stylename[0] == "-"
31
- ):
13
+ regex = r"^(?P<type>([a-zA-Z\-_]*))(\/|(?P<dev>[0-9]+).|\s)?((?P<module>[0-9]+).|\s)?((?P<port>[0-9]+))$"
14
+ matches = re.search(regex, itf.name.lower())
15
+ if matches:
16
+ itf.stylename = (
17
+ (matches["type"] or "")
18
+ + (matches["module"] or "")
19
+ + "-"
20
+ + matches["port"]
21
+ )
22
+ else:
23
+ itf.stylename = re.sub(r"[^.a-zA-Z\d]", "-", itf.name.lower())
24
+ if itf.stylename.isdigit():
32
25
  itf.stylename = f"p{itf.stylename}"
33
26
 
34
27
  if dev not in ports_chassis:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: netbox-device-view
3
- Version: 0.1.11
3
+ Version: 0.1.13
4
4
  Summary: NetBox Device View plugin
5
5
  Home-page: https://github.com/peterbaumert/netbox-device-view
6
6
  Author: Peter Baumert
@@ -6,7 +6,7 @@ netbox_device_view/navigation.py,sha256=EbmAxA0a8y47jbf8XjRQvz_xAvoTwTHI9ljvC6oa
6
6
  netbox_device_view/tables.py,sha256=ejhKjD5fGo_tLUhTExqBhDL_TbYVe9TPnzF-ZWHqujY,351
7
7
  netbox_device_view/template_content.py,sha256=k9spY-bv_ArmRUYqyhpKtOv-MvU3NtFXVN7eWNdU0dg,1162
8
8
  netbox_device_view/urls.py,sha256=DtdIPVagp1KHwPDSlBsV_rJ16pGNi8l661RkXTq32HU,971
9
- netbox_device_view/utils.py,sha256=pgqBmH_9AZLjlRXJS9yHazcb2KrPGM-m3fF7Z_IgWjc,3582
9
+ netbox_device_view/utils.py,sha256=yD91QIXvNlUBA4lV7Q_qqAoTpF69nIRf4YVZu8Iw4ac,3208
10
10
  netbox_device_view/views.py,sha256=hyz6xOt0l3l2Kh0cf-TTG84JfF810ts9_SL3SsRpbGM,2020
11
11
  netbox_device_view/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  netbox_device_view/api/serializers.py,sha256=IQEFuIh7X22MWO4jxv4MctZQxln-DgH2eo-0IbdvBl4,456
@@ -17,7 +17,7 @@ netbox_device_view/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
17
17
  netbox_device_view/static/netbox_device_view/css/device_view.css,sha256=VnvjTMPrEnUkpb_odDe6-VJKhBXZ6RuII4Ce3EnPDCc,833
18
18
  netbox_device_view/templates/netbox_device_view/deviceview.html,sha256=gnHwrEhsIHQ5Mv8KjIgUVa65rmfMy7_hLx-wgjHV6-c,2874
19
19
  netbox_device_view/templates/netbox_device_view/ports.html,sha256=H-OVDZfpa-s3NB5a3ZJmrNbir001wfYfKJss8bppBgk,1716
20
- netbox_device_view-0.1.11.dist-info/METADATA,sha256=b-UIBr-1Jr6QdSU0cz1rzTo_eBPAUGSFp5MaykSdNtU,3899
21
- netbox_device_view-0.1.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
22
- netbox_device_view-0.1.11.dist-info/top_level.txt,sha256=Cj7X6_XpLT0jnyTyX5DMqttqc8_z3uhRYCmvnXLfWOs,19
23
- netbox_device_view-0.1.11.dist-info/RECORD,,
20
+ netbox_device_view-0.1.13.dist-info/METADATA,sha256=qGL4ONJMnKgNNV0bBFcelLUxzyIhe5ba-Y8JjlaH8Do,3899
21
+ netbox_device_view-0.1.13.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
22
+ netbox_device_view-0.1.13.dist-info/top_level.txt,sha256=Cj7X6_XpLT0jnyTyX5DMqttqc8_z3uhRYCmvnXLfWOs,19
23
+ netbox_device_view-0.1.13.dist-info/RECORD,,