[issue44095] Add suffix property to zipfile.Path

2021-05-09 Thread Jakub Nowak


New submission from Jakub Nowak :

suffix property is present on pathlib.Path (specifically pathlib.PurePath) and 
it could also be added to zipfile.Path for consistency.

My use case is filtering files by suffix:
patch_files = list(filter(lambda file: file.suffix == '.patch', files))

Besides suffix also most of the other pathlib.PurePath properties and methods 
could be added.

--
components: Library (Lib)
messages: 393352
nosy: MrQubo
priority: normal
severity: normal
status: open
title: Add suffix property to zipfile.Path
type: enhancement
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue44095>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44095] Add suffix property to zipfile.Path

2021-05-14 Thread Jakub Nowak


Jakub Nowak  added the comment:

Thank for your interest Miguel. I have no experience with CPython codebase so 
I'll be glad if you work on this.

I think treating ZipFile's like a separate drive would be the best. If we agree 
on this then probably all of the properties and methods from pathlib could be 
implemented. But without this at least `suffix`, `suffixes`, `stem`, 
`with_name()`, `with_stem()`, and `with_suffix()` makes perfect sense.

If some of the properties/methods won't be implemented on zipfile.Path then it 
would be useful to raise `NotImplementedError`. Currently, trying to use suffix 
property, raises the error `AttributeError: 'Path' object has no attribute 
'suffix'`. This is confusing as the name of the class is the same as in 
`pathlib.Path` so it's not immediately obvious that it meant `zipfile.Path`.

The use-case for mimicking those two interfaces closely is to use both 
interchangeably (thanks to duck-typing).

--

___
Python tracker 
<https://bugs.python.org/issue44095>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com