python / python/cpython

Make it configurable whether shutil.copytree copies stat() information

Offen
#138,570 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Feature or enhancement

Proposal:

When copying a tree of files, it is sometimes useful for them to have default stat() information (file permissions, mtime and so on), instead of it being copied from the source files, for example when copying files from a read-only location to a temporary location where they may be modified or deleted later, but shutil.copytree unconditionally copies stat() information.

In a script that I wrote, I worked around the lack of this feature by monkey-patching the shutil.copystat function to do nothing, but this is clearly not a robust approach.

Ideally I would like to be able to turn off the stat() copying behavior by passing a named argument to copytree, such as:

shutil.copytree(src, dst, copystat=False)
Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, shutil.copytree und shutil.copystat zu lesen, um zu verstehen, an welcher Stelle Stat-Informationen kopiert werden. Prüfe anschließend das bestehende Verhalten und die Tests von shutil und definiere dann das konfigurierbare Verhalten, sodass beim Kopieren Stat-Informationen je nach Anforderung beibehalten oder übersprungen werden können.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
operating-systems
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.