From 046936eb9407af2460709d264b97fa46a879dc17 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 11 Jun 2004 15:57:30 +0000 Subject: [PATCH] Allow "" as a valid value in a OptionsBox menu (reported by Guido Schimmels). git-svn-id: https://rox.svn.sourceforge.net/svnroot/rox/trunk/ROX-Lib2@3554 66de3db3-b00d-0410-b41b-f4738ad19bea --- Help/Changes | 4 ++++ python/rox/OptionsBox.py | 2 +- python/rox/basedir.py | 5 ----- tests/python/testbasedir.py | 25 ++++++++++++++++++------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Help/Changes b/Help/Changes index 99b98bb..865970e 100644 --- a/Help/Changes +++ b/Help/Changes @@ -3,6 +3,10 @@ by Thomas Leonard http://rox.sourceforge.net +11-Jun-2004 +~~~~~~~~~~~ +Allow "" as a valid value in a OptionsBox menu (reported by Guido Schimmels). + 10-Jun-2004 ~~~~~~~~~~~ Added 'proxy' module. This allows one Python process to invoke methods on diff --git a/python/rox/OptionsBox.py b/python/rox/OptionsBox.py index fde34db..5c207a9 100644 --- a/python/rox/OptionsBox.py +++ b/python/rox/OptionsBox.py @@ -572,8 +572,8 @@ class OptionsBox(g.Dialog): #self.may_add_tip(option_menu, node) for item in node.getElementsByTagName('item'): + assert item.hasAttribute('value') value = item.getAttribute('value') - assert value label_item = self._(item.getAttribute('label')) or value menu.append(g.MenuItem(label_item)) diff --git a/python/rox/basedir.py b/python/rox/basedir.py index c726a1c..dd0386d 100644 --- a/python/rox/basedir.py +++ b/python/rox/basedir.py @@ -37,11 +37,6 @@ xdg_config_dirs = [xdg_config_home] + \ xdg_data_dirs = filter(lambda x: x, xdg_data_dirs) xdg_config_dirs = filter(lambda x: x, xdg_config_dirs) -#print "Config load", xdg_config_dirs -#print "Config save", xdg_config_home -#print "Data load", xdg_data_dirs -#print "Data save", xdg_data_home - def save_config_path(resource): """Ensure $XDG_CONFIG_HOME// exists, and return its path. 'resource' should normally be the name of your application. Use this diff --git a/tests/python/testbasedir.py b/tests/python/testbasedir.py index d788331..f0ac9b9 100755 --- a/tests/python/testbasedir.py +++ b/tests/python/testbasedir.py @@ -7,13 +7,18 @@ from rox import basedir class TestBasedir(unittest.TestCase): def setUp(self): + os.environ['XDG_DATA_HOME'] = '/tmp/share' + os.environ['XDG_DATA_DIRS'] = '/tmp/share.2:/tmp/share.3' + os.environ['XDG_CONFIG_HOME'] = '/tmp/config' + os.environ['XDG_CONFIG_DIRS'] = '/tmp/config.2:/tmp/config.3' + reload(basedir) + + def testDefaults(self): for x in ['XDG_DATA_HOME', 'XDG_DATA_DIRS', 'XDG_CONFIG_HOME', 'XDG_CONFIG_DIRS']: if x in os.environ: del os.environ[x] reload(basedir) - - def testDefaults(self): self.assertEquals(os.path.expanduser('~/.config'), basedir.xdg_config_home) self.assertEquals([basedir.xdg_config_home, '/etc/xdg'], @@ -26,11 +31,6 @@ class TestBasedir(unittest.TestCase): basedir.xdg_data_dirs) def testOverride(self): - os.environ['XDG_DATA_HOME'] = '/tmp/share' - os.environ['XDG_DATA_DIRS'] = '/tmp/share.2:/tmp/share.3' - os.environ['XDG_CONFIG_HOME'] = '/tmp/config' - os.environ['XDG_CONFIG_DIRS'] = '/tmp/config.2:/tmp/config.3' - reload(basedir) self.assertEquals('/tmp/config', basedir.xdg_config_home) self.assertEquals([basedir.xdg_config_home, '/tmp/config.2', '/tmp/config.3'], @@ -40,6 +40,17 @@ class TestBasedir(unittest.TestCase): self.assertEquals([basedir.xdg_data_home, '/tmp/share.2', '/tmp/share.3'], basedir.xdg_data_dirs) + + def testMkDir(self): + assert not os.path.isdir(basedir.xdg_config_home) + path = basedir.save_config_path('ROX-Lib-Test') + self.assertEquals('/tmp/config/ROX-Lib-Test', path) + assert os.path.isdir(basedir.xdg_config_home) + assert os.path.isdir(path) + + os.rmdir(path) + os.rmdir(basedir.xdg_config_home) + sys.argv.append('-v') unittest.main() -- 2.11.4.GIT