[issue27796] Expose DirEntry constructor

2016-08-18 Thread Brendan Moloney

New submission from Brendan Moloney:

As per a discussion on python-ideas [1], the consensus is that we should allow 
users to create a DirEntry object themselves. This would just take a path and 
call stat on it and cache the result of that stat call.

Nick Coghlan mentioned possibly allowing a pre-existing stat result to 
optionally be passed into the constructor [2].

[1] https://mail.python.org/pipermail/python-ideas/2016-August/041716.html
[2] https://mail.python.org/pipermail/python-ideas/2016-August/041713.html

--
messages: 273063
nosy: moloney
priority: normal
severity: normal
status: open
title: Expose DirEntry constructor
type: enhancement
versions: Python 3.6

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



[issue27038] Make os.DirEntry exist

2016-08-15 Thread Brendan Moloney

Brendan Moloney added the comment:

The functions were all written around DirEntry objects since that is what they 
will be processing 99% of the time and I want to do that as efficiently as 
possible. Converting a DirEntry object into a str representation doesn't help 
me with my use case at all. I want to be able to do it the other way around: 
str -> DirEntry

--

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



[issue27038] Make os.DirEntry exist

2016-08-15 Thread Brendan Moloney

Brendan Moloney added the comment:

The pathlib Path class is different enough from the DirEntry class that it 
doesn't really help my goal of allowing a function to work with either a 
DirEntry or a plain (str) path.

These functions are going to be working with DirEntry objects generated by 
scandir 99% of the time so that we can leverage the improved performance, but I 
want to allow users to pass in plain paths as well. If the stdlib doesn't allow 
me to create my own DirEntry object from a plain path I will probably end up 
creating some sort of FakeDirEntry class that mimics a DirEntry, and that seems 
a bit silly and not a great use of time and effort.

If the constructor currently "requires low-level data coming from
readdir() or FindFirstFile()" then why not a class method that just takes a 
path and calls stat on it? You could document the fact that it calls stat and 
that it doesn't have any of the performance benefits of using scandir. 
Consenting adults and all that...

--

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



[issue27038] Make os.DirEntry exist

2016-08-12 Thread Brendan Moloney

Brendan Moloney added the comment:

It makes it much easier to write functions that can work with either a DirEntry 
object or a plain path.

--

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



[issue27038] Make os.DirEntry exist

2016-08-12 Thread Brendan Moloney

Brendan Moloney added the comment:

It would be nice if there was a supported way to create a DirEntry object from 
a path. If you don't want to document the constructor perhaps expose some 
helper function or class method (i.e. from_path)?

--
nosy: +moloney

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2014-07-16 Thread Brendan Moloney

Brendan Moloney added the comment:

Here is a script illustrating the issue.

--
Added file: http://bugs.python.org/file35976/tarfile_issue.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21987
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2014-07-15 Thread Brendan Moloney

New submission from Brendan Moloney:

If a directory path is under 100 char you have to omit the trailing slash from 
the name passed to 'getmember'. If it is over 100 you have to include the 
trailing slash.

As a work around I can use the private '_getmember' with 'normalize=True'.

I tested on 2.7.2 and searched the release notes looking for a related fix 
since then. I couldn't find anything there, or here in the issue tracker.

--
components: Library (Lib)
messages: 223167
nosy: moloney
priority: normal
severity: normal
status: open
title: TarFile.getmember on directory requires trailing slash iff over 100 chars
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21987
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com