The information returned by stat is not intuitive:
(33152, None, None, 1, u'1004', u'1004', 6, None, 1421830200.0, None)
I know where to get the relevant docs. But it would be much easier to deal with the result, if a namedtuple would be used.
I just gave it a try:
Before:
class StatResult(tuple): """ Support class resembling a tuple like that returned from `os.(l)stat`. """ ...
After:
StatResultBase = collections.namedtuple( "StatResult", ["st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size", "st_atime", "st_mtime", "st_ctime"]) class StatResult(StatResultBase): """ Support class resembling a tuple like that returned from `os.(l)stat`. """ ...
The problem is that before the
StatResult
constructor took one argument (the tuple with the items to use) and with the change theStatResult
constructor takes 11 arguments (the tuple items).Since
StatResult
is a public class for implementation of custom parsers, I don't want to change theStatResult
constructor.
As you suggest, I also think the idea behind using a
namedtuple
isn't the class itself, but the representation of its instances. Therefore I added arepr
toStatResult
so that the representation looks like that of anamedtuple
[236781615dd35adca1dbed54f2393196fbd14523](https://git.sr.ht/~sschwarzer/ftputil/commit/236781615dd35adca1dbed54f2393196fbd14523 "Add__repr__
so that aStatResult
looks like a named tuple (#91) ...").