@@ -1335,6 +1335,17 @@ msgid ""
1335
1335
" raise ValueError(\" %r has an empty name\" % (self,))\n"
1336
1336
"ValueError: PureWindowsPath('c:/') has an empty name"
1337
1337
msgstr ""
1338
+ ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n"
1339
+ ">>> p.with_name('setup.py')\n"
1340
+ "PureWindowsPath('c:/Downloads/setup.py')\n"
1341
+ ">>> p = PureWindowsPath('c:/')\n"
1342
+ ">>> p.with_name('setup.py')\n"
1343
+ "Traceback (most recent call last):\n"
1344
+ " File \" <stdin>\" , line 1, in <module>\n"
1345
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 751, in "
1346
+ "with_name\n"
1347
+ " raise ValueError(\" %r has an empty name\" % (self,))\n"
1348
+ "ValueError: PureWindowsPath('c:/') has an empty name"
1338
1349
1339
1350
#: ../../library/pathlib.rst:684
1340
1351
msgid ""
@@ -1364,6 +1375,23 @@ msgid ""
1364
1375
" raise ValueError(\" %r has an empty name\" % (self,))\n"
1365
1376
"ValueError: PureWindowsPath('c:/') has an empty name"
1366
1377
msgstr ""
1378
+ ">>> p = PureWindowsPath('c:/Downloads/draft.txt')\n"
1379
+ ">>> p.with_stem('final')\n"
1380
+ "PureWindowsPath('c:/Downloads/final.txt')\n"
1381
+ ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n"
1382
+ ">>> p.with_stem('lib')\n"
1383
+ "PureWindowsPath('c:/Downloads/lib.gz')\n"
1384
+ ">>> p = PureWindowsPath('c:/')\n"
1385
+ ">>> p.with_stem('')\n"
1386
+ "Traceback (most recent call last):\n"
1387
+ " File \" <stdin>\" , line 1, in <module>\n"
1388
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 861, in "
1389
+ "with_stem\n"
1390
+ " return self.with_name(stem + self.suffix)\n"
1391
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 851, in "
1392
+ "with_name\n"
1393
+ " raise ValueError(\" %r has an empty name\" % (self,))\n"
1394
+ "ValueError: PureWindowsPath('c:/') has an empty name"
1367
1395
1368
1396
#: ../../library/pathlib.rst:708
1369
1397
msgid ""
@@ -2215,7 +2243,7 @@ msgid ""
2215
2243
"Open the file pointed to in bytes mode, write *data* to it, and close the "
2216
2244
"file::"
2217
2245
msgstr ""
2218
- "Abre o arquivo apontado no modo bytes, escreve *dados * e fecha o arquivo::"
2246
+ "Abre o arquivo apontado no modo bytes, escreve *data * e fecha o arquivo::"
2219
2247
2220
2248
#: ../../library/pathlib.rst:1242
2221
2249
msgid "An existing file of the same name is overwritten."
@@ -2479,13 +2507,21 @@ msgid ""
2479
2507
"their targets, and consequently visit directories pointed to by symlinks "
2480
2508
"(where supported)."
2481
2509
msgstr ""
2510
+ "Por padrão, :meth:`Path.walk` não segue links simbólicos e, em vez disso, os "
2511
+ "adiciona à lista *filenames*. Defina *follow_symlinks* como true para "
2512
+ "resolver links simbólicos e colocá-los em *dirnames* e *filenames* conforme "
2513
+ "apropriado para seus alvos e, consequentemente, visitar diretórios apontados "
2514
+ "por links simbólicos (quando suportado)."
2482
2515
2483
2516
#: ../../library/pathlib.rst:1387
2484
2517
msgid ""
2485
2518
"Be aware that setting *follow_symlinks* to true can lead to infinite "
2486
2519
"recursion if a link points to a parent directory of itself. :meth:`Path."
2487
2520
"walk` does not keep track of the directories it has already visited."
2488
2521
msgstr ""
2522
+ "Esteja ciente de que definir *follow_symlinks* como true pode levar a uma "
2523
+ "recursão infinita se um link apontar para um diretório pai dele mesmo. :meth:"
2524
+ "`Path.walk` não rastreia os diretórios que já visitou."
2489
2525
2490
2526
#: ../../library/pathlib.rst:1392
2491
2527
msgid ""
@@ -2495,12 +2531,19 @@ msgid ""
2495
2531
"try to descend into it. To prevent such behavior, remove directories from "
2496
2532
"*dirnames* as appropriate."
2497
2533
msgstr ""
2534
+ ":meth:`Path.walk` presume que os diretórios que percorre não sejam "
2535
+ "modificados durante a execução. Por exemplo, se um diretório de *dirnames* "
2536
+ "tiver sido substituído por um link simbólico e *follow_symlinks* for falso, :"
2537
+ "meth:`Path.walk` ainda tentará descer até ele. Para evitar esse "
2538
+ "comportamento, remova os diretórios de *dirnames* conforme apropriado."
2498
2539
2499
2540
#: ../../library/pathlib.rst:1400
2500
2541
msgid ""
2501
2542
"Unlike :func:`os.walk`, :meth:`Path.walk` lists symlinks to directories in "
2502
2543
"*filenames* if *follow_symlinks* is false."
2503
2544
msgstr ""
2545
+ "Diferentemente de :func:`os.walk`, :meth:`Path.walk` lista links simbólicos "
2546
+ "para diretórios em *filenames* se *follow_symlinks* for falso."
2504
2547
2505
2548
#: ../../library/pathlib.rst:1403
2506
2549
msgid ""
@@ -2526,13 +2569,29 @@ msgid ""
2526
2569
" if '__pycache__' in dirs:\n"
2527
2570
" dirs.remove('__pycache__')"
2528
2571
msgstr ""
2572
+ "from pathlib import Path\n"
2573
+ "for root, dirs, files in Path(\" cpython/Lib/concurrent\" )."
2574
+ "walk(on_error=print):\n"
2575
+ " print(\n"
2576
+ " root,\n"
2577
+ " \" consumes\" ,\n"
2578
+ " sum((root / file).stat().st_size for file in files),\n"
2579
+ " \" bytes in\" ,\n"
2580
+ " len(files),\n"
2581
+ " \" non-directory files\" \n"
2582
+ " )\n"
2583
+ " if '__pycache__' in dirs:\n"
2584
+ " dirs.remove('__pycache__')"
2529
2585
2530
2586
#: ../../library/pathlib.rst:1419
2531
2587
msgid ""
2532
2588
"This next example is a simple implementation of :func:`shutil.rmtree`. "
2533
2589
"Walking the tree bottom-up is essential as :func:`rmdir` doesn't allow "
2534
2590
"deleting a directory before it is empty::"
2535
2591
msgstr ""
2592
+ "O próximo exemplo é uma implementação simples de :func:`shutil.rmtree`. "
2593
+ "Percorrer a árvore de baixo para cima é essencial, pois :func:`rmdir` não "
2594
+ "permite excluir um diretório antes que ele esteja vazio."
2536
2595
2537
2596
#: ../../library/pathlib.rst:1423
2538
2597
msgid ""
@@ -2545,6 +2604,14 @@ msgid ""
2545
2604
" for name in dirs:\n"
2546
2605
" (root / name).rmdir()"
2547
2606
msgstr ""
2607
+ "# Exclui tudo o que estiver acessível no diretório \" top\" .\n"
2608
+ "# CUIDADO: Isso é perigoso! Por exemplo, se top == Path('/'),\n"
2609
+ "# todos os seus arquivos poderão ser excluídos.\n"
2610
+ "for root, dirs, files in top.walk(top_down=False):\n"
2611
+ " for name in files:\n"
2612
+ " (root / name).unlink()\n"
2613
+ " for name in dirs:\n"
2614
+ " (root / name).rmdir()"
2548
2615
2549
2616
#: ../../library/pathlib.rst:1436
2550
2617
msgid "Creating files and directories"
@@ -2558,19 +2625,31 @@ msgid ""
2558
2625
"(and its modification time is updated to the current time), otherwise :exc:"
2559
2626
"`FileExistsError` is raised."
2560
2627
msgstr ""
2628
+ "Cria um arquivo neste caminho especifico. Caso o *modo* for dado, ele será "
2629
+ "combinado com o valor do processo ``umask`` para determinar o modo de "
2630
+ "arquivo e as flags de acesso. Se o arquivo já existir, a função será bem-"
2631
+ "sucedida quando *exist_ok* for verdadeiro (e o tempo de modificação for "
2632
+ "atualizado para a hora atual), caso contrário a exceção :exc:"
2633
+ "`FileExistsError` será levantada."
2561
2634
2562
2635
#: ../../library/pathlib.rst:1447
2563
2636
msgid ""
2564
2637
"The :meth:`~Path.open`, :meth:`~Path.write_text` and :meth:`~Path."
2565
2638
"write_bytes` methods are often used to create files."
2566
2639
msgstr ""
2640
+ "Os métodos :meth:`~Path.open`, :meth:`~Path.write_text` e :meth:`~Path."
2641
+ "write_bytes` são frequentemente usados para criar arquivos."
2567
2642
2568
2643
#: ../../library/pathlib.rst:1453
2569
2644
msgid ""
2570
2645
"Create a new directory at this given path. If *mode* is given, it is "
2571
2646
"combined with the process's ``umask`` value to determine the file mode and "
2572
2647
"access flags. If the path already exists, :exc:`FileExistsError` is raised."
2573
2648
msgstr ""
2649
+ "Cria um novo diretório neste caminho fornecido. Se *mode* for fornecido, ele "
2650
+ "é combinado com o valor ``umask`` do processo para determinar o modo do "
2651
+ "arquivo e os sinalizadores de acesso. Se o caminho já existe, :exc:"
2652
+ "`FileExistsError` é levantada."
2574
2653
2575
2654
#: ../../library/pathlib.rst:1458
2576
2655
msgid ""
@@ -2604,6 +2683,9 @@ msgid ""
2604
2683
"given path already exists in the file system and is not a directory (same "
2605
2684
"behavior as the POSIX ``mkdir -p`` command)."
2606
2685
msgstr ""
2686
+ "Se *exist_ok* for verdadeiro, a exceção :exc:`FileExistsError` não será "
2687
+ "levantada, a menos que o caminho fornecido já exista no sistema de arquivos "
2688
+ "e não seja um diretório (mesmo comportamento do comando POSIX ``mkdir -p``)."
2607
2689
2608
2690
#: ../../library/pathlib.rst:1472
2609
2691
msgid "The *exist_ok* parameter was added."
@@ -2621,6 +2703,12 @@ msgid ""
2621
2703
"a directory if *target_is_directory* is true or a file symlink (the default) "
2622
2704
"otherwise. On non-Windows platforms, *target_is_directory* is ignored."
2623
2705
msgstr ""
2706
+ "No Windows, um link simbólico representa um arquivo ou um diretório e não se "
2707
+ "transforma no destino dinamicamente. Se o alvo estiver presente, será criado "
2708
+ "um link simbólico de mesmo tipo. Caso contrário, o link simbólico será "
2709
+ "criado como um diretório se *target_is_directory* for verdadeiro ou um link "
2710
+ "simbólico de arquivo (o padrão) caso contrário. Em plataformas não Windows, "
2711
+ "*target_is_directory* é ignorado."
2624
2712
2625
2713
#: ../../library/pathlib.rst:1488
2626
2714
msgid ""
@@ -2633,6 +2721,14 @@ msgid ""
2633
2721
">>> p.lstat().st_size\n"
2634
2722
"8"
2635
2723
msgstr ""
2724
+ ">>> p = Path('meulink')\n"
2725
+ ">>> p.symlink_to('setup.py')\n"
2726
+ ">>> p.resolve()\n"
2727
+ "PosixPath('/home/antoine/pathlib/setup.py')\n"
2728
+ ">>> p.stat().st_size\n"
2729
+ "956\n"
2730
+ ">>> p.lstat().st_size\n"
2731
+ "8"
2636
2732
2637
2733
#: ../../library/pathlib.rst:1498
2638
2734
msgid ""
@@ -2646,6 +2742,8 @@ msgid ""
2646
2742
"Raises :exc:`UnsupportedOperation` if :func:`os.symlink` is not available. "
2647
2743
"In previous versions, :exc:`NotImplementedError` was raised."
2648
2744
msgstr ""
2745
+ "Levanta :exc:`UnsupportedOperation` se :func:`os.symlink` não estiver "
2746
+ "disponível. Em versões anteriores, :exc:`NotImplementedError` era levantada."
2649
2747
2650
2748
#: ../../library/pathlib.rst:1508
2651
2749
msgid "Make this path a hard link to the same file as *target*."
@@ -2663,6 +2761,8 @@ msgid ""
2663
2761
"Raises :exc:`UnsupportedOperation` if :func:`os.link` is not available. In "
2664
2762
"previous versions, :exc:`NotImplementedError` was raised."
2665
2763
msgstr ""
2764
+ "Levanta :exc:`UnsupportedOperation` se :func:`os.link` não estiver "
2765
+ "disponível. Em versões anteriores, :exc:`NotImplementedError` era levantada."
2666
2766
2667
2767
#: ../../library/pathlib.rst:1522
2668
2768
msgid "Renaming and deleting"
0 commit comments