mirror of
https://github.com/dgelessus/python-rsrcfork.git
synced 2024-06-24 23:30:04 +00:00
Move _LazyResourceMap out of ResourceFile
This commit is contained in:
parent
af2ac70676
commit
cf6ce3c2a6
|
@ -229,10 +229,6 @@ class Resource(object):
|
||||||
else:
|
else:
|
||||||
return self.data_raw
|
return self.data_raw
|
||||||
|
|
||||||
class ResourceFile(typing.Mapping[bytes, typing.Mapping[int, Resource]], typing.ContextManager["ResourceFile"]):
|
|
||||||
"""A resource file reader operating on a byte stream."""
|
|
||||||
|
|
||||||
# noinspection PyProtectedMember
|
|
||||||
class _LazyResourceMap(typing.Mapping[int, Resource]):
|
class _LazyResourceMap(typing.Mapping[int, Resource]):
|
||||||
"""Internal class: Read-only wrapper for a mapping of resource IDs to resource objects.
|
"""Internal class: Read-only wrapper for a mapping of resource IDs to resource objects.
|
||||||
|
|
||||||
|
@ -274,6 +270,9 @@ class ResourceFile(typing.Mapping[bytes, typing.Mapping[int, Resource]], typing.
|
||||||
else:
|
else:
|
||||||
return f"<{type(self).__module__}.{type(self).__qualname__} at {id(self):#x} containing {len(self)} resources with IDs: {list(self)}>"
|
return f"<{type(self).__module__}.{type(self).__qualname__} at {id(self):#x} containing {len(self)} resources with IDs: {list(self)}>"
|
||||||
|
|
||||||
|
class ResourceFile(typing.Mapping[bytes, typing.Mapping[int, Resource]], typing.ContextManager["ResourceFile"]):
|
||||||
|
"""A resource file reader operating on a byte stream."""
|
||||||
|
|
||||||
_close_stream: bool
|
_close_stream: bool
|
||||||
_stream: typing.BinaryIO
|
_stream: typing.BinaryIO
|
||||||
|
|
||||||
|
@ -500,10 +499,10 @@ class ResourceFile(typing.Mapping[bytes, typing.Mapping[int, Resource]], typing.
|
||||||
|
|
||||||
return key in self._references
|
return key in self._references
|
||||||
|
|
||||||
def __getitem__(self, key: bytes) -> "ResourceFile._LazyResourceMap":
|
def __getitem__(self, key: bytes) -> "_LazyResourceMap":
|
||||||
"""Get a lazy mapping of all resources with the given type in this ResourceFile."""
|
"""Get a lazy mapping of all resources with the given type in this ResourceFile."""
|
||||||
|
|
||||||
return ResourceFile._LazyResourceMap(self._references[key])
|
return _LazyResourceMap(self._references[key])
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"<{type(self).__module__}.{type(self).__qualname__} at {id(self):#x}, attributes {self.file_attributes}, containing {len(self)} resource types: {list(self)}>"
|
return f"<{type(self).__module__}.{type(self).__qualname__} at {id(self):#x}, attributes {self.file_attributes}, containing {len(self)} resource types: {list(self)}>"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user