mirror of
https://github.com/dgelessus/python-rsrcfork.git
synced 2026-04-20 18:17:03 +00:00
Rename resource_type and resource_id attributes to type and id
The old names were chosen to avoid conflicts with Python's type and id builtins, but for attribute names this is not necessary.
This commit is contained in:
+14
-4
@@ -96,15 +96,15 @@ class ResourceAttrs(enum.Flag):
|
||||
class Resource(object):
|
||||
"""A single resource from a resource file."""
|
||||
|
||||
__slots__ = ("resource_type", "resource_id", "name", "attributes", "data_raw", "_data_decompressed")
|
||||
__slots__ = ("type", "id", "name", "attributes", "data_raw", "_data_decompressed")
|
||||
|
||||
def __init__(self, resource_type: bytes, resource_id: int, name: typing.Optional[bytes], attributes: ResourceAttrs, data_raw: bytes):
|
||||
"""Create a new resource with the given type code, ID, name, attributes, and data."""
|
||||
|
||||
super().__init__()
|
||||
|
||||
self.resource_type: bytes = resource_type
|
||||
self.resource_id: int = resource_id
|
||||
self.type: bytes = resource_type
|
||||
self.id: int = resource_id
|
||||
self.name: typing.Optional[bytes] = name
|
||||
self.attributes: ResourceAttrs = attributes
|
||||
self.data_raw: bytes = data_raw
|
||||
@@ -126,7 +126,17 @@ class Resource(object):
|
||||
if not decompress_ok:
|
||||
data_repr = f"<decompression failed - compressed data: {data_repr}>"
|
||||
|
||||
return f"{type(self).__module__}.{type(self).__qualname__}(resource_type={self.resource_type}, resource_id={self.resource_id}, name={self.name}, attributes={self.attributes}, data={data_repr})"
|
||||
return f"{type(self).__module__}.{type(self).__qualname__}(type={self.type}, id={self.id}, name={self.name}, attributes={self.attributes}, data={data_repr})"
|
||||
|
||||
@property
|
||||
def resource_type(self) -> bytes:
|
||||
warnings.warn(DeprecationWarning("The resource_type attribute has been deprecated and will be removed in a future version. Please use the type attribute instead."))
|
||||
return self.type
|
||||
|
||||
@property
|
||||
def resource_id(self) -> int:
|
||||
warnings.warn(DeprecationWarning("The resource_id attribute has been deprecated and will be removed in a future version. Please use the id attribute instead."))
|
||||
return self.id
|
||||
|
||||
@property
|
||||
def data(self) -> bytes:
|
||||
|
||||
Reference in New Issue
Block a user