Skip to content

Commit

Permalink
Changed remaining percent-style / format() to f-strings
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
  • Loading branch information
andy-maier committed May 6, 2024
1 parent 450f687 commit b1e6b91
Show file tree
Hide file tree
Showing 28 changed files with 191 additions and 218 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ conn = pywbem.WBEMConnection(server_url, (user, password))

server = pywbem.WBEMServer(conn)

print("Interop namespace:\n %s" % server.interop_ns)
print(f"Interop namespace:\n {server.interop_ns}")

print("All namespaces:")
for ns in server.namespaces:
print(" %s" % ns)
print(f" {ns}")
```

# Project Planning
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/DemoMock.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"metadata": {},
"outputs": [],
"source": [
"print('Keys in class %s are %s' % (cls.classname, cls.properties.keys()))"
"print(f'Keys in class {cls.classname} are {cls.properties.keys()}')"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/createdeleteinst.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
" 'Query': 'SELECT * FROM CIM_Indication',\n",
" 'QueryLanguage': 'WQL'})\n",
" \n",
"print('Creating instance of class: %s' % filter_inst.classname)\n",
"print(f'Creating instance of class: {filter_inst.classname}')\n",
"try:\n",
" filter_path = conn.CreateInstance(filter_inst, namespace)\n",
"except pywbem.Error as exc:\n",
Expand All @@ -64,16 +64,16 @@
" print('WBEM server does not support creation of dynamic filters.')\n",
" filter_path = None\n",
" else:\n",
" print('CreateInstance failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'CreateInstance failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
"\n",
"if filter_path is not None:\n",
" print('Created instance: %s' % filter_path)\n",
" print(f'Created instance: {filter_path}')\n",
" print('Deleting the instance again, to clean up')\n",
" try:\n",
" conn.DeleteInstance(filter_path)\n",
" except pywbem.Error as exc:\n",
" print('DeleteInstance failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'DeleteInstance failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
" print('Deleted the instance')"
]
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/enuminstnames.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
"try:\n",
" paths = conn.EnumerateInstanceNames(classname, namespace)\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)\n",
" print(f'Operation failed: {exc}')\n",
"else:\n",
" print('Retrieved %s instance paths' % (len(paths)))\n",
" print(f'Retrieved {len(paths)} instance paths')\n",
" for path in paths:\n",
" print('instance path: %s' % path)\n",
" print('keybindings: %s' % path.items())"
" print(f'instance path: {path}')\n",
" print(f'keybindings: {path.items()}')"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/enuminsts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"try:\n",
" insts = conn.EnumerateInstances(classname)\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)\n",
" print(f'Operation failed: {exc}')\n",
"else:\n",
" print('Retrieved %s instances' % (len(insts)))\n",
" print(f'Retrieved {len(insts)} instances')\n",
" for inst in insts:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof()) "
]
},
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/getinstance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@
"try:\n",
" cs_paths = conn.EnumerateInstanceNames(classname, namespace)\n",
"except pywbem.Error as exc:\n",
" print('EnumerateInstanceNames failed: %s' % exc)\n",
" print(f'EnumerateInstanceNames failed: {exc}')\n",
" sys.exit(1)\n",
"\n",
"for cs_path in cs_paths:\n",
"\n",
" print('Instance at: %s' % cs_path)\n",
" print(f'Instance at: {cs_path}')\n",
"\n",
" try:\n",
" cs_inst = conn.GetInstance(cs_path)\n",
" except pywbem.Error as exc:\n",
" print('GetInstance failed: %s' % exc)\n",
" print(f'GetInstance failed: {exc}')\n",
" sys.exit(1)\n",
"\n",
" for prop_name, prop_value in cs_inst.items():\n",
" print(' %s: %r' % (prop_name, prop_value))"
" print(f' {prop_name}: {prop_value!r}')"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/invokemethod.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
" elif isinstance(exc, pywbem.CIMError) and exc.status_code == CIM_ERR_METHOD_NOT_FOUND:\n",
" print('Method does not exist on class CIM_OperatingSystem: MyStaticMethod')\n",
" else:\n",
" print('InvokeMethod(MyStaticMethod) failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'InvokeMethod(MyStaticMethod) failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
"\n",
"try:\n",
" os_inst_paths = conn.EnumerateInstanceNames('CIM_OperatingSystem')\n",
"except pywbem.Error as exc:\n",
" print('EnumerateInstanceNames failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'EnumerateInstanceNames failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
"\n",
"os_inst_path = os_inst_paths[0]\n",
Expand All @@ -77,7 +77,7 @@
" elif isinstance(exc, pywbem.CIMError) and exc.status_code == CIM_ERR_METHOD_NOT_FOUND:\n",
" print('Method does not exist on class CIM_OperatingSystem: MyMethod')\n",
" else:\n",
" print('InvokeMethod(MyMethod) failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'InvokeMethod(MyMethod) failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)"
]
},
Expand Down
44 changes: 22 additions & 22 deletions docs/notebooks/iterablecimoperations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@
" inst_iterator = conn.IterEnumerateInstances(classname,\n",
" MaxObjectCount=max_obj_cnt)\n",
" for inst in inst_iterator:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof())\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -140,9 +140,9 @@
" path_iterator = conn.IterEnumerateInstancePaths(classname,\n",
" MaxObjectCount=max_obj_cnt)\n",
" for path in path_iterator:\n",
" print('path=%s' % path)\n",
" print(f'path={path}')\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -188,12 +188,12 @@
" inst_iterator = conn.IterAssociatorInstances(source_paths[0],\n",
" MaxObjectCount=max_obj_cnt)\n",
" for inst in inst_iterator:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof())\n",
" else:\n",
" print('%s class has no instances and therefore no associations', classname)\n",
" print('{} class has no instances and therefore no associations', classname)\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -239,11 +239,11 @@
" path_iterator = conn.IterAssociatorInstancePaths(source_paths[0],\n",
" MaxObjectCount=max_obj_cnt)\n",
" for path in path_iterator:\n",
" print('path=%s' % path)\n",
" print(f'path={path}')\n",
" else:\n",
" print('%s class has no instances and therefore no instance associations', classname)\n",
" print('{} class has no instances and therefore no instance associations', classname)\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -289,12 +289,12 @@
" inst_iterator = conn.IterAssociatorInstances(source_paths[0],\n",
" MaxObjectCount=max_obj_cnt)\n",
" for instance in inst_iterator:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof())\n",
" else:\n",
" print('%s class has no instances and therefore no instance associations', classname)\n",
" print(f'{classname} class has no instances and therefore no instance associations')\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -340,11 +340,11 @@
" path_iterator = conn.IterReferenceInstancePaths(source_paths[0],\n",
" MaxObjectCount=max_obj_cnt)\n",
" for path in path_iterator:\n",
" print('path=%s' % path)\n",
" print(f'path={path}')\n",
" else:\n",
" print('%s class has no instances and therefore no instance associations', classname)\n",
" print(f'{classname} class has no instances and therefore no instance associations')\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -394,7 +394,7 @@
" else:\n",
" print('query has no result')\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -427,7 +427,7 @@
" MaxObjectCount=max_obj_cnt)]\n",
" print(*paths, sep='\\n')\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -467,10 +467,10 @@
" inst_iterator = conn.IterEnumerateInstances(classname,\n",
" MaxObjectCount=max_obj_cnt)\n",
" for inst in inst_iterator:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof())\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
},
{
Expand Down Expand Up @@ -508,10 +508,10 @@
" inst_iterator = conn.IterEnumerateInstances(classname,\n",
" MaxObjectCount=max_obj_cnt)\n",
" for inst in inst_iterator:\n",
" print('path=%s' % inst.path)\n",
" print(f'path={inst.path}')\n",
" print(inst.tomof())\n",
"except pywbem.Error as exc:\n",
" print('Operation failed: %s' % exc)"
" print(f'Operation failed: {exc}')"
]
}
],
Expand Down
10 changes: 5 additions & 5 deletions docs/notebooks/modifyinstance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
" 'Query': 'SELECT * FROM CIM_Indication',\n",
" 'QueryLanguage': 'WQL'})\n",
" \n",
"print('Creating instance of class: %s' % filter_inst.classname)\n",
"print(f'Creating instance of class: {filter_inst.classname}')\n",
"try:\n",
" filter_path = conn.CreateInstance(filter_inst, namespace)\n",
"except pywbem.Error as exc:\n",
Expand All @@ -64,11 +64,11 @@
" print('WBEM server does not support creation of dynamic filters.')\n",
" filter_path = None\n",
" else:\n",
" print('CreateInstance failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'CreateInstance failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
"\n",
"if filter_path is not None:\n",
" print('Created instance: %s' % filter_path)\n",
" print(f'Created instance: {filter_path}')\n",
"\n",
" filter_inst['Query'] = 'SELECT * FROM CIM_ProcessIndication'\n",
"\n",
Expand All @@ -81,14 +81,14 @@
" if isinstance(exc, pywbem.CIMError) and exc[0] == pywbem.CIM_ERR_NOT_SUPPORTED:\n",
" print('Modifying CIM_IndicationFilter is not supported')\n",
" else:\n",
" print('ModifyInstance failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'ModifyInstance failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
"\n",
" print('Deleting the instance again, to clean up')\n",
" try:\n",
" conn.DeleteInstance(filter_path)\n",
" except pywbem.Error as exc:\n",
" print('DeleteInstance failed: %s: %s' % (exc.__class__.__name__, exc))\n",
" print(f'DeleteInstance failed: {exc.__class__.__name__}: {exc}')\n",
" sys.exit(1)\n",
" print('Deleted the instance')"
]
Expand Down

0 comments on commit b1e6b91

Please sign in to comment.