@@ -32,9 +32,9 @@ msgid ""
3232":mod:`lib2to3` could also be adapted to custom applications in which Python "
3333"code needs to be edited automatically."
3434msgstr ""
35- "2to3 是一个 Python 程序,它可以用来读取 Python 2.x 版本的代码,并使用一系列的 * fixer* 来将其转换为合法的 Python "
36- " 3.x 代码。标准库中已经包含了丰富的 fixer ,这足以处理绝大多数代码。不过 2to3 的支持库 :mod:`lib2to3` "
37- "是一个很灵活通用的库,所以你也可以为 2to3 编写你自己的 fixer 。:mod:`lib2to3` 也可以用在那些需要自动处理 Python "
35+ "2to3 是一个 Python 程序,它可以用来读取 Python 2.x 版本的代码,并使用一系列的*修复器 ( fixer) * 来将其转换为合法的 "
36+ "Python 3.x 代码。标准库中已经包含了丰富的修复器 ,这足以处理绝大多数代码。不过 2to3 的支持库 :mod:`lib2to3` "
37+ "是一个很灵活通用的库,所以你也可以为 2to3 编写你自己的修复器 。:mod:`lib2to3` 也可以用在那些需要自动处理 Python "
3838"代码的应用中。"
3939
4040#: ../../library/2to3.rst:20
@@ -90,27 +90,26 @@ msgid ""
9090" disables a fixer. The following example runs only the ``imports`` and "
9191"``has_key`` fixers:"
9292msgstr ""
93- "默认情况下,2to3 会执行 :ref:`预定义 fixers <2to3-fixers>` 的集合。使用 :option:`!-l` "
94- "参数可以列出所有可用的 fixers。使用 :option:`!-f` 参数可以明确指定需要使用的 fixers 集合。而使用 "
95- ":option:`!-x` 参数则可以明确指定不使用的 fixer。下面的例子会只使用 ``imports`` 和 ``has_key`` fixer "
96- "运行:"
93+ "默认情况下,2to3 会执行 :ref:`预定义修复器 <2to3-fixers>` 的集合。使用 :option:`!-l` "
94+ "参数可以列出所有可用的修复器。使用 :option:`!-f` 参数可以明确指定需要使用的修复器集合。而使用 :option:`!-x` "
95+ "参数则可以明确指定不使用的修复器。下面的例子会只使用 ``imports`` 和 ``has_key`` 修复器运行:"
9796
9897#: ../../library/2to3.rst:70
9998msgid "This command runs every fixer except the ``apply`` fixer:"
100- msgstr "这个命令会执行除了 ``apply`` 之外的所有 fixer :"
99+ msgstr "这个命令会执行除了 ``apply`` 之外的所有修复器 :"
101100
102101#: ../../library/2to3.rst:76
103102msgid ""
104103"Some fixers are *explicit*, meaning they aren't run by default and must be "
105104"listed on the command line to be run. Here, in addition to the default "
106105"fixers, the ``idioms`` fixer is run:"
107106msgstr ""
108- "有一些 fixer 是需要*明确指定 *的,它们默认不会执行,必须在命令行中列出才会执行。比如下面的例子,除了默认的 fixer 以外 ,还会执行 "
109- "``idioms`` fixer :"
107+ "有一些修复器是需要*显式指定 *的,它们默认不会执行,必须在命令行中列出才会执行。比如下面的例子,除了默认的修复器以外 ,还会执行 ``idioms`` "
108+ "修复器 :"
110109
111110#: ../../library/2to3.rst:84
112111msgid "Notice how passing ``all`` enables all default fixers."
113- msgstr "注意这里使用 ``all`` 来启用所有默认的 fixer 。"
112+ msgstr "注意这里使用 ``all`` 来启用所有默认的修复器 。"
114113
115114#: ../../library/2to3.rst:86
116115msgid ""
@@ -151,7 +150,7 @@ msgstr ""
151150"由于一些 print 语句既可能是函数调用,也可能是代码语句,2to3 并不总是能读取含有 print 函数的文件。当 2to3 检测到代码中存在 "
152151"``from __future__ import print_function`` 编译指令时,会在内部语法中将 :func:`print` "
153152"作为函数来处理。这一变动也可以使用 :option:`!-p` 选项手动开启。使用 :option:`-p` 来为已经将 print "
154- "语句转为函数调用的代码执行 fixer。"
153+ "语句转为函数调用的代码运行 fixer。"
155154
156155#: ../../library/2to3.rst:107
157156msgid ""
@@ -160,10 +159,13 @@ msgid ""
160159":option:`!-n` flag is required when using this as backup files do not make "
161160"sense when not overwriting the input files."
162161msgstr ""
162+ ":option:`!-o` 或 :option:`!--output-dir` "
163+ "选项可以指定将转换后的文件写入其他目录中。由于这种情况下不会覆写原始文件,所以创建副本文件毫无意义,因此也需要使用 :option:`!-n` "
164+ "选项来禁用创建副本。"
163165
164166#: ../../library/2to3.rst:112
165167msgid "The :option:`!-o` option was added."
166- msgstr ""
168+ msgstr "增加了 :option:`!-o` 选项。 "
167169
168170#: ../../library/2to3.rst:115
169171msgid ""
@@ -173,147 +175,160 @@ msgid ""
173175"is copied with translation from one directory to another. This option "
174176"implies the :option:`!-w` flag as it would not make sense otherwise."
175177msgstr ""
178+ ":option:`!-W` 或 :option:`!--write-unchanged-files` 选项用来告诉 2to3 "
179+ "始终需要输出文件,即使没有任何改动。这在使用 :option:`!-o` 参数时十分有用,这样就可以将整个 Python "
180+ "源码包完整地转换到另一个目录。这个选项隐含了 :option:`!-w` 选项,否则等于没有作用。"
176181
177182#: ../../library/2to3.rst:121
178183msgid "The :option:`!-W` flag was added."
179- msgstr ""
184+ msgstr "增加了 :option:`!-W` 选项。 "
180185
181186#: ../../library/2to3.rst:124
182187msgid ""
183188"The :option:`!--add-suffix` option specifies a string to append to all "
184189"output filenames. The :option:`!-n` flag is required when specifying this "
185190"as backups are not necessary when writing to different filenames. Example:"
186191msgstr ""
192+ ":option:`!--add-suffix` "
193+ "选项接受一个字符串,用来作为后缀附加在输出文件名后面的后面。由于写入的文件名与原始文件不同,所以没有必要创建副本,因此 :option:`!-n` "
194+ "选项也是必要的。举个例子:"
187195
188196#: ../../library/2to3.rst:132
189197msgid "Will cause a converted file named ``example.py3`` to be written."
190- msgstr ""
198+ msgstr "这样会把转换后的文件写入 ``example.py3`` 文件。 "
191199
192200#: ../../library/2to3.rst:134
193201msgid "The :option:`!--add-suffix` option was added."
194- msgstr ""
202+ msgstr "增加了 :option:`!--add-suffix` 选项。 "
195203
196204#: ../../library/2to3.rst:137
197205msgid "To translate an entire project from one directory tree to another use:"
198- msgstr ""
206+ msgstr "将整个项目从一个目录转换到另一个目录可以用这样的命令: "
199207
200208#: ../../library/2to3.rst:147
201209msgid "Fixers"
202- msgstr ""
210+ msgstr "修复器 "
203211
204212#: ../../library/2to3.rst:149
205213msgid ""
206214"Each step of transforming code is encapsulated in a fixer. The command "
207215"``2to3 -l`` lists them. As :ref:`documented above <2to3-using>`, each can "
208216"be turned on and off individually. They are described here in more detail."
209217msgstr ""
218+ "转换代码的每一个步骤都封装在修复器中。可以使用 ``2to3 -l`` 来列出可用的修复器。:ref:`之前已经提到 "
219+ "<2to3-using>`,每个修复器都可以独立地打开或是关闭。下面会对各个修复器做更详细的描述。"
210220
211221#: ../../library/2to3.rst:156
212222msgid ""
213223"Removes usage of :func:`apply`. For example ``apply(function, *args, "
214224"**kwargs)`` is converted to ``function(*args, **kwargs)``."
215225msgstr ""
226+ "移除对 :func:`apply` 的使用,举例来说,``apply(function, *args, **kwargs)`` 会被转换成 "
227+ "``function(*args, **kwargs)``。"
216228
217229#: ../../library/2to3.rst:161
218230msgid ""
219231"Replaces deprecated :mod:`unittest` method names with the correct ones."
220- msgstr ""
232+ msgstr "将已弃用的 :mod:`unittest` 方法替换为正确的。 "
221233
222234#: ../../library/2to3.rst:164 ../../library/2to3.rst:352
223235msgid "From"
224- msgstr ""
236+ msgstr "Python 2.x "
225237
226238#: ../../library/2to3.rst:164 ../../library/2to3.rst:352
227239msgid "To"
228- msgstr ""
240+ msgstr "Python 3.x "
229241
230242#: ../../library/2to3.rst:166
231243msgid "``failUnlessEqual(a, b)``"
232- msgstr ""
244+ msgstr "``failUnlessEqual(a, b)`` "
233245
234246#: ../../library/2to3.rst:166 ../../library/2to3.rst:168
235247msgid ":meth:`assertEqual(a, b) <unittest.TestCase.assertEqual>`"
236- msgstr ""
248+ msgstr ":meth:`assertEqual(a, b) <unittest.TestCase.assertEqual>` "
237249
238250#: ../../library/2to3.rst:168
239251msgid "``assertEquals(a, b)``"
240- msgstr ""
252+ msgstr "``assertEquals(a, b)`` "
241253
242254#: ../../library/2to3.rst:170
243255msgid "``failIfEqual(a, b)``"
244- msgstr ""
256+ msgstr "``failIfEqual(a, b)`` "
245257
246258#: ../../library/2to3.rst:170 ../../library/2to3.rst:172
247259msgid ":meth:`assertNotEqual(a, b) <unittest.TestCase.assertNotEqual>`"
248- msgstr ""
260+ msgstr ":meth:`assertNotEqual(a, b) <unittest.TestCase.assertNotEqual>` "
249261
250262#: ../../library/2to3.rst:172
251263msgid "``assertNotEquals(a, b)``"
252- msgstr ""
264+ msgstr "``assertNotEquals(a, b)`` "
253265
254266#: ../../library/2to3.rst:174
255267msgid "``failUnless(a)``"
256- msgstr ""
268+ msgstr "``failUnless(a)`` "
257269
258270#: ../../library/2to3.rst:174 ../../library/2to3.rst:176
259271msgid ":meth:`assertTrue(a) <unittest.TestCase.assertTrue>`"
260- msgstr ""
272+ msgstr ":meth:`assertTrue(a) <unittest.TestCase.assertTrue>` "
261273
262274#: ../../library/2to3.rst:176
263275msgid "``assert_(a)``"
264- msgstr ""
276+ msgstr "``assert_(a)`` "
265277
266278#: ../../library/2to3.rst:178
267279msgid "``failIf(a)``"
268- msgstr ""
280+ msgstr "``failIf(a)`` "
269281
270282#: ../../library/2to3.rst:178
271283msgid ":meth:`assertFalse(a) <unittest.TestCase.assertFalse>`"
272- msgstr ""
284+ msgstr ":meth:`assertFalse(a) <unittest.TestCase.assertFalse>` "
273285
274286#: ../../library/2to3.rst:180
275287msgid "``failUnlessRaises(exc, cal)``"
276- msgstr ""
288+ msgstr "``failUnlessRaises(exc, cal)`` "
277289
278290#: ../../library/2to3.rst:180
279291msgid ":meth:`assertRaises(exc, cal) <unittest.TestCase.assertRaises>`"
280- msgstr ""
292+ msgstr ":meth:`assertRaises(exc, cal) <unittest.TestCase.assertRaises>` "
281293
282294#: ../../library/2to3.rst:182
283295msgid "``failUnlessAlmostEqual(a, b)``"
284- msgstr ""
296+ msgstr "``failUnlessAlmostEqual(a, b)`` "
285297
286298#: ../../library/2to3.rst:182 ../../library/2to3.rst:184
287299msgid ":meth:`assertAlmostEqual(a, b) <unittest.TestCase.assertAlmostEqual>`"
288- msgstr ""
300+ msgstr ":meth:`assertAlmostEqual(a, b) <unittest.TestCase.assertAlmostEqual>` "
289301
290302#: ../../library/2to3.rst:184
291303msgid "``assertAlmostEquals(a, b)``"
292- msgstr ""
304+ msgstr "``assertAlmostEquals(a, b)`` "
293305
294306#: ../../library/2to3.rst:186
295307msgid "``failIfAlmostEqual(a, b)``"
296- msgstr ""
308+ msgstr "``failIfAlmostEqual(a, b)`` "
297309
298310#: ../../library/2to3.rst:186 ../../library/2to3.rst:188
299311msgid ""
300312":meth:`assertNotAlmostEqual(a, b) <unittest.TestCase.assertNotAlmostEqual>`"
301313msgstr ""
314+ ":meth:`assertNotAlmostEqual(a, b) <unittest.TestCase.assertNotAlmostEqual>`"
302315
303316#: ../../library/2to3.rst:188
304317msgid "``assertNotAlmostEquals(a, b)``"
305- msgstr ""
318+ msgstr "``assertNotAlmostEquals(a, b)`` "
306319
307320#: ../../library/2to3.rst:194
308321msgid "Converts :class:`basestring` to :class:`str`."
309- msgstr ""
322+ msgstr "将 :class:`basestring` 转换为 :class:`str`。 "
310323
311324#: ../../library/2to3.rst:198
312325msgid ""
313326"Converts :class:`buffer` to :class:`memoryview`. This fixer is optional "
314327"because the :class:`memoryview` API is similar but not exactly the same as "
315328"that of :class:`buffer`."
316329msgstr ""
330+ "将 :class:`buffer` 转换为 :class:`memoryview`。这个修复器是可选的,因为 :class:`memoryview` "
331+ "API 和 :class:`buffer` 很相似,但不完全一样。"
317332
318333#: ../../library/2to3.rst:204
319334msgid ""
@@ -325,48 +340,59 @@ msgid ""
325340":meth:`dict.values`. It also wraps existing usages of :meth:`dict.items`, "
326341":meth:`dict.keys`, and :meth:`dict.values` in a call to :class:`list`."
327342msgstr ""
343+ "修复字典迭代方法。:meth:`dict.iteritems` 会转换成 "
344+ ":meth:`dict.items`,:meth:`dict.iterkeys` 会转换成 "
345+ ":meth:`dict.keys`,:meth:`dict.itervalues` 会转换成 "
346+ ":meth:`dict.values`。类似的,:meth:`dict.viewitems`,:meth:`dict.viewkeys` 和 "
347+ ":meth:`dict.viewvalues` 会分别转换成 :meth:`dict.items`,:meth:`dict.keys` 和 "
348+ ":meth:`dict.values`。另外也会将原有的 :meth:`dict.items`,:meth:`dict.keys` 和 "
349+ ":meth:`dict.values` 方法调用用 :class:`list` 包装一层。"
328350
329351#: ../../library/2to3.rst:214
330352msgid "Converts ``except X, T`` to ``except X as T``."
331- msgstr ""
353+ msgstr "将 ``except X, T`` 转换为 ``except X as T``。 "
332354
333355#: ../../library/2to3.rst:218
334356msgid "Converts the ``exec`` statement to the :func:`exec` function."
335- msgstr ""
357+ msgstr "将 ``exec`` 语句转换为 :func:`exec` 函数调用。 "
336358
337359#: ../../library/2to3.rst:222
338360msgid ""
339361"Removes usage of :func:`execfile`. The argument to :func:`execfile` is "
340362"wrapped in calls to :func:`open`, :func:`compile`, and :func:`exec`."
341363msgstr ""
364+ "移除 :func:`execfile` 的使用。:func:`execfile` 的实参会使用 :func:`open`,:func:`compile`"
365+ " 和 :func:`exec` 包装。"
342366
343367#: ../../library/2to3.rst:227
344368msgid ""
345369"Changes assignment of :attr:`sys.exitfunc` to use of the :mod:`atexit` "
346370"module."
347- msgstr ""
371+ msgstr "将对 :attr:`sys.exitfunc` 的赋值改为使用 :mod:`atexit` 模块代替。 "
348372
349373#: ../../library/2to3.rst:232
350374msgid "Wraps :func:`filter` usage in a :class:`list` call."
351- msgstr ""
375+ msgstr "将 :func:`filter` 函数用 :class:`list` 包装一层。 "
352376
353377#: ../../library/2to3.rst:236
354378msgid ""
355379"Fixes function attributes that have been renamed. For example, "
356380"``my_function.func_closure`` is converted to ``my_function.__closure__``."
357381msgstr ""
382+ "修复已经重命名的函数属性。比如 ``my_function.func_closure`` 会被转换为 "
383+ "``my_function.__closure__``。"
358384
359385#: ../../library/2to3.rst:241
360386msgid "Removes ``from __future__ import new_feature`` statements."
361- msgstr ""
387+ msgstr "移除 ``from __future__ import new_feature`` 语句。 "
362388
363389#: ../../library/2to3.rst:245
364390msgid "Renames :func:`os.getcwdu` to :func:`os.getcwd`."
365- msgstr ""
391+ msgstr "将 :func:`os.getcwdu` 重命名为 :func:`os.getcwd`。 "
366392
367393#: ../../library/2to3.rst:249
368394msgid "Changes ``dict.has_key(key)`` to ``key in dict``."
369- msgstr ""
395+ msgstr "将 ``dict.has_key(key)`` 转换为 ``key in dict``。 "
370396
371397#: ../../library/2to3.rst:253
372398msgid ""
@@ -376,14 +402,17 @@ msgid ""
376402"``while 1`` becomes ``while True``. This fixer also tries to make use of "
377403":func:`sorted` in appropriate places. For example, this block ::"
378404msgstr ""
405+ "这是一个可选的修复器,会进行多种转换,将 Python 代码变成更加常见的写法。类似 ``type(x) is SomeClass`` 和 "
406+ "``type(x) == SomeClass`` 的类型对比会被转换成 ``isinstance(x, SomeClass)``。``while 1``"
407+ " 转换成 ``while True``。这个修复器还会在合适的地方使用 :func:`sorted` 函数。举个例子,这样的代码:"
379408
380409#: ../../library/2to3.rst:262
381410msgid "is changed to ::"
382- msgstr ""
411+ msgstr "会被转换为: "
383412
384413#: ../../library/2to3.rst:268
385414msgid "Detects sibling imports and converts them to relative imports."
386- msgstr ""
415+ msgstr "检测 sibling imports,并将其转换成相对 import。 "
387416
388417#: ../../library/2to3.rst:272
389418msgid "Handles module renames in the standard library."
0 commit comments