File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed
Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -137,17 +137,14 @@ def _validate_properties(self):
137137 getattr (self , check )()
138138
139139 def __eq__ (self , other ) -> bool :
140- return (
141- isinstance (other , FileSet )
142- and self .mime_like == other .mime_like
143- and self .fspaths == other .fspaths
144- )
140+ return type (self ) is type (other ) and self .fspaths == other .fspaths
145141
146142 def __ne__ (self , other ) -> bool :
147143 return not self .__eq__ (other )
148144
149145 def __hash__ (self ) -> int :
150- return hash ((self .mime_like , self .fspaths ))
146+ tp = type (self )
147+ return hash ((tp .__module__ , tp .__name__ , self .fspaths ))
151148
152149 def __repr__ (self ) -> str :
153150 return f"{ self .type_name } ('" + "', '" .join (str (p ) for p in self .fspaths ) + "')"
Original file line number Diff line number Diff line change 88 MyFormatGz ,
99 MyFormatGzX ,
1010 MyFormatX ,
11+ MyBinaryFormat ,
12+ MyHeader ,
13+ MyBinaryFormatX ,
14+ MyOtherBinaryFormatX ,
1115 YourFormat ,
1216 SeparateHeader ,
1317 ImageWithHeader ,
Original file line number Diff line number Diff line change 11from fileformats .generic import File
22from fileformats .application import Json
3- from fileformats .core .mixin import WithSideCars , WithSeparateHeader
3+ from fileformats .core .mixin import WithSideCars , WithSeparateHeader , WithMagicNumber
44
55
66class YFile (File ):
@@ -36,6 +36,25 @@ class MyFormatX(WithSideCars, MyFormat):
3636 side_car_types = (Json ,)
3737
3838
39+ class MyBinaryFormat (WithMagicNumber , File ):
40+ ext = ".my"
41+ magic_number = b"MYFORMAT"
42+
43+
44+ class MyHeader (File ):
45+ ext = ".myhdr"
46+
47+
48+ class MyBinaryFormatX (WithSeparateHeader , MyFormat ):
49+ header_type = MyHeader
50+
51+
52+ class MyOtherBinaryFormatX (WithMagicNumber , WithSeparateHeader , File ):
53+ magic_number = b"MYFORMAT"
54+ ext = ".my"
55+ header_type = MyHeader
56+
57+
3958class YourFormat (File ):
4059
4160 ext = ".yr"
You can’t perform that action at this time.
0 commit comments