PyPANRestV2 2.1.9__tar.gz → 2.1.10__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPANRestV2
3
- Version: 2.1.9
3
+ Version: 2.1.10
4
4
  Summary: Python tools for interacting with Palo Alto Networks REST API.
5
5
  License: MIT
6
6
  Author: Mark Rzepa
@@ -314,13 +314,21 @@ class TemplateStacks(PanoramaTab):
314
314
  self._ensure_device_variables_container(device_entry)
315
315
 
316
316
  variable_found = False
317
- for var_entry in device_entry['variable']['entry']:
317
+ # Use get() accessors to avoid KeyError if the container wasn't
318
+ # fully normalized for some reason.
319
+ for var_entry in device_entry.get('variable', {}).get('entry', []):
318
320
  if var_entry.get('@name') == variable_name:
319
321
  var_entry['type'] = {variable_type: variable_value}
320
322
  variable_found = True
321
323
  break
322
324
 
323
325
  if not variable_found:
326
+ # Ensure the entry list exists before appending
327
+ if 'variable' not in device_entry or not isinstance(device_entry['variable'], dict):
328
+ device_entry['variable'] = {'entry': []}
329
+ if 'entry' not in device_entry['variable'] or not isinstance(device_entry['variable']['entry'], list):
330
+ device_entry['variable']['entry'] = []
331
+
324
332
  device_entry['variable']['entry'].append({
325
333
  '@name': variable_name,
326
334
  'type': {variable_type: variable_value}
@@ -3,7 +3,7 @@ requires = ["poetry-core>=1.0.0"]
3
3
  build-backend = "poetry.core.masonry.api"
4
4
  [tool.poetry]
5
5
  name = "PyPANRestV2"
6
- version = "2.1.9"
6
+ version = "2.1.10"
7
7
  description = "Python tools for interacting with Palo Alto Networks REST API."
8
8
  authors = [
9
9
  "Mark Rzepa <mark@rzepa.com>"
File without changes