Re: [Python-Dev] A smarter shutil.copytree ?

2008-05-21 Thread Tarek Ziadé
On Tue, Apr 22, 2008 at 7:04 PM, Steven Bethard <[EMAIL PROTECTED]> wrote: > > The callable takes the src directory + its content as a list, and > > returns filter eligible for exclusion > > FWIW, that looks better to me. > > > That makes me wonder, like Alexander said on the bug tracker: > >

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-22 Thread Steven Bethard
On Tue, Apr 22, 2008 at 1:56 AM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > On Mon, Apr 21, 2008 at 2:25 AM, Steven Bethard <[EMAIL PROTECTED]> wrote: > > On Sun, Apr 20, 2008 at 4:15 PM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > > > I have submitted a patch for review here: > http://bugs.python.or

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-22 Thread Tarek Ziadé
On Mon, Apr 21, 2008 at 2:25 AM, Steven Bethard <[EMAIL PROTECTED]> wrote: > > On Sun, Apr 20, 2008 at 4:15 PM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > > I have submitted a patch for review here: http://bugs.python.org/issue2663 > > > > glob-style patterns or a callable (for complex cases) can

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-21 Thread Greg Ewing
Steven Bethard wrote: I'm not a big fan of the sequence-or-callable argument. Why not just make it a callable argument, and supply a utility function Or have two different keyword arguments, one for a sequence and one for a callable. -- Greg ___ Pyth

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-21 Thread Guido van Rossum
On Sun, Apr 20, 2008 at 5:25 PM, Steven Bethard <[EMAIL PROTECTED]> wrote: > > On Sun, Apr 20, 2008 at 4:15 PM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > > I have submitted a patch for review here: http://bugs.python.org/issue2663 > > > > glob-style patterns or a callable (for complex cases) can

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-21 Thread Tarek Ziadé
The pattern matching uses the src_dir to call glob.glob(), which returns the list of files to be excluded. That's why I added within the copytree() function. To make an excluding_patterns work, it could be coded like this:: def excluding_patterns(*patterns): def _excluding_patterns(fi

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-20 Thread Isaac Morland
On Sun, 20 Apr 2008, Steven Bethard wrote: On Sun, Apr 20, 2008 at 4:15 PM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: I have submitted a patch for review here: http://bugs.python.org/issue2663 glob-style patterns or a callable (for complex cases) can be provided to filter out files or directori

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-20 Thread Steven Bethard
On Sun, Apr 20, 2008 at 4:15 PM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > I have submitted a patch for review here: http://bugs.python.org/issue2663 > > glob-style patterns or a callable (for complex cases) can be provided > to filter out files or directories. I'm not a big fan of the sequence-o

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-20 Thread Tarek Ziadé
I have submitted a patch for review here: http://bugs.python.org/issue2663 glob-style patterns or a callable (for complex cases) can be provided to filter out files or directories. Regards Tarek ___ Python-Dev mailing list Python-Dev@python.org http://

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-17 Thread Tarek Ziadé
On Thu, Apr 17, 2008 at 7:06 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Sounds like a neat little feature. Looking forward to it. Maybe the > most useful use case would be to provide glob-style patterns for > skipping files or directories (and their contents). Alright I will work on it th

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-17 Thread Gustavo Carneiro
On 17/04/2008, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > > Hi, > > shutil.copytree is very convenient to make recursive copies, but > os.walk has to be used everytime some filtering > has to be done on the files copied., if you want to avoid copying some > files. > > The code pattern with os.walk is

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-17 Thread Guido van Rossum
Sounds like a neat little feature. Looking forward to it. Maybe the most useful use case would be to provide glob-style patterns for skipping files or directories (and their contents). --Guido On Thu, Apr 17, 2008 at 9:52 AM, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > Hi, > > shutil.copytree is ve

Re: [Python-Dev] A smarter shutil.copytree ?

2008-04-17 Thread Tarek Ziadé
> - copying a source to a target, but the pyc/pyo file > def filtering(source, target): > return os.path.splitext(filename) not in ('.pyc', '.pyo') > > shutil.copytree(source, target, filter_=filtering) > - oups, made a mistake in my example: def fi

[Python-Dev] A smarter shutil.copytree ?

2008-04-17 Thread Tarek Ziadé
Hi, shutil.copytree is very convenient to make recursive copies, but os.walk has to be used everytime some filtering has to be done on the files copied., if you want to avoid copying some files. The code pattern with os.walk is pretty talkative : - copying a source folder to