Improve style to use default iterators rather than explicit ones.

This commit is contained in:
Mike Auty
2018-08-05 16:18:53 +01:00
parent b1d46f843b
commit d08c29ffab
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ class Volshell(interfaces.plugins.PluginInterface):
config = self.config
layer_name = self.config['primary']
kvo = context.memory[layer_name].config.get('kernel_virtual_offset')
members = lambda x: list(sorted(x.vol.members.keys()))
members = lambda x: list(sorted(x.vol.members))
# Determine locals
curframe = inspect.currentframe()
+1 -1
View File
@@ -617,7 +617,7 @@ class Struct(interfaces.objects.ObjectInterface):
def __dir__(self) -> typing.Iterable[str]:
"""Returns a complete list of members when dir is called"""
return list(super().__dir__()) + list(self.vol.members.keys())
return list(super().__dir__()) + list(self.vol.members)
def write(self, value):
raise TypeError("Structs cannot be written to directly, individual members must be written instead")
+1 -1
View File
@@ -49,7 +49,7 @@ class SymbolSpace(interfaces.symbols.SymbolSpaceInterface, validity.ValidityRout
def get_symbols_by_type(self, type_name: str) -> typing.Iterable[str]:
"""Returns all symbols based on the type of the symbol"""
for table in self._dict.keys():
for table in self._dict:
for symbol_name in self._dict[table].get_symbols_by_type(type_name):
yield table + constants.BANG + symbol_name
+4 -4
View File
@@ -109,7 +109,7 @@ class IntermediateSymbolTable(interfaces.symbols.SymbolTableInterface):
changes have been made) than the consumer (in this case, the file reader).
"""
supported, age, revision = [int(x) for x in version.split(".")]
supported_versions = [x for x in versions.keys() if x[0] == supported and x[1] >= age]
supported_versions = [x for x in versions if x[0] == supported and x[1] >= age]
if not supported_versions:
raise ValueError(
"No Intermediate Format interface versions support file interface version: {}".format(version))
@@ -258,17 +258,17 @@ class Version1Format(ISFormatTable):
@property
def symbols(self) -> typing.Iterable[str]:
"""Returns an iterator of the symbol names"""
return self._json_object.get('symbols', {}).keys()
return list(self._json_object.get('symbols', {}))
@property
def enumerations(self) -> typing.Iterable[str]:
"""Returns an iterator of the available enumerations"""
return self._json_object.get('enums', {}).keys()
return list(self._json_object.get('enums', {}))
@property
def types(self) -> typing.Iterable[str]:
"""Returns an iterator of the symbol type names"""
return list(self._json_object.get('user_types', {}).keys()) + list(self.natives.types)
return list(self._json_object.get('user_types', {})) + list(self.natives.types)
def get_type_class(self, name: str) -> typing.Type[interfaces.objects.ObjectInterface]:
return self._overrides.get(name, objects.Struct)