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
This commit is contained in:
Jay Pipes 2017-05-04 18:44:20 -04:00
parent 1441f4f62d
commit 5a704fd08d
3 changed files with 1 additions and 50 deletions

View File

@ -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())
[...
<snip>
'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::

View File

@ -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.

View File

@ -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)