From 5a704fd08dc8066ed52b82b71e5cca888e0523de Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Thu, 4 May 2017 18:44:20 -0400 Subject: [PATCH] remove redundant get_symbol_names() func The os_traits.get_symbol_names() function implementation was identical to the os_traits.get_traits() function. Remove it. Change-Id: I8656d98e51258b641190cfca1da71348ca7b6752 --- README.rst | 29 +---------------------------- os_traits/__init__.py | 15 --------------- os_traits/tests/test_os_traits.py | 7 ------- 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/README.rst b/README.rst index 4cc8b89..ed83817 100644 --- a/README.rst +++ b/README.rst @@ -29,34 +29,7 @@ traits constants:: >>> print ot.HW_CPU_X86_SSE42 HW_CPU_X86_SSE42 -Don't know what the symbol names are for the `os_traits` module? There's a -helper method for that:: - - >>> import pprint - >>> pprint.pprint(ot.get_symbol_names()) - [... - - 'HW_CPU_X86_AVX2', - 'HW_CPU_X86_SGX', - 'HW_CPU_X86_AVX', - 'HW_CPU_X86_AVX512BW', - 'HW_CPU_X86_AVX512DQ', - 'HW_CPU_X86_SSE', - 'HW_CPU_X86_SHA', - 'HW_CPU_X86_AVX512F', - 'HW_CPU_X86_F16C', - 'HW_CPU_X86_SSE41', - 'HW_CPU_X86_SSE42', - 'HW_CPU_X86_VMX', - 'HW_CPU_X86_ASF', - 'HW_CPU_X86_BMI2', - 'HW_CPU_X86_CLMUL', - 'HW_CPU_X86_AVX512VL', - 'HW_CPU_X86_AVX512PF', - 'HW_CPU_X86_XOP', - 'HW_CPU_X86_BMI', - 'HW_CPU_X86_ABM', - 'HW_CPU_X86_3DNOW'] +You can get a list of the os_traits symbols by simply doing a dir(os_traits). Want to see the trait strings for a subset of traits? There's a method for that too:: diff --git a/os_traits/__init__.py b/os_traits/__init__.py index ab9527b..3dd9705 100644 --- a/os_traits/__init__.py +++ b/os_traits/__init__.py @@ -65,21 +65,6 @@ def import_submodules(package, recursive=True): import_submodules(sys.modules.get(__name__)) -def get_symbol_names(prefix=None): - """Returns the names of symbols of trait strings in the os_traits module, - optionally filtered by a supplied prefix. - - :param prefix: Optional string prefix to filter by. e.g. 'HW_' - """ - prefix = prefix or "" - return [ - k for k, v in sys.modules[__name__].__dict__.items() - if isinstance(v, six.string_types) and - not k.startswith('_') and - v.startswith(prefix) - ] - - def get_traits(prefix=None): """Returns the trait strings in the os_traits module, optionally filtered by a supplied prefix. diff --git a/os_traits/tests/test_os_traits.py b/os_traits/tests/test_os_traits.py index 7857d2c..c0dae69 100644 --- a/os_traits/tests/test_os_traits.py +++ b/os_traits/tests/test_os_traits.py @@ -31,13 +31,6 @@ class TestSymbols(base.TestCase): self.assertEqual(x86.SSE42, ot.HW_CPU_X86_SSE42) self.assertEqual(offload.TSO, ot.HW_NIC_OFFLOAD_TSO) - def test_get_symbol_names(self): - names = ot.get_symbol_names() - self.assertIn("HW_CPU_X86_AVX2", names) - self.assertIn("STORAGE_DISK_SSD", names) - self.assertIn("HW_NIC_SRIOV", names) - self.assertIn("MISC_SHARES_VIA_AGGREGATE", names) - def test_get_traits(self): traits = ot.get_traits('HW_CPU') self.assertIn("HW_CPU_X86_SSE42", traits)