-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathcontextlib.po
More file actions
1213 lines (1081 loc) · 51.3 KB
/
contextlib.po
File metadata and controls
1213 lines (1081 loc) · 51.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2001-2018, Python Software Foundation
# For licence information, see README file.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-10-17 09:58+0200\n"
"PO-Revision-Date: 2021-11-06 21:37+0100\n"
"Last-Translator: Jean Abou Samra <jean@abou-samra.fr>\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
#: library/contextlib.rst:2
msgid ""
":mod:`!contextlib` --- Utilities for :keyword:`!with`\\ -statement contexts"
msgstr ""
":mod:`!contextlib` — Utilitaires pour les contextes s'appuyant sur "
"l'instruction :keyword:`!with`"
#: library/contextlib.rst:7
msgid "**Source code:** :source:`Lib/contextlib.py`"
msgstr "**Code source :** :source:`Lib/contextlib.py`"
#: library/contextlib.rst:11
msgid ""
"This module provides utilities for common tasks involving "
"the :keyword:`with` statement. For more information see "
"also :ref:`typecontextmanager` and :ref:`context-managers`."
msgstr ""
"Ce module fournit des utilitaires pour les tâches impliquant le mot-"
"clé :keyword:`with`. Pour plus d'informations voir "
"aussi :ref:`typecontextmanager` et :ref:`context-managers`."
#: library/contextlib.rst:17
msgid "Utilities"
msgstr "Utilitaires"
#: library/contextlib.rst:19
msgid "Functions and classes provided:"
msgstr "Fonctions et classes fournies :"
#: library/contextlib.rst:23
msgid ""
"An :term:`abstract base class` for classes that "
"implement :meth:`object.__enter__` and :meth:`object.__exit__`. A default "
"implementation for :meth:`object.__enter__` is provided which returns "
"``self`` while :meth:`object.__exit__` is an abstract method which by "
"default returns ``None``. See also the definition "
"of :ref:`typecontextmanager`."
msgstr ""
":term:`Classe mère abstraite <abstract base class>` pour les classes qui "
"implémentent les méthodes :meth:`object.__enter__` "
"et :meth:`object.__exit__`. Une implémentation par défaut "
"de :meth:`object.__enter__` est fournie, qui renvoie ``self``, "
"et :meth:`object.__exit__` est une méthode abstraite qui renvoie ``None`` "
"par défaut. Voir aussi la définition de :ref:`typecontextmanager`."
#: library/contextlib.rst:34
msgid ""
"An :term:`abstract base class` for classes that "
"implement :meth:`object.__aenter__` and :meth:`object.__aexit__`. A default "
"implementation for :meth:`object.__aenter__` is provided which returns "
"``self`` while :meth:`object.__aexit__` is an abstract method which by "
"default returns ``None``. See also the definition of :ref:`async-context-"
"managers`."
msgstr ""
":term:`Classe mère abstraite <abstract base class>` pour les classes qui "
"implémentent les méthodes :meth:`object.__aenter__` "
"et :meth:`object.__aexit__`. Une implémentation par défaut "
"de :meth:`object.__aenter__` est fournie, qui renvoie ``self``, "
"et :meth:`object.__aexit__` est une méthode abstraite qui renvoie ``None`` "
"par défaut. Voir aussi la définition de :ref:`async-context-managers`."
#: library/contextlib.rst:46
#, fuzzy
msgid ""
"This function is a :term:`decorator` that can be used to define a factory "
"function for :keyword:`with` statement context managers, without needing to "
"create a class or separate :meth:`~object.__enter__` "
"and :meth:`~object.__exit__` methods."
msgstr ""
"Cette fonction est un :term:`decorator` qui peut être utilisé pour définir "
"une fonction fabriquant des gestionnaires de contexte à utiliser "
"avec :keyword:`with`, sans nécessiter de créer une classe ou des "
"méthodes :meth:`__enter__` et :meth:`__exit__` séparées."
#: library/contextlib.rst:50
#, fuzzy
msgid ""
"While many objects natively support use in with statements, sometimes a "
"resource needs to be managed that isn't a context manager in its own right, "
"and doesn't implement a ``close()`` method for use with "
"``contextlib.closing``."
msgstr ""
"Alors que de nombreux objets s'utilisent nativement dans des blocs *with*, "
"on trouve parfois des ressources qui nécessitent d'être gérées mais ne sont "
"pas des gestionnaires de contextes, et qui n'implémentent pas de méthode "
"``close()`` pour pouvoir être utilisées avec ``contextlib.closing``"
#: library/contextlib.rst:54
msgid ""
"An abstract example would be the following to ensure correct resource "
"management::"
msgstr ""
"L'exemple abstrait suivant présente comment assurer une gestion correcte des "
"ressources ::"
#: library/contextlib.rst:69
msgid "The function can then be used like this::"
msgstr ""
#: library/contextlib.rst:75
msgid ""
"The function being decorated must return a :term:`generator`-iterator when "
"called. This iterator must yield exactly one value, which will be bound to "
"the targets in the :keyword:`with` statement's :keyword:`!as` clause, if any."
msgstr ""
"La fonction à décorer doit renvoyer un :term:`générateur <generator>`-"
"itérateur quand elle est appelée. Ce générateur ne doit produire qu'une "
"seule valeur, qui est récupérée dans le bloc :keyword:`with` à l'aide de la "
"clause :keyword:`!as` si précisée."
#: library/contextlib.rst:79
msgid ""
"At the point where the generator yields, the block nested in "
"the :keyword:`with` statement is executed. The generator is then resumed "
"after the block is exited. If an unhandled exception occurs in the block, it "
"is reraised inside the generator at the point where the yield occurred. "
"Thus, you can use a :keyword:`try`...\\ :keyword:`except`..."
"\\ :keyword:`finally` statement to trap the error (if any), or ensure that "
"some cleanup takes place. If an exception is trapped merely in order to log "
"it or to perform some action (rather than to suppress it entirely), the "
"generator must reraise that exception. Otherwise the generator context "
"manager will indicate to the :keyword:`!with` statement that the exception "
"has been handled, and execution will resume with the statement immediately "
"following the :keyword:`!with` statement."
msgstr ""
"Au moment où le générateur produit une valeur, le bloc imbriqué sous "
"l'instruction :keyword:`with` est exécuté. Le générateur est ensuite repris "
"après la sortie du bloc. Si une exception non gérée survient dans le bloc, "
"elle est relayée dans le générateur au niveau de l'instruction *yield*. "
"Ainsi, vous pouvez utiliser les instructions :keyword:`try`…"
"\\ :keyword:`except`…\\ :keyword:`finally` pour attraper l'erreur (s'il y "
"a), ou vous assurer qu'un nettoyage a bien lieu. Si une exception est "
"attrapée dans l'unique but d'être journalisée ou d'effectuer une action "
"particulière (autre que supprimer entièrement l'exception), le générateur se "
"doit de la relayer. Autrement le générateur gestionnaire de contexte doit "
"indiquer à l'instruction :keyword:`!with` que l'exception a été gérée, et "
"l'exécution reprend sur l'instruction qui suit directement le "
"bloc :keyword:`!with`."
#: library/contextlib.rst:91
msgid ""
":func:`contextmanager` uses :class:`ContextDecorator` so the context "
"managers it creates can be used as decorators as well as in :keyword:`with` "
"statements. When used as a decorator, a new generator instance is implicitly "
"created on each function call (this allows the otherwise \"one-shot\" "
"context managers created by :func:`contextmanager` to meet the requirement "
"that context managers support multiple invocations in order to be used as "
"decorators)."
msgstr ""
"Le décorateur :func:`contextmanager` utilise la "
"classe :class:`ContextDecorator` afin que les gestionnaires de contexte "
"qu'il crée puissent être utilisés aussi bien en tant que décorateurs qu'avec "
"des instructions :keyword:`with`. Quand vous l'utilisez comme décorateur, "
"une nouvelle instance du générateur est créée à chaque appel de la fonction "
"(cela permet aux gestionnaires de contexte à usage unique créés "
"par :func:`contextmanager` de remplir la condition de pouvoir être invoqués "
"plusieurs fois afin d'être utilisés comme décorateurs)."
#: library/contextlib.rst:98
msgid "Use of :class:`ContextDecorator`."
msgstr "Utilisation de la classe :class:`ContextDecorator`."
#: library/contextlib.rst:104
msgid ""
"Similar to :func:`~contextlib.contextmanager`, but creates "
"an :ref:`asynchronous context manager <async-context-managers>`."
msgstr ""
"Similaire à :func:`~contextlib.contextmanager`, mais crée "
"un :ref:`gestionnaire de contexte asynchrone <async-context-managers>`."
#: library/contextlib.rst:107
#, fuzzy
msgid ""
"This function is a :term:`decorator` that can be used to define a factory "
"function for :keyword:`async with` statement asynchronous context managers, "
"without needing to create a class or separate :meth:`~object.__aenter__` "
"and :meth:`~object.__aexit__` methods. It must be applied to "
"an :term:`asynchronous generator` function."
msgstr ""
"Cette fonction est un :term:`decorator` qui peut être utilisé pour définir "
"une fonction fabriquant des gestionnaires de contexte asynchrones à utiliser "
"avec :keyword:`async with`, sans nécessiter de créer une classe ou des "
"méthodes :meth:`__aenter__` et :meth:`__aexit__` séparées. Le décorateur "
"doit être appliqué à une fonction renvoyant un :term:`asynchronous "
"generator`."
#: library/contextlib.rst:113
msgid "A simple example::"
msgstr "Un exemple simple ::"
#: library/contextlib.rst:131
msgid ""
"Context managers defined with :func:`asynccontextmanager` can be used either "
"as decorators or with :keyword:`async with` statements::"
msgstr ""
"Les gestionnaires de contexte définis avec :func:`asynccontextmanager` "
"peuvent s'utiliser comme décorateurs ou dans les "
"instructions :keyword:`async with` ::"
#: library/contextlib.rst:149
msgid ""
"When used as a decorator, a new generator instance is implicitly created on "
"each function call. This allows the otherwise \"one-shot\" context managers "
"created by :func:`asynccontextmanager` to meet the requirement that context "
"managers support multiple invocations in order to be used as decorators."
msgstr ""
#: library/contextlib.rst:154
#, fuzzy
msgid ""
"Async context managers created with :func:`asynccontextmanager` can be used "
"as decorators."
msgstr ""
"Une classe mère qui permet à un gestionnaire de contexte d'être aussi "
"utilisé comme décorateur."
#: library/contextlib.rst:161
msgid ""
"Return a context manager that closes *thing* upon completion of the block. "
"This is basically equivalent to::"
msgstr ""
"Renvoie un gestionnaire de contexte qui ferme *thing* à la fin du bloc. "
"C'est essentiellement équivalent à ::"
#: library/contextlib.rst:173
msgid "And lets you write code like this::"
msgstr "Et cela vous permet d'écrire du code tel que ::"
#: library/contextlib.rst:182
msgid ""
"without needing to explicitly close ``page``. Even if an error occurs, "
"``page.close()`` will be called when the :keyword:`with` block is exited."
msgstr ""
"sans besoin de fermer explicitement ``page``. Même si une erreur survient, "
"``page.close()`` est appelée à la fermeture du bloc :keyword:`with`."
#: library/contextlib.rst:187
msgid ""
"Most types managing resources support the :term:`context manager` protocol, "
"which closes *thing* on leaving the :keyword:`with` statement. As "
"such, :func:`!closing` is most useful for third party types that don't "
"support context managers. This example is purely for illustration purposes, "
"as :func:`~urllib.request.urlopen` would normally be used in a context "
"manager."
msgstr ""
#: library/contextlib.rst:196
#, fuzzy
msgid ""
"Return an async context manager that calls the ``aclose()`` method of "
"*thing* upon completion of the block. This is basically equivalent to::"
msgstr ""
"Renvoie un gestionnaire de contexte qui ferme *thing* à la fin du bloc. "
"C'est essentiellement équivalent à ::"
#: library/contextlib.rst:208
msgid ""
"Significantly, ``aclosing()`` supports deterministic cleanup of async "
"generators when they happen to exit early by :keyword:`break` or an "
"exception. For example::"
msgstr ""
#: library/contextlib.rst:219
msgid ""
"This pattern ensures that the generator's async exit code is executed in the "
"same context as its iterations (so that exceptions and context variables "
"work as expected, and the exit code isn't run after the lifetime of some "
"task it depends on)."
msgstr ""
#: library/contextlib.rst:231
msgid ""
"Return a context manager that returns *enter_result* from ``__enter__``, but "
"otherwise does nothing. It is intended to be used as a stand-in for an "
"optional context manager, for example::"
msgstr ""
"Renvoie un gestionnaire de contexte dont la méthode ``__enter__`` renvoie "
"*enter_result*, mais ne fait rien d'autre. L'idée est de l'utiliser comme "
"remplaçant pour un gestionnaire de contexte optionnel, par exemple ::"
#: library/contextlib.rst:245
msgid "An example using *enter_result*::"
msgstr "Un exemple utilisant *enter_result* ::"
#: library/contextlib.rst:258
#, fuzzy
msgid ""
"It can also be used as a stand-in for :ref:`asynchronous context managers "
"<async-context-managers>`::"
msgstr ""
"Similaire à :func:`~contextlib.contextmanager`, mais crée "
"un :ref:`gestionnaire de contexte asynchrone <async-context-managers>` ::"
#: library/contextlib.rst:274
msgid ":term:`asynchronous context manager` support was added."
msgstr ""
#: library/contextlib.rst:281
#, fuzzy
msgid ""
"Return a context manager that suppresses any of the specified exceptions if "
"they occur in the body of a :keyword:`!with` statement and then resumes "
"execution with the first statement following the end of the :keyword:`!with` "
"statement."
msgstr ""
"Renvoie un gestionnaire de contexte qui supprime toutes les exceptions "
"spécifiées si elles surviennent dans le corps du bloc *with*, et reprend "
"l'exécution sur la première instruction qui suit la fin du bloc *with*."
#: library/contextlib.rst:286
msgid ""
"As with any other mechanism that completely suppresses exceptions, this "
"context manager should be used only to cover very specific errors where "
"silently continuing with program execution is known to be the right thing to "
"do."
msgstr ""
"Comme pour tous les mécanismes qui suppriment complètement les exceptions, "
"ce gestionnaire de contexte doit seulement être utilisé pour couvrir des cas "
"très spécifiques d'erreurs où il est certain que continuer silencieusement "
"l'exécution du programme est la bonne chose à faire."
#: library/contextlib.rst:291
msgid "For example::"
msgstr "Par exemple ::"
#: library/contextlib.rst:301
msgid "This code is equivalent to::"
msgstr "Ce code est équivalent à ::"
#: library/contextlib.rst:362 library/contextlib.rst:389
msgid "This context manager is :ref:`reentrant <reentrant-cms>`."
msgstr "Ce gestionnaire de contexte est :ref:`réentrant <reentrant-cms>`."
#: library/contextlib.rst:315
msgid ""
"If the code within the :keyword:`!with` block raises "
"a :exc:`BaseExceptionGroup`, suppressed exceptions are removed from the "
"group. Any exceptions of the group which are not suppressed are re-raised "
"in a new group which is created using the original "
"group's :meth:`~BaseExceptionGroup.derive` method."
msgstr ""
#: library/contextlib.rst:323
msgid ""
"``suppress`` now supports suppressing exceptions raised as part of "
"a :exc:`BaseExceptionGroup`."
msgstr ""
#: library/contextlib.rst:329
msgid ""
"Context manager for temporarily redirecting :data:`sys.stdout` to another "
"file or file-like object."
msgstr ""
"Gestionnaire de contexte servant à rediriger "
"temporairement :data:`sys.stdout` vers un autre fichier ou objet fichier-"
"compatible."
#: library/contextlib.rst:332
msgid ""
"This tool adds flexibility to existing functions or classes whose output is "
"hardwired to stdout."
msgstr ""
"Cet outil ajoute une certaine flexibilité aux fonctions ou classes "
"existantes dont la sortie est envoyée vers la sortie standard."
#: library/contextlib.rst:335
#, fuzzy
msgid ""
"For example, the output of :func:`help` normally is sent to *sys.stdout*. "
"You can capture that output in a string by redirecting the output to "
"an :class:`io.StringIO` object. The replacement stream is returned from the "
"``__enter__`` method and so is available as the target of "
"the :keyword:`with` statement::"
msgstr ""
"Par exemple, la sortie de :func:`help` est normalement envoyée vers "
"*sys.stdout*. Vous pouvez capturer cette sortie dans une chaîne de "
"caractères en la redirigeant vers un objet :class:`io.StringIO` ::"
#: library/contextlib.rst:345
msgid ""
"To send the output of :func:`help` to a file on disk, redirect the output to "
"a regular file::"
msgstr ""
"Pour envoyer la sortie de :func:`help` vers un fichier sur le disque, "
"redirigez-la sur un fichier normal ::"
#: library/contextlib.rst:352
msgid "To send the output of :func:`help` to *sys.stderr*::"
msgstr "Pour envoyer la sortie de :func:`help` sur *sys.stderr* ::"
#: library/contextlib.rst:357
msgid ""
"Note that the global side effect on :data:`sys.stdout` means that this "
"context manager is not suitable for use in library code and most threaded "
"applications. It also has no effect on the output of subprocesses. However, "
"it is still a useful approach for many utility scripts."
msgstr ""
"Notez que l'effet de bord global sur :data:`sys.stdout` signifie que ce "
"gestionnaire de contexte n'est pas adapté à une utilisation dans le code "
"d'une bibliothèque ni dans la plupart des applications à plusieurs fils "
"d'exécution. Aussi, cela n'a pas d'effet sur la sortie des sous-processus. "
"Cependant, cela reste une approche utile pour beaucoup de scripts "
"utilitaires."
#: library/contextlib.rst:369
msgid ""
"Similar to :func:`~contextlib.redirect_stdout` but "
"redirecting :data:`sys.stderr` to another file or file-like object."
msgstr ""
"Similaire à :func:`~contextlib.redirect_stdout` mais "
"redirige :data:`sys.stderr` vers un autre fichier ou objet fichier-"
"compatible."
#: library/contextlib.rst:379
msgid ""
"Non parallel-safe context manager to change the current working directory. "
"As this changes a global state, the working directory, it is not suitable "
"for use in most threaded or async contexts. It is also not suitable for most "
"non-linear code execution, like generators, where the program execution is "
"temporarily relinquished -- unless explicitly desired, you should not yield "
"when this context manager is active."
msgstr ""
#: library/contextlib.rst:386
msgid ""
"This is a simple wrapper around :func:`~os.chdir`, it changes the current "
"working directory upon entering and restores the old one on exit."
msgstr ""
#: library/contextlib.rst:396
msgid ""
"A base class that enables a context manager to also be used as a decorator."
msgstr ""
"Une classe mère qui permet à un gestionnaire de contexte d'être aussi "
"utilisé comme décorateur."
#: library/contextlib.rst:398
msgid ""
"Context managers inheriting from ``ContextDecorator`` have to implement "
"``__enter__`` and ``__exit__`` as normal. ``__exit__`` retains its optional "
"exception handling even when used as a decorator."
msgstr ""
"Les gestionnaires de contexte héritant de ``ContextDecorator`` doivent "
"implémenter ``__enter__`` et ``__exit__`` comme habituellement. ``__exit__`` "
"conserve sa gestion optionnelle des exceptions même lors de l'utilisation en "
"décorateur."
#: library/contextlib.rst:402
msgid ""
"``ContextDecorator`` is used by :func:`contextmanager`, so you get this "
"functionality automatically."
msgstr ""
"``ContextDecorator`` est utilisé par :func:`contextmanager`, donc vous "
"bénéficiez automatiquement de cette fonctionnalité."
#: library/contextlib.rst:405
msgid "Example of ``ContextDecorator``::"
msgstr "Exemple de ``ContextDecorator`` ::"
#: library/contextlib.rst:490
msgid "The class can then be used like this::"
msgstr ""
#: library/contextlib.rst:436
msgid ""
"This change is just syntactic sugar for any construct of the following form::"
msgstr ""
"Ce changement est simplement un sucre syntaxique pour les constructions de "
"la forme suivante ::"
#: library/contextlib.rst:442
msgid "``ContextDecorator`` lets you instead write::"
msgstr "``ContextDecorator`` vous permet d'écrire à la place ::"
#: library/contextlib.rst:448
msgid ""
"It makes it clear that the ``cm`` applies to the whole function, rather than "
"just a piece of it (and saving an indentation level is nice, too)."
msgstr ""
"Cela éclaircit le fait que ``cm`` s'applique à la fonction entière, et pas "
"seulement à un morceau en particulier (et gagner un niveau d'indentation est "
"toujours appréciable)."
#: library/contextlib.rst:451
msgid ""
"Existing context managers that already have a base class can be extended by "
"using ``ContextDecorator`` as a mixin class::"
msgstr ""
"Les gestionnaires de contexte existants qui ont déjà une classe mère peuvent "
"être étendus en utilisant ``ContextDecorator`` comme une *mixin* ::"
#: library/contextlib.rst:464
msgid ""
"As the decorated function must be able to be called multiple times, the "
"underlying context manager must support use in multiple :keyword:`with` "
"statements. If this is not the case, then the original construct with the "
"explicit :keyword:`!with` statement inside the function should be used."
msgstr ""
"Comme la fonction décorée doit être capable d'être appelée plusieurs fois, "
"le gestionnaire de contexte sous-jacent doit permettre d'être utilisé dans "
"de multiples instructions :keyword:`with`. Si ce n'est pas le cas, alors la "
"construction d'origine avec de multiples instructions :keyword:`!with` au "
"sein de la fonction doit être utilisée."
#: library/contextlib.rst:474
#, fuzzy
msgid ""
"Similar to :class:`ContextDecorator` but only for asynchronous functions."
msgstr ""
"Similaire à :meth:`enter_context` mais attend un gestionnaire de contexte "
"asynchrone."
#: library/contextlib.rst:476
#, fuzzy
msgid "Example of ``AsyncContextDecorator``::"
msgstr "Exemple de ``ContextDecorator`` ::"
#: library/contextlib.rst:515
msgid ""
"A context manager that is designed to make it easy to programmatically "
"combine other context managers and cleanup functions, especially those that "
"are optional or otherwise driven by input data."
msgstr ""
"Gestionnaire de contexte conçu pour simplifier le fait de combiner "
"programmatiquement d'autres gestionnaires de contexte et fonctions de "
"nettoyage, spécifiquement ceux qui sont optionnels ou pilotés par des "
"données d'entrée."
#: library/contextlib.rst:519
msgid ""
"For example, a set of files may easily be handled in a single with statement "
"as follows::"
msgstr ""
"Par exemple, un ensemble de fichiers peut facilement être géré dans une "
"unique instruction *with* comme suit ::"
#: library/contextlib.rst:528
msgid ""
"The :meth:`~object.__enter__` method returns the :class:`ExitStack` "
"instance, and performs no additional operations."
msgstr ""
#: library/contextlib.rst:531
msgid ""
"Each instance maintains a stack of registered callbacks that are called in "
"reverse order when the instance is closed (either explicitly or implicitly "
"at the end of a :keyword:`with` statement). Note that callbacks are *not* "
"invoked implicitly when the context stack instance is garbage collected."
msgstr ""
"Chaque instance maintient une pile de fonctions de rappels (*callbacks*) "
"enregistrées qui sont appelées en ordre inverse quand l'instance est fermée "
"(explicitement ou implicitement à la fin d'un bloc :keyword:`with`). Notez "
"que ces fonctions ne sont *pas* invoquées implicitement quand l'instance de "
"la pile de contextes est collectée par le ramasse-miettes."
#: library/contextlib.rst:536
msgid ""
"This stack model is used so that context managers that acquire their "
"resources in their ``__init__`` method (such as file objects) can be handled "
"correctly."
msgstr ""
"Ce modèle de pile est utilisé afin que les gestionnaires de contexte qui "
"acquièrent leurs ressources dans leur méthode ``__init__`` (tels que les "
"objets-fichiers) puissent être gérés correctement."
#: library/contextlib.rst:540
msgid ""
"Since registered callbacks are invoked in the reverse order of registration, "
"this ends up behaving as if multiple nested :keyword:`with` statements had "
"been used with the registered set of callbacks. This even extends to "
"exception handling - if an inner callback suppresses or replaces an "
"exception, then outer callbacks will be passed arguments based on that "
"updated state."
msgstr ""
"Comme les fonctions de rappel enregistrées sont invoquées dans l'ordre "
"inverse d'enregistrement, cela revient au même que si de multiples "
"blocs :keyword:`with` imbriqués avaient été utilisés avec l'ensemble de "
"fonctions enregistrées. Cela s'étend aussi à la gestion d'exceptions — si "
"une fonction de rappel intérieure supprime ou remplace une exception, alors "
"les fonctions extérieures reçoivent des arguments basés sur ce nouvel état."
#: library/contextlib.rst:547
msgid ""
"This is a relatively low level API that takes care of the details of "
"correctly unwinding the stack of exit callbacks. It provides a suitable "
"foundation for higher level context managers that manipulate the exit stack "
"in application specific ways."
msgstr ""
"C'est une *API* relativement bas-niveau qui s'occupe de dérouler "
"correctement la pile des appels de sortie. Elle fournit une base adaptée "
"pour des gestionnaires de contexte de plus haut niveau qui manipulent la "
"pile de sortie de manière spécifique à l'application."
#: library/contextlib.rst:556
#, fuzzy
msgid ""
"Enters a new context manager and adds its :meth:`~object.__exit__` method to "
"the callback stack. The return value is the result of the context manager's "
"own :meth:`~object.__enter__` method."
msgstr ""
"Entre dans un nouveau gestionnaire de contexte et ajoute sa "
"méthode :meth:`__exit__` à la pile d'appels. La valeur de retour est le "
"résultat de la méthode :meth:`__enter__` du gestionnaire de contexte donné."
#: library/contextlib.rst:560
msgid ""
"These context managers may suppress exceptions just as they normally would "
"if used directly as part of a :keyword:`with` statement."
msgstr ""
"Ces gestionnaires de contexte peuvent supprimer des exceptions comme ils le "
"feraient normalement s'ils étaient utilisés directement derrière une "
"instruction :keyword:`with`."
#: library/contextlib.rst:563
msgid ""
"Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not a "
"context manager."
msgstr ""
#: library/contextlib.rst:569
#, fuzzy
msgid ""
"Adds a context manager's :meth:`~object.__exit__` method to the callback "
"stack."
msgstr ""
"Ajoute la méthode :meth:`__exit__` d'un gestionnaire de contexte à la pile "
"d'appels."
#: library/contextlib.rst:571
#, fuzzy
msgid ""
"As ``__enter__`` is *not* invoked, this method can be used to cover part of "
"an :meth:`~object.__enter__` implementation with a context manager's "
"own :meth:`~object.__exit__` method."
msgstr ""
"Comme ``__enter__`` n'est *pas* invoquée, cette méthode peut être utilisée "
"pour couvrir une partie de l'implémentation de :meth:`__enter__` avec la "
"propre méthode :meth:`__exit__` d'un gestionnaire de contexte."
#: library/contextlib.rst:575
#, fuzzy
msgid ""
"If passed an object that is not a context manager, this method assumes it is "
"a callback with the same signature as a context "
"manager's :meth:`~object.__exit__` method and adds it directly to the "
"callback stack."
msgstr ""
"Si l'argument passé n'est pas un gestionnaire de contexte, la méthode assume "
"qu'il s'agit d'une fonction de rappel avec la même signature que la "
"méthode :meth:`__exit__` des gestionnaires de contexte pour l'ajouter "
"directement à la pile d'appels."
#: library/contextlib.rst:579
#, fuzzy
msgid ""
"By returning true values, these callbacks can suppress exceptions the same "
"way context manager :meth:`~object.__exit__` methods can."
msgstr ""
"En retournant des valeurs vraies, ces fonctions peuvent supprimer des "
"exceptions de la même manière que le peuvent les méthodes :meth:`__exit__` "
"des gestionnaires de contexte."
#: library/contextlib.rst:582
msgid ""
"The passed in object is returned from the function, allowing this method to "
"be used as a function decorator."
msgstr ""
"L'objet passé en paramètre est renvoyé par la fonction, ce qui permet à la "
"méthode d'être utilisée comme décorateur de fonction."
#: library/contextlib.rst:587
msgid ""
"Accepts an arbitrary callback function and arguments and adds it to the "
"callback stack."
msgstr ""
"Accepte une fonction arbitraire et ses arguments et les ajoute à la pile des "
"fonctions de rappel."
#: library/contextlib.rst:590
msgid ""
"Unlike the other methods, callbacks added this way cannot suppress "
"exceptions (as they are never passed the exception details)."
msgstr ""
"À la différence des autres méthodes, les fonctions de rappel ajoutées de "
"cette manière ne peuvent pas supprimer les exceptions (puisqu'elles ne "
"reçoivent jamais les détails de l'exception)."
#: library/contextlib.rst:593
msgid ""
"The passed in callback is returned from the function, allowing this method "
"to be used as a function decorator."
msgstr ""
"La fonction passée en paramètre est renvoyée par la méthode, ce qui permet à "
"la méthode d'être utilisée comme décorateur de fonction."
#: library/contextlib.rst:598
msgid ""
"Transfers the callback stack to a fresh :class:`ExitStack` instance and "
"returns it. No callbacks are invoked by this operation - instead, they will "
"now be invoked when the new stack is closed (either explicitly or implicitly "
"at the end of a :keyword:`with` statement)."
msgstr ""
"Transfère la pile d'appels à une nouvelle instance de :class:`ExitStack` et "
"la renvoie. Aucune fonction de rappel n'est invoquée par cette opération — à "
"la place, elles sont dorénavant invoquées quand la nouvelle pile sera close "
"(soit explicitement soit implicitement à la fin d'un bloc :keyword:`with`)."
#: library/contextlib.rst:603
msgid ""
"For example, a group of files can be opened as an \"all or nothing\" "
"operation as follows::"
msgstr ""
"Par exemple, un groupe de fichiers peut être ouvert comme une opération "
"« tout ou rien » comme suit ::"
#: library/contextlib.rst:617
msgid ""
"Immediately unwinds the callback stack, invoking callbacks in the reverse "
"order of registration. For any context managers and exit callbacks "
"registered, the arguments passed in will indicate that no exception occurred."
msgstr ""
"Déroule immédiatement la pile d'appels, invoquant les fonctions de rappel "
"dans l'ordre inverse d'enregistrement. Pour chaque gestionnaire de contexte "
"et fonction de sortie enregistré, les arguments passés indiqueront qu'aucune "
"exception n'est survenue."
#: library/contextlib.rst:624
msgid ""
"An :ref:`asynchronous context manager <async-context-managers>`, similar "
"to :class:`ExitStack`, that supports combining both synchronous and "
"asynchronous context managers, as well as having coroutines for cleanup "
"logic."
msgstr ""
"Un :ref:`gestionnaire de contexte asynchrone <async-context-managers>`, "
"similaire à :class:`ExitStack`, apte à combiner à la fois des gestionnaires "
"de contexte synchrones et asynchrones, ainsi que la gestion de coroutines "
"pour la logique de nettoyage."
#: library/contextlib.rst:629
#, fuzzy
msgid ""
"The :meth:`~ExitStack.close` method is not implemented; :meth:`aclose` must "
"be used instead."
msgstr ""
"La méthode :meth:`close` n'est pas implémentée, :meth:`aclose` doit plutôt "
"être utilisée."
#: library/contextlib.rst:635
#, fuzzy
msgid ""
"Similar to :meth:`ExitStack.enter_context` but expects an asynchronous "
"context manager."
msgstr ""
"Similaire à :meth:`enter_context` mais attend un gestionnaire de contexte "
"asynchrone."
#: library/contextlib.rst:638
msgid ""
"Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an "
"asynchronous context manager."
msgstr ""
#: library/contextlib.rst:644
#, fuzzy
msgid ""
"Similar to :meth:`ExitStack.push` but expects either an asynchronous context "
"manager or a coroutine function."
msgstr ""
"Similaire à :meth:`push` mais attend soit un gestionnaire de contexte "
"asynchrone soit une fonction coroutine."
#: library/contextlib.rst:649
#, fuzzy
msgid "Similar to :meth:`ExitStack.callback` but expects a coroutine function."
msgstr "Similaire à :meth:`callback` mais attend une fonction coroutine."
#: library/contextlib.rst:654
#, fuzzy
msgid "Similar to :meth:`ExitStack.close` but properly handles awaitables."
msgstr ""
"Similaire à :meth:`close` mais gère correctement les tâches asynchrones."
#: library/contextlib.rst:656
msgid "Continuing the example for :func:`asynccontextmanager`::"
msgstr "En continuité de l'exemple de :func:`asynccontextmanager` ::"
#: library/contextlib.rst:668
msgid "Examples and Recipes"
msgstr "Exemples et Recettes"
#: library/contextlib.rst:670
msgid ""
"This section describes some examples and recipes for making effective use of "
"the tools provided by :mod:`contextlib`."
msgstr ""
"Cette section décrit quelques exemples et recettes pour décrire une "
"utilisation réelle des outils fournis par :mod:`contextlib`."
#: library/contextlib.rst:675
msgid "Supporting a variable number of context managers"
msgstr "Gérer un nombre variable de gestionnaires de contexte"
#: library/contextlib.rst:677
msgid ""
"The primary use case for :class:`ExitStack` is the one given in the class "
"documentation: supporting a variable number of context managers and other "
"cleanup operations in a single :keyword:`with` statement. The variability "
"may come from the number of context managers needed being driven by user "
"input (such as opening a user specified collection of files), or from some "
"of the context managers being optional::"
msgstr ""
"Le cas d'utilisation primaire de :class:`ExitStack` est celui décrit dans la "
"documentation de la classe : gérer un nombre variable de gestionnaires de "
"contexte et d'autres opérations de nettoyage en une unique "
"instruction :keyword:`with`. La variabilité peut venir du nombre de "
"gestionnaires de contexte voulus découlant d'une entrée de l'utilisateur "
"(comme ouvrir une collection spécifique de fichiers de l'utilisateur), ou de "
"certains gestionnaires de contexte qui peuvent être optionnels ::"
#: library/contextlib.rst:692
msgid ""
"As shown, :class:`ExitStack` also makes it quite easy to use :keyword:`with` "
"statements to manage arbitrary resources that don't natively support the "
"context management protocol."
msgstr ""
"Comme montré, :class:`ExitStack` rend aussi assez facile d'utiliser les "
"instructions :keyword:`with` pour gérer des ressources arbitraires qui ne "
"gèrent pas nativement le protocole des gestionnaires de contexte."
#: library/contextlib.rst:698
msgid "Catching exceptions from ``__enter__`` methods"
msgstr "Attraper des exceptions depuis les méthodes ``__enter__``"
#: library/contextlib.rst:700
msgid ""
"It is occasionally desirable to catch exceptions from an ``__enter__`` "
"method implementation, *without* inadvertently catching exceptions from "
"the :keyword:`with` statement body or the context manager's ``__exit__`` "
"method. By using :class:`ExitStack` the steps in the context management "
"protocol can be separated slightly in order to allow this::"
msgstr ""
"Il est occasionnellement souhaitable d'attraper les exceptions depuis "
"l'implémentation d'une méthode ``__enter__``, *sans* attraper par "
"inadvertance les exceptions du corps de l'instruction :keyword:`with` ou de "
"la méthode ``__exit__`` des gestionnaires de contexte. En "
"utilisant :class:`ExitStack`, les étapes du protocole des gestionnaires de "
"contexte peuvent être légèrement séparées pour permettre le code suivant ::"
#: library/contextlib.rst:715
msgid ""
"Actually needing to do this is likely to indicate that the underlying API "
"should be providing a direct resource management interface for use "
"with :keyword:`try`/:keyword:`except`/:keyword:`finally` statements, but not "
"all APIs are well designed in that regard. When a context manager is the "
"only resource management API provided, then :class:`ExitStack` can make it "
"easier to handle various situations that can't be handled directly in "
"a :keyword:`with` statement."
msgstr ""
"Avoir à faire cela est en fait surtout utile pour indiquer que l'*API* sous-"
"jacente devrait fournir une interface directe de gestion des ressources à "
"utiliser avec les "
"instructions :keyword:`try`/:keyword:`except`/:keyword:`finally`, mais que "
"toutes les *API* ne sont pas bien conçues dans cet objectif. Quand un "
"gestionnaire de contexte est la seule *API* de gestion des ressources "
"fournie, alors :class:`ExitStack` peut rendre plus facile la gestion de "
"plusieurs situations qui ne peuvent pas être traitées directement dans une "
"instruction :keyword:`with`."
#: library/contextlib.rst:725
msgid "Cleaning up in an ``__enter__`` implementation"
msgstr "Nettoyer dans une méthode ``__enter__``"
#: library/contextlib.rst:727
#, fuzzy
msgid ""
"As noted in the documentation of :meth:`ExitStack.push`, this method can be "
"useful in cleaning up an already allocated resource if later steps in "
"the :meth:`~object.__enter__` implementation fail."
msgstr ""
"Comme indiqué dans la documentation de :meth:`ExitStack.push`, cette méthode "
"peut être utile pour nettoyer une ressource déjà allouée si les dernières "
"étapes de l'implémentation de :meth:`__enter__` échouent."
#: library/contextlib.rst:731
msgid ""
"Here's an example of doing this for a context manager that accepts resource "
"acquisition and release functions, along with an optional validation "
"function, and maps them to the context management protocol::"
msgstr ""
"Voici un exemple de gestionnaire de contexte qui reçoit des fonctions "
"d'acquisition de ressources et de libération, avec une méthode de validation "
"optionnelle, et qui les adapte au protocole des gestionnaires de contexte ::"
#: library/contextlib.rst:771
msgid "Replacing any use of ``try-finally`` and flag variables"
msgstr "Remplacer un ``try-finally`` avec une option variable"
#: library/contextlib.rst:773
msgid ""
"A pattern you will sometimes see is a ``try-finally`` statement with a flag "
"variable to indicate whether or not the body of the ``finally`` clause "
"should be executed. In its simplest form (that can't already be handled just "
"by using an ``except`` clause instead), it looks something like this::"
msgstr ""
"Un modèle que vous rencontrerez parfois est un bloc ``try-finally`` avec une "
"option pour indiquer si le corps de la clause ``finally`` doit être exécuté "
"ou non. Dans sa forme la plus simple (qui ne peut pas déjà être gérée avec "
"juste une clause ``except``), cela ressemble à ::"
#: library/contextlib.rst:787
msgid ""
"As with any ``try`` statement based code, this can cause problems for "
"development and review, because the setup code and the cleanup code can end "
"up being separated by arbitrarily long sections of code."
msgstr ""
"Comme avec n'importe quel code basé sur une instruction ``try``, cela peut "
"poser problème pour le développement et la revue, parce que beaucoup de "
"codes d'installation et de nettoyage peuvent finir par être séparés par des "
"sections de code arbitrairement longues."
#: library/contextlib.rst:791
msgid ""
":class:`ExitStack` makes it possible to instead register a callback for "
"execution at the end of a ``with`` statement, and then later decide to skip "
"executing that callback::"
msgstr ""
":class:`ExitStack` rend possible de plutôt enregistrer une fonction de "
"rappel pour être exécutée à la fin d'une instruction ``with``, et décider "
"ensuite de passer l'exécution de cet appel ::"
#: library/contextlib.rst:803
#, fuzzy
msgid ""
"This allows the intended cleanup behaviour to be made explicit up front, "
"rather than requiring a separate flag variable."
msgstr ""
"Cela permet de rendre explicite dès le départ le comportement de nettoyage "
"attendu, plutôt que de nécessiter une option séparée."
#: library/contextlib.rst:806
msgid ""
"If a particular application uses this pattern a lot, it can be simplified "
"even further by means of a small helper class::"
msgstr ""
"Si une application particulière utilise beaucoup ce modèle, cela peut-être "
"simplifié encore plus au moyen d'une petite classe d'aide ::"
#: library/contextlib.rst:824
msgid ""
"If the resource cleanup isn't already neatly bundled into a standalone "
"function, then it is still possible to use the decorator form "
"of :meth:`ExitStack.callback` to declare the resource cleanup in advance::"
msgstr ""
"Si le nettoyage de la ressource n'est pas déjà soigneusement embarqué dans "
"une fonction autonome, il est possible d'utiliser le "
"décorateur :meth:`ExitStack.callback` pour déclarer la fonction de nettoyage "
"de ressource en avance ::"
#: library/contextlib.rst:839
msgid ""
"Due to the way the decorator protocol works, a callback function declared "
"this way cannot take any parameters. Instead, any resources to be released "
"must be accessed as closure variables."
msgstr ""
"Dû au fonctionnement du protocole des décorateurs, une fonction déclarée "
"ainsi ne peut prendre aucun paramètre. À la place, les ressources à libérer "
"doivent être récupérées depuis l'extérieur comme des variables de fermeture "
"(*closure*)."
#: library/contextlib.rst:845
msgid "Using a context manager as a function decorator"
msgstr ""
"Utiliser un gestionnaire de contexte en tant que décorateur de fonction"
#: library/contextlib.rst:847
msgid ""
":class:`ContextDecorator` makes it possible to use a context manager in both "
"an ordinary ``with`` statement and also as a function decorator."
msgstr ""
":class:`ContextDecorator` rend possible l'utilisation d'un gestionnaire de "
"contexte à la fois ordinairement avec une instruction ``with`` ou comme un "
"décorateur de fonction."