[PATCH 1/2] remove obsolete i18n strings which are no longer in use

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> These strings are no longer in use, but they still remain in i18n.py Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- plugins/sample/i18n.py | 1 - src/kimchi/i18n.py | 4 ---- 2 files changed, 5 deletions(-) diff --git a/plugins/sample/i18n.py b/plugins/sample/i18n.py index 8957e11..72d9783 100644 --- a/plugins/sample/i18n.py +++ b/plugins/sample/i18n.py @@ -26,7 +26,6 @@ messages = { "SPAPI0001E": _("Unkown parameter specified %(value)s"), "SPAPI0002E": _("The specified value %(value)s is not a positive number"), - "SPCIRC0001E": _("Circle %(name)s already exists"), "SPCIRC0002E": _("Circle %(name)s does not exist"), "SPCIRC0003E": _("Specify name and radius to create a Circle"), "SPCIRC0004E": _("Circle name must be a string"), diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index d45f607..0eb721a 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -36,7 +36,6 @@ messages = { "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'. [Error code: %(code)s]"), "KCHAUTH0002E": _("You are not authorized to access Kimchi"), "KCHAUTH0003E": _("Specify %(item)s to login into Kimchi"), - "KCHAUTH0004E": _("This operation is not allowed as you have restricted access to Kimchi."), "KCHDISKS0001E": _("Error while getting block devices. Details: %(err)s"), "KCHDISKS0002E": _("Error while getting block device information for %(device)s."), @@ -110,7 +109,6 @@ messages = { "KCHPOOL0001E": _("Storage pool %(name)s already exists"), "KCHPOOL0002E": _("Storage pool %(name)s does not exist"), - "KCHPOOL0003E": _("Autostart flag must be true or false"), "KCHPOOL0004E": _("Specify %(item)s in order to create the storage pool %(name)s"), "KCHPOOL0005E": _("Unable to delete active storage pool %(name)s"), "KCHPOOL0006E": _("Unable to list storage pools. Details: %(err)s"), @@ -173,7 +171,6 @@ messages = { "KCHNET0007E": _("Interface should be bare NIC, bonding or bridge device."), "KCHNET0008E": _("Unable to create network %(name)s. Details: %(err)s"), "KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"), - "KCHNET0010E": _("Unable to create VLAN tagged bridge using interface %(iface)s. Details: %(err)s"), "KCHNET0011E": _("Network name must be a string"), "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"), "KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"), @@ -217,7 +214,6 @@ messages = { "KCHCDROM0002E": _("Invalid storage type. Types supported: 'cdrom'"), "KCHCDROM0003E": _("The path '%(value)s' is not valid local/remote path for the device"), "KCHCDROM0004E": _("Device name %(dev_name)s already exists in vm %(vm_name)s"), - "KCHCDROM0006E": _("Can't specify a directory for a CDROM device path"), "KCHCDROM0007E": _("The storage device %(dev_name)s does not exist in the guest %(vm_name)s"), "KCHCDROM0008E": _("Error while creating new storage device: %(error)s"), "KCHCDROM0009E": _("Error while updating storage device: %(error)s"), -- 1.8.5.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> There are some i18n strings are no longer in use in source code. But they are still remain in i18n.py. We should add a mechanism to check the obsolete i18n strings. Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- contrib/check_i18n.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contrib/check_i18n.py b/contrib/check_i18n.py index e3c2b8c..e9eab6e 100755 --- a/contrib/check_i18n.py +++ b/contrib/check_i18n.py @@ -45,6 +45,25 @@ def check_string_formatting(messages): exit(1) +def check_obsolete_messages(path, messages): + def find_message_key(path, k): + for root, dirs, files in os.walk(path): + for f in files: + fname = os.path.join(root, f) + if (not fname.endswith("i18n.py") and fname.endswith(".py") + or fname.endswith(".json")): + with open(fname) as f: + string = "".join(f.readlines()) + if k in string: + return True + return False + + for k in messages.iterkeys(): + if not find_message_key(path, k): + print " %s is obsolete, it is no longer in use" % k + exit(1) + + def main(): files = [] for v in sys.argv[1:]: @@ -54,6 +73,7 @@ def main(): for f in files: messages = load_i18n_module(f).messages check_string_formatting(messages) + check_obsolete_messages(os.path.dirname(f), messages) print "Checking for invalid i18n string successfully" -- 1.8.5.3

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 04/07/2014 10:39 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
There are some i18n strings are no longer in use in source code. But they are still remain in i18n.py.
We should add a mechanism to check the obsolete i18n strings.
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- contrib/check_i18n.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/contrib/check_i18n.py b/contrib/check_i18n.py index e3c2b8c..e9eab6e 100755 --- a/contrib/check_i18n.py +++ b/contrib/check_i18n.py @@ -45,6 +45,25 @@ def check_string_formatting(messages): exit(1)
+def check_obsolete_messages(path, messages): + def find_message_key(path, k): + for root, dirs, files in os.walk(path): + for f in files: + fname = os.path.join(root, f) + if (not fname.endswith("i18n.py") and fname.endswith(".py") + or fname.endswith(".json")): + with open(fname) as f: + string = "".join(f.readlines()) + if k in string: + return True + return False + + for k in messages.iterkeys(): + if not find_message_key(path, k): + print " %s is obsolete, it is no longer in use" % k + exit(1) + + def main(): files = [] for v in sys.argv[1:]: @@ -54,6 +73,7 @@ def main(): for f in files: messages = load_i18n_module(f).messages check_string_formatting(messages) + check_obsolete_messages(os.path.dirname(f), messages) print "Checking for invalid i18n string successfully"

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 04/07/2014 10:39 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
These strings are no longer in use, but they still remain in i18n.py
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- plugins/sample/i18n.py | 1 - src/kimchi/i18n.py | 4 ---- 2 files changed, 5 deletions(-)
diff --git a/plugins/sample/i18n.py b/plugins/sample/i18n.py index 8957e11..72d9783 100644 --- a/plugins/sample/i18n.py +++ b/plugins/sample/i18n.py @@ -26,7 +26,6 @@ messages = { "SPAPI0001E": _("Unkown parameter specified %(value)s"), "SPAPI0002E": _("The specified value %(value)s is not a positive number"),
- "SPCIRC0001E": _("Circle %(name)s already exists"), "SPCIRC0002E": _("Circle %(name)s does not exist"), "SPCIRC0003E": _("Specify name and radius to create a Circle"), "SPCIRC0004E": _("Circle name must be a string"), diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index d45f607..0eb721a 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -36,7 +36,6 @@ messages = { "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'. [Error code: %(code)s]"), "KCHAUTH0002E": _("You are not authorized to access Kimchi"), "KCHAUTH0003E": _("Specify %(item)s to login into Kimchi"), - "KCHAUTH0004E": _("This operation is not allowed as you have restricted access to Kimchi."),
"KCHDISKS0001E": _("Error while getting block devices. Details: %(err)s"), "KCHDISKS0002E": _("Error while getting block device information for %(device)s."), @@ -110,7 +109,6 @@ messages = {
"KCHPOOL0001E": _("Storage pool %(name)s already exists"), "KCHPOOL0002E": _("Storage pool %(name)s does not exist"), - "KCHPOOL0003E": _("Autostart flag must be true or false"), "KCHPOOL0004E": _("Specify %(item)s in order to create the storage pool %(name)s"), "KCHPOOL0005E": _("Unable to delete active storage pool %(name)s"), "KCHPOOL0006E": _("Unable to list storage pools. Details: %(err)s"), @@ -173,7 +171,6 @@ messages = { "KCHNET0007E": _("Interface should be bare NIC, bonding or bridge device."), "KCHNET0008E": _("Unable to create network %(name)s. Details: %(err)s"), "KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"), - "KCHNET0010E": _("Unable to create VLAN tagged bridge using interface %(iface)s. Details: %(err)s"), "KCHNET0011E": _("Network name must be a string"), "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"), "KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"), @@ -217,7 +214,6 @@ messages = { "KCHCDROM0002E": _("Invalid storage type. Types supported: 'cdrom'"), "KCHCDROM0003E": _("The path '%(value)s' is not valid local/remote path for the device"), "KCHCDROM0004E": _("Device name %(dev_name)s already exists in vm %(vm_name)s"), - "KCHCDROM0006E": _("Can't specify a directory for a CDROM device path"), "KCHCDROM0007E": _("The storage device %(dev_name)s does not exist in the guest %(vm_name)s"), "KCHCDROM0008E": _("Error while creating new storage device: %(error)s"), "KCHCDROM0009E": _("Error while updating storage device: %(error)s"),

I can't apply this patch set. Does it depend on other patch set? On 04/07/2014 10:39 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
These strings are no longer in use, but they still remain in i18n.py
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- plugins/sample/i18n.py | 1 - src/kimchi/i18n.py | 4 ---- 2 files changed, 5 deletions(-)
diff --git a/plugins/sample/i18n.py b/plugins/sample/i18n.py index 8957e11..72d9783 100644 --- a/plugins/sample/i18n.py +++ b/plugins/sample/i18n.py @@ -26,7 +26,6 @@ messages = { "SPAPI0001E": _("Unkown parameter specified %(value)s"), "SPAPI0002E": _("The specified value %(value)s is not a positive number"),
- "SPCIRC0001E": _("Circle %(name)s already exists"), "SPCIRC0002E": _("Circle %(name)s does not exist"), "SPCIRC0003E": _("Specify name and radius to create a Circle"), "SPCIRC0004E": _("Circle name must be a string"), diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index d45f607..0eb721a 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -36,7 +36,6 @@ messages = { "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'. [Error code: %(code)s]"), "KCHAUTH0002E": _("You are not authorized to access Kimchi"), "KCHAUTH0003E": _("Specify %(item)s to login into Kimchi"), - "KCHAUTH0004E": _("This operation is not allowed as you have restricted access to Kimchi."),
"KCHDISKS0001E": _("Error while getting block devices. Details: %(err)s"), "KCHDISKS0002E": _("Error while getting block device information for %(device)s."), @@ -110,7 +109,6 @@ messages = {
"KCHPOOL0001E": _("Storage pool %(name)s already exists"), "KCHPOOL0002E": _("Storage pool %(name)s does not exist"), - "KCHPOOL0003E": _("Autostart flag must be true or false"), "KCHPOOL0004E": _("Specify %(item)s in order to create the storage pool %(name)s"), "KCHPOOL0005E": _("Unable to delete active storage pool %(name)s"), "KCHPOOL0006E": _("Unable to list storage pools. Details: %(err)s"), @@ -173,7 +171,6 @@ messages = { "KCHNET0007E": _("Interface should be bare NIC, bonding or bridge device."), "KCHNET0008E": _("Unable to create network %(name)s. Details: %(err)s"), "KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"), - "KCHNET0010E": _("Unable to create VLAN tagged bridge using interface %(iface)s. Details: %(err)s"), "KCHNET0011E": _("Network name must be a string"), "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"), "KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"), @@ -217,7 +214,6 @@ messages = { "KCHCDROM0002E": _("Invalid storage type. Types supported: 'cdrom'"), "KCHCDROM0003E": _("The path '%(value)s' is not valid local/remote path for the device"), "KCHCDROM0004E": _("Device name %(dev_name)s already exists in vm %(vm_name)s"), - "KCHCDROM0006E": _("Can't specify a directory for a CDROM device path"), "KCHCDROM0007E": _("The storage device %(dev_name)s does not exist in the guest %(vm_name)s"), "KCHCDROM0008E": _("Error while creating new storage device: %(error)s"), "KCHCDROM0009E": _("Error while updating storage device: %(error)s"),

On 04/11/2014 11:04 AM, Aline Manera wrote:
I can't apply this patch set. Does it depend on other patch set?
yes. depend on [PATCH V5] add a make check-local command to verify the i18n string formatting will send them together later.
On 04/07/2014 10:39 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
These strings are no longer in use, but they still remain in i18n.py
Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- plugins/sample/i18n.py | 1 - src/kimchi/i18n.py | 4 ---- 2 files changed, 5 deletions(-)
diff --git a/plugins/sample/i18n.py b/plugins/sample/i18n.py index 8957e11..72d9783 100644 --- a/plugins/sample/i18n.py +++ b/plugins/sample/i18n.py @@ -26,7 +26,6 @@ messages = { "SPAPI0001E": _("Unkown parameter specified %(value)s"), "SPAPI0002E": _("The specified value %(value)s is not a positive number"),
- "SPCIRC0001E": _("Circle %(name)s already exists"), "SPCIRC0002E": _("Circle %(name)s does not exist"), "SPCIRC0003E": _("Specify name and radius to create a Circle"), "SPCIRC0004E": _("Circle name must be a string"), diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index d45f607..0eb721a 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -36,7 +36,6 @@ messages = { "KCHAUTH0001E": _("Authentication failed for user '%(userid)s'. [Error code: %(code)s]"), "KCHAUTH0002E": _("You are not authorized to access Kimchi"), "KCHAUTH0003E": _("Specify %(item)s to login into Kimchi"), - "KCHAUTH0004E": _("This operation is not allowed as you have restricted access to Kimchi."),
"KCHDISKS0001E": _("Error while getting block devices. Details: %(err)s"), "KCHDISKS0002E": _("Error while getting block device information for %(device)s."), @@ -110,7 +109,6 @@ messages = {
"KCHPOOL0001E": _("Storage pool %(name)s already exists"), "KCHPOOL0002E": _("Storage pool %(name)s does not exist"), - "KCHPOOL0003E": _("Autostart flag must be true or false"), "KCHPOOL0004E": _("Specify %(item)s in order to create the storage pool %(name)s"), "KCHPOOL0005E": _("Unable to delete active storage pool %(name)s"), "KCHPOOL0006E": _("Unable to list storage pools. Details: %(err)s"), @@ -173,7 +171,6 @@ messages = { "KCHNET0007E": _("Interface should be bare NIC, bonding or bridge device."), "KCHNET0008E": _("Unable to create network %(name)s. Details: %(err)s"), "KCHNET0009E": _("Unable to find a free IP address for network '%(name)s'"), - "KCHNET0010E": _("Unable to create VLAN tagged bridge using interface %(iface)s. Details: %(err)s"), "KCHNET0011E": _("Network name must be a string"), "KCHNET0012E": _("Supported network types are isolated, NAT and bridge"), "KCHNET0013E": _("Network subnet must be a string with IP address and prefix or netmask"), @@ -217,7 +214,6 @@ messages = { "KCHCDROM0002E": _("Invalid storage type. Types supported: 'cdrom'"), "KCHCDROM0003E": _("The path '%(value)s' is not valid local/remote path for the device"), "KCHCDROM0004E": _("Device name %(dev_name)s already exists in vm %(vm_name)s"), - "KCHCDROM0006E": _("Can't specify a directory for a CDROM device path"), "KCHCDROM0007E": _("The storage device %(dev_name)s does not exist in the guest %(vm_name)s"), "KCHCDROM0008E": _("Error while creating new storage device: %(error)s"), "KCHCDROM0009E": _("Error while updating storage device: %(error)s"),
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center
participants (4)
-
Aline Manera
-
Daniel H Barboza
-
shaohef@linux.vnet.ibm.com
-
Sheldon