File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 66import os
77
88class StatBase :
9- def __init__ (self ):
10- self ._stat_buf = None
9+ def __init__ (self , stat : os . stat_result ):
10+ self ._stat_buf = stat
1111
1212 # Never iterate this object!
1313 def __getitem__ (self , key ):
1414 if type (key ) is not str :
1515 raise TypeError
16- if not key .startswith ("__" ) and key in dir (self ._stat_buf ):
16+
17+ if not key .startswith ("__" ) and hasattr (self ._stat_buf , key ):
1718 return self ._stat_buf .__getattribute__ (key )
19+
1820 return 0
19-
21+
2022 def __getattr__ (self , key ):
2123 return self .__getitem__ (key )
24+
2225class Stat (StatBase ):
2326 def __init__ (self , path ):
24- super (Stat , self ).__init__ ()
25- self ._stat_buf = os .stat (path )
27+ super ().__init__ (os .stat (path ))
2628
2729class Fstat (StatBase ):
28- def __init__ (self , fd ):
29- super (Fstat , self ).__init__ ()
30- self ._stat_buf = os .fstat (fd )
30+ def __init__ (self , fd : int ):
31+ super ().__init__ (os .fstat (fd ))
3132
3233class Lstat (StatBase ):
3334 def __init__ (self , path ):
34- super (Lstat , self ).__init__ ()
35- self ._stat_buf = os .lstat (path )
36-
37-
35+ super ().__init__ (os .lstat (path ))
You can’t perform that action at this time.
0 commit comments