Skip to content

Traducido archivo library/optparse #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Traducida sección "Extendidendo Optparse - Nuevos tipos
  • Loading branch information
fjsevilla-dev committed Sep 21, 2020
commit e00f67e1d91af3c43b897a43ed6db54dc67fee9e
2 changes: 2 additions & 0 deletions dictionaries/library_optparse.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
HelpFormatter
IndentedHelpFormatter
metavariable
MyOption
OptionError
OptionParser
OptionParsers
OptionValues
optparse
quiet
reformatea
Expand Down
54 changes: 49 additions & 5 deletions library/optparse.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-05 12:54+0200\n"
"PO-Revision-Date: 2020-09-20 23:53+0200\n"
"PO-Revision-Date: 2020-09-21 12:18+0200\n"
"Language-Team: python-doc-es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -3014,18 +3014,22 @@ msgstr ""

#: ../Doc/library/optparse.rst:1842
msgid "Extending :mod:`optparse`"
msgstr ""
msgstr "Extendiendo el módulo :mod:`optparse`"

#: ../Doc/library/optparse.rst:1844
msgid ""
"Since the two major controlling factors in how :mod:`optparse` interprets "
"command-line options are the action and type of each option, the most likely "
"direction of extension is to add new actions and new types."
msgstr ""
"Dado que los dos factores principales que controlan como el modulo :mod: "
"`optparse` interpreta las opciones de la línea de comandos son la acción y "
"el tipo de cada opción, los objetivos más probables de extensión son agregar "
"nuevas acciones y nuevos tipos."

#: ../Doc/library/optparse.rst:1852
msgid "Adding new types"
msgstr ""
msgstr "Agregando nuevos tipos"

#: ../Doc/library/optparse.rst:1854
msgid ""
Expand All @@ -3034,18 +3038,26 @@ msgid ""
"mod:`optparse`'s types: :attr:`~Option.TYPES` and :attr:`~Option."
"TYPE_CHECKER`."
msgstr ""
"Para añadir nuevos tipos, necesitas definir tu propia subclase de la clase :"
"class:`Option` de :mod:`optparse`. Esta clase tiene un par de atributos que "
"definen los tipos de :mod:`optparse`: :attr:`~Option.TYPES` y :attr:`~Option."
"TYPE_CHECKER`."

#: ../Doc/library/optparse.rst:1860
msgid ""
"A tuple of type names; in your subclass, simply define a new tuple :attr:"
"`TYPES` that builds on the standard one."
msgstr ""
"Una tupla con nombres de tipos. En tu subclase, simplemente define una nueva "
"tupla :attr:`TYPES` que se base en la estándar."

#: ../Doc/library/optparse.rst:1865
msgid ""
"A dictionary mapping type names to type-checking functions. A type-checking "
"function has the following signature::"
msgstr ""
"Un diccionario que asigna nombres de tipos a funciones de verificación de "
"tipo. Una función de verificación de tipo tiene la siguiente firma:"

#: ../Doc/library/optparse.rst:1870
msgid ""
Expand All @@ -3057,6 +3069,14 @@ msgid ""
"by :meth:`OptionParser.parse_args`, or be passed to a callback as the "
"``value`` parameter."
msgstr ""
"donde ``option`` es una instancia de :class:`Option`, ``opt`` es una cadena "
"de opciones (por ejemplo, ``-f``), y ``value`` es la cadena de caracteres de "
"la línea de comandos que debe comprobarse y convertirse al tipo deseado. "
"``check_mytype ()`` debería retornar un objeto del tipo hipotético "
"``mytype``. El valor retornado por una función de verificación de tipo "
"terminará formando parte de la instancia de OptionValues retornada por el "
"método :meth:`OptionParser.parse_args` o se pasará a una retrollamada como "
"parámetro ``value``."

#: ../Doc/library/optparse.rst:1878
msgid ""
Expand All @@ -3066,6 +3086,12 @@ msgid ""
"method, which in turn prepends the program name and the string ``\"error:"
"\"`` and prints everything to stderr before terminating the process."
msgstr ""
"Tu función de verificación de tipo debería lanzar una excepción :exc:"
"`OptionValueError` si encuentra algún problema. :exc:`OptionValueError` toma "
"una cadena de caracteres como único argumento, que es pasada tal cual al "
"método :meth:`error` de la clase :class:`OptionParser`, que a su vez "
"antepone a la misma el nombre del programa y la cadena ``\"error:\"`` e "
"imprime todo en la salida de error estándar antes de finalizar el proceso."

#: ../Doc/library/optparse.rst:1884
msgid ""
Expand All @@ -3074,20 +3100,28 @@ msgid ""
"even sillier than it used to be, because :mod:`optparse` 1.3 added built-in "
"support for complex numbers, but never mind.)"
msgstr ""
"Aquí hay un ejemplo absurdo que demuestra cómo agregar un tipo de opción ``"
"\"complex\"`` para analizar números complejos al estilo Python en la línea "
"de comandos. (Esto es aún más absurdo de lo que en principio parece, porque "
"en al versión 1.3 de :mod:`optparse` se agregó soporte incorporado para "
"números complejos, pero no importa)."

#: ../Doc/library/optparse.rst:1889
msgid "First, the necessary imports::"
msgstr ""
msgstr "Primero, las importaciones necesarias::"

#: ../Doc/library/optparse.rst:1894
msgid ""
"You need to define your type-checker first, since it's referred to later (in "
"the :attr:`~Option.TYPE_CHECKER` class attribute of your Option subclass)::"
msgstr ""
"En primer lugar, debes definir tu verificador de tipo, ya que se hace "
"referencia a él más adelante (en el atributo de clase :attr:`~Option."
"TYPE_CHECKER` de tu subclase de Option)::"

#: ../Doc/library/optparse.rst:1904
msgid "Finally, the Option subclass::"
msgstr ""
msgstr "Finalmente, la subclase de Option::"

#: ../Doc/library/optparse.rst:1911
msgid ""
Expand All @@ -3096,20 +3130,30 @@ msgid ""
"`optparse`'s Option class. This being Python, nothing stops you from doing "
"that except good manners and common sense.)"
msgstr ""
"(Si no hacemos una copia (:func:`copy`) de :attr:`Option.TYPE_CHECKER`, "
"terminaríamos modificando el atributo :attr:`~Option.TYPE_CHECKER` de la "
"clase Option de :mod:`optparse`. Tratándose de Python, nada te impide hacer "
"eso, excepto los buenos modales y el sentido común.)"

#: ../Doc/library/optparse.rst:1916
msgid ""
"That's it! Now you can write a script that uses the new option type just "
"like any other :mod:`optparse`\\ -based script, except you have to instruct "
"your OptionParser to use MyOption instead of Option::"
msgstr ""
"¡Eso es todo! Ahora puedes escribir un script que use tu nuevo tipo de "
"opción como cualquier otro script basado en mod:`optparse`, excepto que "
"debes indicarle a tu OptionParser que use MyOption en lugar de Option::"

#: ../Doc/library/optparse.rst:1923
msgid ""
"Alternately, you can build your own option list and pass it to OptionParser; "
"if you don't use :meth:`add_option` in the above way, you don't need to tell "
"OptionParser which option class to use::"
msgstr ""
"Alternativamente, puedes crear tu propia lista de opciones y pasarla a "
"OptionParser; si no usas :meth:`add_option` de la manera anterior, no "
"necesitas decirle a OptionParser qué clase de opción usar::"

#: ../Doc/library/optparse.rst:1934
msgid "Adding new actions"
Expand Down