Skip to content

Commit 0695d14

Browse files
author
Tang Chen
committed
Trivial: Fix coding style in examples in doc
Now, we use i18n strings for help and log messages, and standardize the usage of logger. So fix those in the example in doc. Change-Id: Ibbc051b12133699811dd35a7e77a10de50ed8e44
1 parent df71ae8 commit 0695d14

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

doc/source/command-errors.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ raised that includes the name of the file that was attempted to be opened.
5151
) as p:
5252
public_key = p.read()
5353
except IOError as e:
54-
msg = "Key file %s not found: %s"
54+
msg = _("Key file %s not found: %s")
5555
raise exceptions.CommandError(
5656
msg % (parsed_args.public_key, e),
5757
)
@@ -135,7 +135,7 @@ remaining arguments are set using the ``update()`` method.
135135
parsed_args.property,
136136
)
137137
except SomeException: # Need to define the exceptions to catch here
138-
self.app.log.error("Property set failed")
138+
LOG.error(_("Property set failed"))
139139
result += 1
140140
141141
if parsed_args.state:
@@ -145,7 +145,7 @@ remaining arguments are set using the ``update()`` method.
145145
parsed_args.state,
146146
)
147147
except SomeException: # Need to define the exceptions to catch here
148-
self.app.log.error("State set failed")
148+
LOG.error(_("State set failed"))
149149
result += 1
150150
151151
try:
@@ -154,7 +154,7 @@ remaining arguments are set using the ``update()`` method.
154154
**kwargs
155155
)
156156
except SomeException: # Need to define the exceptions to catch here
157-
self.app.log.error("Update failed")
157+
LOG.error(_("Update failed"))
158158
result += 1
159159
160160
# NOTE(dtroyer): We need to signal the error, and a non-zero return code,
@@ -166,8 +166,8 @@ Example 2
166166
~~~~~~~~~
167167

168168
This example is taken from the ``network delete`` command which takes multiple
169-
networks to delete. All networks will be delete in a loop, which makes multiple
170-
``delete_network()`` calls.
169+
networks to delete. All networks will be deleted in a loop, which makes
170+
multiple ``delete_network()`` calls.
171171

172172
.. code-block:: python
173173
@@ -179,7 +179,7 @@ networks to delete. All networks will be delete in a loop, which makes multiple
179179
'network',
180180
metavar="<network>",
181181
nargs="+",
182-
help=("Network(s) to delete (name or ID)")
182+
help=_("Network(s) to delete (name or ID)")
183183
)
184184
return parser
185185
@@ -191,11 +191,15 @@ networks to delete. All networks will be delete in a loop, which makes multiple
191191
obj = client.find_network(network, ignore_missing=False)
192192
client.delete_network(obj)
193193
except Exception:
194-
self.app.log.error("Failed to delete network with name "
195-
"or ID %s." % network)
194+
LOG.error(_("Failed to delete network with name "
195+
"or ID %s."), network)
196196
ret += 1
197197
198198
if ret > 0:
199199
total = len(parsed_args.network)
200-
msg = "Failed to delete %s of %s networks." % (ret, total)
200+
msg = _("Failed to delete %(ret)s of %(total)s networks.") %
201+
{
202+
"ret": ret,
203+
"total": total,
204+
}
201205
raise exceptions.CommandError(msg)

0 commit comments

Comments
 (0)