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):
137
137
getattr (self , check )()
138
138
139
139
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
145
141
146
142
def __ne__ (self , other ) -> bool :
147
143
return not self .__eq__ (other )
148
144
149
145
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 ))
151
148
152
149
def __repr__ (self ) -> str :
153
150
return f"{ self .type_name } ('" + "', '" .join (str (p ) for p in self .fspaths ) + "')"
Original file line number Diff line number Diff line change 8
8
MyFormatGz ,
9
9
MyFormatGzX ,
10
10
MyFormatX ,
11
+ MyBinaryFormat ,
12
+ MyHeader ,
13
+ MyBinaryFormatX ,
14
+ MyOtherBinaryFormatX ,
11
15
YourFormat ,
12
16
SeparateHeader ,
13
17
ImageWithHeader ,
Original file line number Diff line number Diff line change 1
1
from fileformats .generic import File
2
2
from fileformats .application import Json
3
- from fileformats .core .mixin import WithSideCars , WithSeparateHeader
3
+ from fileformats .core .mixin import WithSideCars , WithSeparateHeader , WithMagicNumber
4
4
5
5
6
6
class YFile (File ):
@@ -36,6 +36,25 @@ class MyFormatX(WithSideCars, MyFormat):
36
36
side_car_types = (Json ,)
37
37
38
38
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
+
39
58
class YourFormat (File ):
40
59
41
60
ext = ".yr"
You can’t perform that action at this time.
0 commit comments