From 0695d1495e8337149850b8f753c603e7cac1989c Mon Sep 17 00:00:00 2001 From: Tang Chen <chen.tang@easystack.cn> Date: Wed, 8 Jun 2016 14:25:59 +0800 Subject: [PATCH] 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 --- doc/source/command-errors.rst | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/source/command-errors.rst b/doc/source/command-errors.rst index a24dc317bb..48b828fd42 100644 --- a/doc/source/command-errors.rst +++ b/doc/source/command-errors.rst @@ -51,7 +51,7 @@ raised that includes the name of the file that was attempted to be opened. ) as p: public_key = p.read() except IOError as e: - msg = "Key file %s not found: %s" + msg = _("Key file %s not found: %s") raise exceptions.CommandError( msg % (parsed_args.public_key, e), ) @@ -135,7 +135,7 @@ remaining arguments are set using the ``update()`` method. parsed_args.property, ) except SomeException: # Need to define the exceptions to catch here - self.app.log.error("Property set failed") + LOG.error(_("Property set failed")) result += 1 if parsed_args.state: @@ -145,7 +145,7 @@ remaining arguments are set using the ``update()`` method. parsed_args.state, ) except SomeException: # Need to define the exceptions to catch here - self.app.log.error("State set failed") + LOG.error(_("State set failed")) result += 1 try: @@ -154,7 +154,7 @@ remaining arguments are set using the ``update()`` method. **kwargs ) except SomeException: # Need to define the exceptions to catch here - self.app.log.error("Update failed") + LOG.error(_("Update failed")) result += 1 # NOTE(dtroyer): We need to signal the error, and a non-zero return code, @@ -166,8 +166,8 @@ Example 2 ~~~~~~~~~ This example is taken from the ``network delete`` command which takes multiple -networks to delete. All networks will be delete in a loop, which makes multiple -``delete_network()`` calls. +networks to delete. All networks will be deleted in a loop, which makes +multiple ``delete_network()`` calls. .. code-block:: python @@ -179,7 +179,7 @@ networks to delete. All networks will be delete in a loop, which makes multiple 'network', metavar="<network>", nargs="+", - help=("Network(s) to delete (name or ID)") + help=_("Network(s) to delete (name or ID)") ) return parser @@ -191,11 +191,15 @@ networks to delete. All networks will be delete in a loop, which makes multiple obj = client.find_network(network, ignore_missing=False) client.delete_network(obj) except Exception: - self.app.log.error("Failed to delete network with name " - "or ID %s." % network) + LOG.error(_("Failed to delete network with name " + "or ID %s."), network) ret += 1 if ret > 0: total = len(parsed_args.network) - msg = "Failed to delete %s of %s networks." % (ret, total) + msg = _("Failed to delete %(ret)s of %(total)s networks.") % + { + "ret": ret, + "total": total, + } raise exceptions.CommandError(msg)