msg212691 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-04 04:55 |
it would be REALLY nice (and REALLY easy) to add a parameter: exist_ok and pass this to os.makedirs with the same parameter name so you can use copytree to append a src dir to an existing dst dir.
|
msg212692 - (view) |
Author: Elias Zamaria (elias) * |
Date: 2014-03-04 05:21 |
Here is a patch that adds the option.
I am not very familiar with the internals of shutil and os so I would recommend that someone else review it.
I haven't added any tests. I can try to if anyone wants but I am not sure how long it will take me or if I will find the time any time soon.
|
msg212756 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-05 01:36 |
awesome, thanks so much!!
|
msg212901 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2014-03-07 21:41 |
Contrary to makedirs, there could be two interpretations for exist_ok in copytree: a) if a directory or file already exists in the destination, ignore it and go ahead b) only do that for directories.
The proposed patch does b), but the cp tool does a). It’s not clear to me which is best. Can you start a discussion on the python-ideas mailing list?
|
msg212945 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-08 23:18 |
how about instead we rename the new parameter to dirs_exists_ok or something like that since the method already allows for existing files.
|
msg212948 - (view) |
Author: Elias Zamaria (elias) * |
Date: 2014-03-09 00:03 |
I am not sure. I am not on the python-ideas mailing list, and I am not sure
what adding and maintaining the discussion would entail, or if I would have
the time to do it or want to deal with the clutter in my inbox. I just
committed this patch because it seemed like it would be quick and easy.
I can start the discussion if anyone specifically wants me to, but I don't
want to let anyone down.
On Fri, Mar 7, 2014 at 1:41 PM, Éric Araujo <report@bugs.python.org> wrote:
>
> Éric Araujo added the comment:
>
> Contrary to makedirs, there could be two interpretations for exist_ok in
> copytree: a) if a directory or file already exists in the destination,
> ignore it and go ahead b) only do that for directories.
>
> The proposed patch does b), but the cp tool does a). It's not clear to me
> which is best. Can you start a discussion on the python-ideas mailing list?
>
> ----------
> nosy: +eric.araujo
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20849>
> _______________________________________
>
|
msg212949 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-09 01:10 |
I personally dont think this is worth investing the time for a discussion.
If the maintainers dont want to accept this or a minor variation without a
discussion ill just keep my local monkeypatch :) thanks again for the
quick patch Elias!
On Mar 8, 2014 4:03 PM, "Elias Zamaria" <report@bugs.python.org> wrote:
>
> Elias Zamaria added the comment:
>
> I am not sure. I am not on the python-ideas mailing list, and I am not sure
> what adding and maintaining the discussion would entail, or if I would have
> the time to do it or want to deal with the clutter in my inbox. I just
> committed this patch because it seemed like it would be quick and easy.
>
> I can start the discussion if anyone specifically wants me to, but I don't
> want to let anyone down.
>
> On Fri, Mar 7, 2014 at 1:41 PM, Éric Araujo <report@bugs.python.org>
> wrote:
>
> >
> > Éric Araujo added the comment:
> >
> > Contrary to makedirs, there could be two interpretations for exist_ok in
> > copytree: a) if a directory or file already exists in the destination,
> > ignore it and go ahead b) only do that for directories.
> >
> > The proposed patch does b), but the cp tool does a). It's not clear to
> me
> > which is best. Can you start a discussion on the python-ideas mailing
> list?
> >
> > ----------
> > nosy: +eric.araujo
> >
> > _______________________________________
> > Python tracker <report@bugs.python.org>
> > <http://bugs.python.org/issue20849>
> > _______________________________________
> >
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20849>
> _______________________________________
>
|
msg213611 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2014-03-15 01:44 |
Adding some core devs to get their opinion on this proposal.
|
msg213620 - (view) |
Author: R. David Murray (r.david.murray) *  |
Date: 2014-03-15 02:15 |
I don't know what "the method already allows for existing files" means. Since the target directory can't exist, there can be no existing files.
In unix, this kind of capability is provided by a combination of shell globbing and 'cp -r', and by default it does replace existing files. So it would be reasonable for exists_ok to mean exactly that: replace anything that currently exists, if it does.
I think that would be a reasonable API, but the implementation isn't as simple as just passing through the exists_ok flag to makedirs.
I do not think that *just* making it OK for the destination directory to exist would be a good API.
|
msg213647 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-15 09:01 |
Ya. The original request I think is ok because by allowing that flag it
will replace files and dirs.
On Mar 14, 2014 7:15 PM, "R. David Murray" <report@bugs.python.org> wrote:
>
> R. David Murray added the comment:
>
> I don't know what "the method already allows for existing files" means.
> Since the target directory can't exist, there can be no existing files.
>
> In unix, this kind of capability is provided by a combination of shell
> globbing and 'cp -r', and by default it does replace existing files. So it
> would be reasonable for exists_ok to mean exactly that: replace anything
> that currently exists, if it does.
>
> I think that would be a reasonable API, but the implementation isn't as
> simple as just passing through the exists_ok flag to makedirs.
>
> I do not think that *just* making it OK for the destination directory to
> exist would be a good API.
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue20849>
> _______________________________________
>
|
msg214055 - (view) |
Author: Alexander Mohr (thehesiod) * |
Date: 2014-03-19 05:39 |
btw, I believe the solution is as simple as stated as that's what I'm doing locally and its behaving exactly as intended.
|
msg323626 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2018-08-16 22:22 |
I think this feature request is reasonable for 2 reasons:
1) As it stands if dst directory exists copytree() cannot be used. The only possible workaround is using rmtree(dst) first, but that doesn't seem to make much sense. The change may look extremely easy but the fact that copytree() cannot be used in a specific circumstance justifies the cost of introducing a new argument, basically because there is no other way around it.
2) "cp -r" does this by default, which is probably indicative (I don't think the default should be True though).
I think the new argument should be called "dirs_exists_ok" instead of "exists_ok" though, so that it's clear that the behavior does not affect files.
[ R. David Murray ]
> I do not think that *just* making it OK for the destination directory to exist would be a good API.
I don't think that refusing (or allowing) to copy existing files is a common enough use case to justify the addition of a new parameter (note: also "cp" does not provide this use case). If such a behavior is desired the user can simply provide its own custom "copy_function".
|
msg323665 - (view) |
Author: Joshua Bronson (jab) * |
Date: 2018-08-17 17:45 |
I submitted a new PR in https://github.com/python/cpython/pull/8792 that addresses the outstanding concerns in @ofekmeister's original PR. It includes passing tests and passes all the GitHub PR status checks. Does it look ok to merge? Thanks.
|
msg332670 - (view) |
Author: Giampaolo Rodola' (giampaolo.rodola) *  |
Date: 2018-12-28 18:03 |
New changeset 9e00d9e88fbf943987e4771c753f5ca8f794103e by Giampaolo Rodola (jab) in branch 'master':
bpo-20849: add dirs_exist_ok arg to shutil.copytree (patch by Josh Bronson)
https://github.com/python/cpython/commit/9e00d9e88fbf943987e4771c753f5ca8f794103e
|
|
Date |
User |
Action |
Args |
2022-04-11 14:57:59 | admin | set | github: 65048 |
2018-12-28 18:05:08 | giampaolo.rodola | set | status: open -> closed assignee: giampaolo.rodola resolution: fixed stage: patch review -> commit review |
2018-12-28 18:03:44 | giampaolo.rodola | set | messages:
+ msg332670 |
2018-08-17 17:45:14 | jab | set | messages:
+ msg323665 |
2018-08-17 17:41:31 | jab | set | nosy:
+ jab
|
2018-08-16 22:22:20 | giampaolo.rodola | set | messages:
+ msg323626 |
2018-08-16 18:58:06 | jab | set | pull_requests:
+ pull_request8266 |
2018-06-12 09:43:10 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola
|
2017-12-09 03:47:52 | martin.panter | link | issue32247 superseder |
2017-08-01 21:36:24 | Ofekmeister | set | pull_requests:
+ pull_request3020 |
2015-03-12 13:07:10 | r.david.murray | link | issue23638 superseder |
2014-04-23 19:36:59 | justin.myers | set | nosy:
+ justin.myers
|
2014-03-19 05:39:11 | thehesiod | set | messages:
+ msg214055 |
2014-03-15 09:01:29 | thehesiod | set | messages:
+ msg213647 |
2014-03-15 02:15:54 | r.david.murray | set | messages:
+ msg213620 |
2014-03-15 01:44:14 | eric.araujo | set | nosy:
+ ncoghlan, tarek, r.david.murray, hynek messages:
+ msg213611
|
2014-03-09 01:10:42 | thehesiod | set | messages:
+ msg212949 |
2014-03-09 00:03:23 | elias | set | messages:
+ msg212948 |
2014-03-08 23:18:12 | thehesiod | set | messages:
+ msg212945 |
2014-03-07 21:41:50 | eric.araujo | set | nosy:
+ eric.araujo messages:
+ msg212901
|
2014-03-05 01:36:23 | thehesiod | set | messages:
+ msg212756 |
2014-03-04 14:01:27 | berker.peksag | set | stage: patch review versions:
- Python 3.3, Python 3.4 |
2014-03-04 05:21:28 | elias | set | files:
+ shutil-copytree-exist_ok.patch
nosy:
+ elias messages:
+ msg212692
keywords:
+ patch |
2014-03-04 04:55:22 | thehesiod | create | |