[Python-ideas] PEP: Extended stat_result (First Draft)

Stefan Drees stefan at drees.name
Mon May 6 18:25:01 CEST 2013


On 06.05.13 18:14, MRAB wrote:
> On 06/05/2013 09:30, Pieter Nagel wrote:
> [snip]
>> Specification
>> =============
>>
>>
>> Added methods on ``stat_result``
>> --------------------------------
>>
>> is_dir()
>>      Equivalent to ``bool(stat.S_ISDIR(self.st_mode))``.
>>
>> is_character_device()
>>      Equivalent to ``bool(stat.S_ISCHR(self.st_mode))``.
>>

is_char_dev()

>> is_block_device()
>>      Equivalent to ``bool(stat.S_ISBLK(self.st_mode))``.
>>

is_block_dev()

>> is_file()
>>      Equivalent to ``bool(stat.S_ISREG(self.st_mode))``.
>>
>> is_fifo()
>>      Equivalent to ``bool(stat.S_ISFIFO(self.st_mode))``.
>>
>> is_symbolic_link()
>>      Equivalent to ``bool(stat.S_ISLNK(self.st_mode))``.
>>

is_sym_link()

>> is_socket()
>>      Equivalent to ``bool(stat.S_ISSOCK(self.st_mode)``.
>>
>> same_stat(other)
>>      Equivalent to ``os.path.samestat(self, other)``.
>>
>> file_mode()
>>      This shall return ``stat.filemode(stat.S_IMODE(self.st_mode))``,
>> i.e. a
>>      string of the form ‘-rwxrwxrwx’.
>>
>> permission_bits()
>>      This shall return ``stat.S_IMODE(self.st_mode)``.
>>

perm_bits() or maybe better file_perm() ?


>> format()
>>      This shall return ``stat.S_IFMT(self.st_mode)``.
>>
> Some of the names seem too long for me.

please cf. shortening suggestions inline above.

>>
>> Added functions in ``os.path``
>> ------------------------------
>>
>> is_dir(f)
>>      This shall be an alias for the existing isdir(f).
>>
> Do we really need 2 names for the same thing? No.
>
>> is_character_device(f)
>>      This shall return ``os.stat(f).is_character_device()``, or
>> ``False`` if
>>      ``f`` does not exist.
>>

is_char_dev()

>> is_block_device(f)
>>      This shall return ``os.stat(f).is_block_device()``, or ``False`` if
>>      ``f`` does not exist.
>>

is_block_dev()

>> is_file()
>>      This shall be an alias for the existing isfile(f).
>>
>> is_fifo()
>>      This shall return ``os.stat(f).is_fifo()``, or ``False`` if
>>      ``f`` does not exist.
>>
>> is_symbolic_link()
>>      This shall return ``os.stat(f).is_symbolic_link()``, or ``False`` if
>>      ``f`` does not exist.
>>

is_sym_link()

>> is_socket()
>>      This shall return ``os.stat(f).is_socket()``, or ``False`` if
>>      ``f`` does not exist.
>>
> Some of the names seem too long for me.

ditto.

> ...

All the best,

Stefan.



More information about the Python-ideas mailing list