@@ -1291,6 +1291,17 @@ msgid ""
1291
1291
" raise ValueError(\" %r has an empty name\" % (self,))\n"
1292
1292
"ValueError: PureWindowsPath('c:/') has an empty name"
1293
1293
msgstr ""
1294
+ ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n"
1295
+ ">>> p.with_name('setup.py')\n"
1296
+ "PureWindowsPath('c:/Downloads/setup.py')\n"
1297
+ ">>> p = PureWindowsPath('c:/')\n"
1298
+ ">>> p.with_name('setup.py')\n"
1299
+ "Traceback (most recent call last):\n"
1300
+ " File \" <stdin>\" , line 1, in <module>\n"
1301
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 751, in "
1302
+ "with_name\n"
1303
+ " raise ValueError(\" %r has an empty name\" % (self,))\n"
1304
+ "ValueError: PureWindowsPath('c:/') has an empty name"
1294
1305
1295
1306
#: ../../library/pathlib.rst:676
1296
1307
msgid ""
@@ -1320,6 +1331,23 @@ msgid ""
1320
1331
" raise ValueError(\" %r has an empty name\" % (self,))\n"
1321
1332
"ValueError: PureWindowsPath('c:/') has an empty name"
1322
1333
msgstr ""
1334
+ ">>> p = PureWindowsPath('c:/Downloads/draft.txt')\n"
1335
+ ">>> p.with_stem('final')\n"
1336
+ "PureWindowsPath('c:/Downloads/final.txt')\n"
1337
+ ">>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')\n"
1338
+ ">>> p.with_stem('lib')\n"
1339
+ "PureWindowsPath('c:/Downloads/lib.gz')\n"
1340
+ ">>> p = PureWindowsPath('c:/')\n"
1341
+ ">>> p.with_stem('')\n"
1342
+ "Traceback (most recent call last):\n"
1343
+ " File \" <stdin>\" , line 1, in <module>\n"
1344
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 861, in "
1345
+ "with_stem\n"
1346
+ " return self.with_name(stem + self.suffix)\n"
1347
+ " File \" /home/antoine/cpython/default/Lib/pathlib.py\" , line 851, in "
1348
+ "with_name\n"
1349
+ " raise ValueError(\" %r has an empty name\" % (self,))\n"
1350
+ "ValueError: PureWindowsPath('c:/') has an empty name"
1323
1351
1324
1352
#: ../../library/pathlib.rst:700
1325
1353
msgid ""
@@ -1981,7 +2009,7 @@ msgid ""
1981
2009
"Open the file pointed to in bytes mode, write *data* to it, and close the "
1982
2010
"file::"
1983
2011
msgstr ""
1984
- "Abre o arquivo apontado no modo bytes, escreve *dados * e fecha o arquivo::"
2012
+ "Abre o arquivo apontado no modo bytes, escreve *data * e fecha o arquivo::"
1985
2013
1986
2014
#: ../../library/pathlib.rst:1140
1987
2015
msgid "An existing file of the same name is overwritten."
@@ -2246,13 +2274,21 @@ msgid ""
2246
2274
"their targets, and consequently visit directories pointed to by symlinks "
2247
2275
"(where supported)."
2248
2276
msgstr ""
2277
+ "Por padrão, :meth:`Path.walk` não segue links simbólicos e, em vez disso, os "
2278
+ "adiciona à lista *filenames*. Defina *follow_symlinks* como true para "
2279
+ "resolver links simbólicos e colocá-los em *dirnames* e *filenames* conforme "
2280
+ "apropriado para seus alvos e, consequentemente, visitar diretórios apontados "
2281
+ "por links simbólicos (quando suportado)."
2249
2282
2250
2283
#: ../../library/pathlib.rst:1292
2251
2284
msgid ""
2252
2285
"Be aware that setting *follow_symlinks* to true can lead to infinite "
2253
2286
"recursion if a link points to a parent directory of itself. :meth:`Path."
2254
2287
"walk` does not keep track of the directories it has already visited."
2255
2288
msgstr ""
2289
+ "Esteja ciente de que definir *follow_symlinks* como true pode levar a uma "
2290
+ "recursão infinita se um link apontar para um diretório pai dele mesmo. :meth:"
2291
+ "`Path.walk` não rastreia os diretórios que já visitou."
2256
2292
2257
2293
#: ../../library/pathlib.rst:1297
2258
2294
msgid ""
@@ -2262,12 +2298,19 @@ msgid ""
2262
2298
"try to descend into it. To prevent such behavior, remove directories from "
2263
2299
"*dirnames* as appropriate."
2264
2300
msgstr ""
2301
+ ":meth:`Path.walk` presume que os diretórios que percorre não sejam "
2302
+ "modificados durante a execução. Por exemplo, se um diretório de *dirnames* "
2303
+ "tiver sido substituído por um link simbólico e *follow_symlinks* for falso, :"
2304
+ "meth:`Path.walk` ainda tentará descer até ele. Para evitar esse "
2305
+ "comportamento, remova os diretórios de *dirnames* conforme apropriado."
2265
2306
2266
2307
#: ../../library/pathlib.rst:1305
2267
2308
msgid ""
2268
2309
"Unlike :func:`os.walk`, :meth:`Path.walk` lists symlinks to directories in "
2269
2310
"*filenames* if *follow_symlinks* is false."
2270
2311
msgstr ""
2312
+ "Diferentemente de :func:`os.walk`, :meth:`Path.walk` lista links simbólicos "
2313
+ "para diretórios em *filenames* se *follow_symlinks* for falso."
2271
2314
2272
2315
#: ../../library/pathlib.rst:1308
2273
2316
msgid ""
@@ -2293,13 +2336,29 @@ msgid ""
2293
2336
" if '__pycache__' in dirs:\n"
2294
2337
" dirs.remove('__pycache__')"
2295
2338
msgstr ""
2339
+ "from pathlib import Path\n"
2340
+ "for root, dirs, files in Path(\" cpython/Lib/concurrent\" )."
2341
+ "walk(on_error=print):\n"
2342
+ " print(\n"
2343
+ " root,\n"
2344
+ " \" consumes\" ,\n"
2345
+ " sum((root / file).stat().st_size for file in files),\n"
2346
+ " \" bytes in\" ,\n"
2347
+ " len(files),\n"
2348
+ " \" non-directory files\" \n"
2349
+ " )\n"
2350
+ " if '__pycache__' in dirs:\n"
2351
+ " dirs.remove('__pycache__')"
2296
2352
2297
2353
#: ../../library/pathlib.rst:1324
2298
2354
msgid ""
2299
2355
"This next example is a simple implementation of :func:`shutil.rmtree`. "
2300
2356
"Walking the tree bottom-up is essential as :func:`rmdir` doesn't allow "
2301
2357
"deleting a directory before it is empty::"
2302
2358
msgstr ""
2359
+ "O próximo exemplo é uma implementação simples de :func:`shutil.rmtree`. "
2360
+ "Percorrer a árvore de baixo para cima é essencial, pois :func:`rmdir` não "
2361
+ "permite excluir um diretório antes que ele esteja vazio."
2303
2362
2304
2363
#: ../../library/pathlib.rst:1328
2305
2364
msgid ""
@@ -2312,6 +2371,14 @@ msgid ""
2312
2371
" for name in dirs:\n"
2313
2372
" (root / name).rmdir()"
2314
2373
msgstr ""
2374
+ "# Exclui tudo o que estiver acessível no diretório \" top\" .\n"
2375
+ "# CUIDADO: Isso é perigoso! Por exemplo, se top == Path('/'),\n"
2376
+ "# todos os seus arquivos poderão ser excluídos.\n"
2377
+ "for root, dirs, files in top.walk(top_down=False):\n"
2378
+ " for name in files:\n"
2379
+ " (root / name).unlink()\n"
2380
+ " for name in dirs:\n"
2381
+ " (root / name).rmdir()"
2315
2382
2316
2383
#: ../../library/pathlib.rst:1341
2317
2384
msgid "Creating files and directories"
@@ -2325,19 +2392,31 @@ msgid ""
2325
2392
"(and its modification time is updated to the current time), otherwise :exc:"
2326
2393
"`FileExistsError` is raised."
2327
2394
msgstr ""
2395
+ "Cria um arquivo neste caminho especifico. Caso o *modo* for dado, ele será "
2396
+ "combinado com o valor do processo ``umask`` para determinar o modo de "
2397
+ "arquivo e as flags de acesso. Se o arquivo já existir, a função será bem-"
2398
+ "sucedida quando *exist_ok* for verdadeiro (e o tempo de modificação for "
2399
+ "atualizado para a hora atual), caso contrário a exceção :exc:"
2400
+ "`FileExistsError` será levantada."
2328
2401
2329
2402
#: ../../library/pathlib.rst:1352
2330
2403
msgid ""
2331
2404
"The :meth:`~Path.open`, :meth:`~Path.write_text` and :meth:`~Path."
2332
2405
"write_bytes` methods are often used to create files."
2333
2406
msgstr ""
2407
+ "Os métodos :meth:`~Path.open`, :meth:`~Path.write_text` e :meth:`~Path."
2408
+ "write_bytes` são frequentemente usados para criar arquivos."
2334
2409
2335
2410
#: ../../library/pathlib.rst:1358
2336
2411
msgid ""
2337
2412
"Create a new directory at this given path. If *mode* is given, it is "
2338
2413
"combined with the process's ``umask`` value to determine the file mode and "
2339
2414
"access flags. If the path already exists, :exc:`FileExistsError` is raised."
2340
2415
msgstr ""
2416
+ "Cria um novo diretório neste caminho fornecido. Se *mode* for fornecido, ele "
2417
+ "é combinado com o valor ``umask`` do processo para determinar o modo do "
2418
+ "arquivo e os sinalizadores de acesso. Se o caminho já existe, :exc:"
2419
+ "`FileExistsError` é levantada."
2341
2420
2342
2421
#: ../../library/pathlib.rst:1363
2343
2422
msgid ""
@@ -2371,6 +2450,9 @@ msgid ""
2371
2450
"given path already exists in the file system and is not a directory (same "
2372
2451
"behavior as the POSIX ``mkdir -p`` command)."
2373
2452
msgstr ""
2453
+ "Se *exist_ok* for verdadeiro, a exceção :exc:`FileExistsError` não será "
2454
+ "levantada, a menos que o caminho fornecido já exista no sistema de arquivos "
2455
+ "e não seja um diretório (mesmo comportamento do comando POSIX ``mkdir -p``)."
2374
2456
2375
2457
#: ../../library/pathlib.rst:1377
2376
2458
msgid "The *exist_ok* parameter was added."
@@ -2388,6 +2470,12 @@ msgid ""
2388
2470
"a directory if *target_is_directory* is true or a file symlink (the default) "
2389
2471
"otherwise. On non-Windows platforms, *target_is_directory* is ignored."
2390
2472
msgstr ""
2473
+ "No Windows, um link simbólico representa um arquivo ou um diretório e não se "
2474
+ "transforma no destino dinamicamente. Se o alvo estiver presente, será criado "
2475
+ "um link simbólico de mesmo tipo. Caso contrário, o link simbólico será "
2476
+ "criado como um diretório se *target_is_directory* for verdadeiro ou um link "
2477
+ "simbólico de arquivo (o padrão) caso contrário. Em plataformas não Windows, "
2478
+ "*target_is_directory* é ignorado."
2391
2479
2392
2480
#: ../../library/pathlib.rst:1393
2393
2481
msgid ""
@@ -2400,6 +2488,14 @@ msgid ""
2400
2488
">>> p.lstat().st_size\n"
2401
2489
"8"
2402
2490
msgstr ""
2491
+ ">>> p = Path('meulink')\n"
2492
+ ">>> p.symlink_to('setup.py')\n"
2493
+ ">>> p.resolve()\n"
2494
+ "PosixPath('/home/antoine/pathlib/setup.py')\n"
2495
+ ">>> p.stat().st_size\n"
2496
+ "956\n"
2497
+ ">>> p.lstat().st_size\n"
2498
+ "8"
2403
2499
2404
2500
#: ../../library/pathlib.rst:1403
2405
2501
msgid ""
0 commit comments