- Notifications
You must be signed in to change notification settings - Fork396
Traducido archivo extending/embedding#3340
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:3.13
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -11,15 +11,16 @@ msgstr "" | ||
"Project-Id-Version: Python 3.8\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-21 16:38-0300\n" | ||
"PO-Revision-Date:2024-11-30 20:35-0600\n" | ||
"Last-Translator: Cristián Maureira-Fredes <cmaureirafredes@gmail.com>\n" | ||
"Language-Team: python-doc-es\n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=utf-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"Generated-By: Babel 2.16.0\n" | ||
"X-Generator: Poedit 3.5\n" | ||
#: ../Doc/extending/embedding.rst:8 | ||
msgid "Embedding Python in Another Application" | ||
@@ -160,6 +161,40 @@ msgid "" | ||
" Py_ExitStatusException(status);\n" | ||
"}" | ||
msgstr "" | ||
"#define PY_SSIZE_T_CLEAN\n" | ||
"#include <Python.h>\n" | ||
"\n" | ||
"int\n" | ||
"main(int argc, char *argv[])\n" | ||
"{\n" | ||
" PyStatus status;\n" | ||
" PyConfig config;\n" | ||
" PyConfig_InitPythonConfig(&config);\n" | ||
"\n" | ||
" /* optional but recommended */\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Ahora que lo veo: la idea es poder traducir los comentarios en los bloques de código (es la mayor razón en de por qué ahora se incluyen en la traducción) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Eso intenté pero me salía un | ||
" status = PyConfig_SetBytesString(&config, &config.program_name, " | ||
"argv[0]);\n" | ||
" if (PyStatus_Exception(status)) {\n" | ||
" goto exception;\n" | ||
" }\n" | ||
"\n" | ||
" status = Py_InitializeFromConfig(&config);\n" | ||
" if (PyStatus_Exception(status)) {\n" | ||
" goto exception;\n" | ||
" }\n" | ||
" PyConfig_Clear(&config);\n" | ||
"\n" | ||
" PyRun_SimpleString(\"from time import time,ctime\\n\"\n" | ||
" \"print('Today is', ctime(time()))\\n\");\n" | ||
" if (Py_FinalizeEx() < 0) {\n" | ||
" exit(120);\n" | ||
" }\n" | ||
" return 0;\n" | ||
"\n" | ||
" exception:\n" | ||
" PyConfig_Clear(&config);\n" | ||
" Py_ExitStatusException(status);\n" | ||
"}" | ||
#: ../Doc/extending/embedding.rst:92 | ||
msgid "" | ||
@@ -168,9 +203,12 @@ msgid "" | ||
"3.13, but we keep it here for backward compatibility. See :ref:`arg-parsing-" | ||
"string-and-buffers` for a description of this macro." | ||
msgstr "" | ||
"``#define PY_SSIZE_T_CLEAN`` se usaba para indicar que ``Py_ssize_t`` debería " | ||
"usarse en algunas APIs en lugar de ``int``. No es necesario desde Python " | ||
"3.13, pero lo mantenemos aquí por compatibilidad. Ver :ref:`arg-parsing-" | ||
"string-and-buffers` para una descripción de esta macro." | ||
#: ../Doc/extending/embedding.rst:97 | ||
msgid "" | ||
"Setting :c:member:`PyConfig.program_name` should be called before :c:func:" | ||
"`Py_InitializeFromConfig` to inform the interpreter about paths to Python " | ||
@@ -184,16 +222,16 @@ msgid "" | ||
"`PyRun_SimpleFile` function, which saves you the trouble of allocating " | ||
"memory space and loading the file contents." | ||
msgstr "" | ||
"Laconfiguración :c:member:`PyConfig.program_name` debe llamarse antes de :c:" | ||
"func:`Py_InitializeFromConfig` para informar al intérprete sobre las rutas a " | ||
"lasbibliotecas de tiempo de ejecución de Python. A continuación, el " | ||
"intérpretede Python se inicializa con :c:func:`Py_Initialize`, seguido de " | ||
"la ejecuciónde un script Python codificado que imprime la fecha y la hora. " | ||
"Luego, lallamada :c:func:`Py_FinalizeEx` cierra el intérprete, seguido por " | ||
"el finaldel programa. En un programa real, es posible que desee obtener el " | ||
"script dePython de otra fuente, tal vez una rutina de editor de texto, un " | ||
"archivo ouna base de datos. Obtener el código Python de un archivo se puede " | ||
"hacermejor usando la función :c:func:`PyRun_SimpleFile`, que le ahorra la " | ||
"molestia de asignar espacio de memoria y cargar el contenido del archivo." | ||
#: ../Doc/extending/embedding.rst:112 | ||
@@ -383,6 +421,78 @@ msgid "" | ||
" return 0;\n" | ||
"}\n" | ||
msgstr "" | ||
"#define PY_SSIZE_T_CLEAN\n" | ||
"#include <Python.h>\n" | ||
"\n" | ||
"int\n" | ||
"main(int argc, char *argv[])\n" | ||
"{\n" | ||
" PyObject *pName, *pModule, *pFunc;\n" | ||
" PyObject *pArgs, *pValue;\n" | ||
" int i;\n" | ||
"\n" | ||
" if (argc < 3) {\n" | ||
" fprintf(stderr,\"Usage: call pythonfile funcname [args]\\n\");\n" | ||
" return 1;\n" | ||
" }\n" | ||
"\n" | ||
" Py_Initialize();\n" | ||
" pName = PyUnicode_DecodeFSDefault(argv[1]);\n" | ||
" /* Error checking of pName left out */\n" | ||
"\n" | ||
" pModule = PyImport_Import(pName);\n" | ||
" Py_DECREF(pName);\n" | ||
"\n" | ||
" if (pModule != NULL) {\n" | ||
" pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" | ||
" /* pFunc is a new reference */\n" | ||
"\n" | ||
" if (pFunc && PyCallable_Check(pFunc)) {\n" | ||
" pArgs = PyTuple_New(argc - 3);\n" | ||
" for (i = 0; i < argc - 3; ++i) {\n" | ||
" pValue = PyLong_FromLong(atoi(argv[i + 3]));\n" | ||
" if (!pValue) {\n" | ||
" Py_DECREF(pArgs);\n" | ||
" Py_DECREF(pModule);\n" | ||
" fprintf(stderr, \"Cannot convert argument\\n\");\n" | ||
" return 1;\n" | ||
" }\n" | ||
" /* pValue reference stolen here: */\n" | ||
" PyTuple_SetItem(pArgs, i, pValue);\n" | ||
" }\n" | ||
" pValue = PyObject_CallObject(pFunc, pArgs);\n" | ||
" Py_DECREF(pArgs);\n" | ||
" if (pValue != NULL) {\n" | ||
" printf(\"Result of call: %ld\\n\", PyLong_AsLong(pValue));\n" | ||
" Py_DECREF(pValue);\n" | ||
" }\n" | ||
" else {\n" | ||
" Py_DECREF(pFunc);\n" | ||
" Py_DECREF(pModule);\n" | ||
" PyErr_Print();\n" | ||
" fprintf(stderr,\"Call failed\\n\");\n" | ||
" return 1;\n" | ||
" }\n" | ||
" }\n" | ||
" else {\n" | ||
" if (PyErr_Occurred())\n" | ||
" PyErr_Print();\n" | ||
" fprintf(stderr, \"Cannot find function \\\"%s\\\"\\n\", " | ||
"argv[2]);\n" | ||
" }\n" | ||
" Py_XDECREF(pFunc);\n" | ||
" Py_DECREF(pModule);\n" | ||
" }\n" | ||
" else {\n" | ||
" PyErr_Print();\n" | ||
" fprintf(stderr, \"Failed to load \\\"%s\\\"\\n\", argv[1]);\n" | ||
" return 1;\n" | ||
" }\n" | ||
" if (Py_FinalizeEx() < 0) {\n" | ||
" return 120;\n" | ||
" }\n" | ||
" return 0;\n" | ||
"}\n" | ||
#: ../Doc/extending/embedding.rst:165 | ||
msgid "" | ||
@@ -407,6 +517,12 @@ msgid "" | ||
" c = c + b\n" | ||
" return c" | ||
msgstr "" | ||
"def multiply(a,b):\n" | ||
" print(\"Will compute\", a, \"times\", b)\n" | ||
" c = 0\n" | ||
" for i in range(0, a):\n" | ||
" c = c + b\n" | ||
" return c" | ||
#: ../Doc/extending/embedding.rst:180 | ||
msgid "then the result should be:" | ||
@@ -418,6 +534,9 @@ msgid "" | ||
"Will compute 3 times 2\n" | ||
"Result of call: 6" | ||
msgstr "" | ||
"$ call multiply multiply 3 2\n" | ||
"Will compute 3 times 2\n" | ||
"Result of call: 6" | ||
#: ../Doc/extending/embedding.rst:188 | ||
msgid "" | ||
@@ -437,6 +556,10 @@ msgid "" | ||
"/* Error checking of pName left out */\n" | ||
"pModule = PyImport_Import(pName);" | ||
msgstr "" | ||
"Py_Initialize();\n" | ||
"pName = PyUnicode_DecodeFSDefault(argv[1]);\n" | ||
"/* Error checking of pName left out */\n" | ||
"pModule = PyImport_Import(pName);" | ||
#: ../Doc/extending/embedding.rst:197 | ||
msgid "" | ||
@@ -460,6 +583,13 @@ msgid "" | ||
"}\n" | ||
"Py_XDECREF(pFunc);" | ||
msgstr "" | ||
"pFunc = PyObject_GetAttrString(pModule, argv[2]);\n" | ||
"/* pFunc is a new reference */\n" | ||
"\n" | ||
"if (pFunc && PyCallable_Check(pFunc)) {\n" | ||
" ...\n" | ||
"}\n" | ||
"Py_XDECREF(pFunc);" | ||
#: ../Doc/extending/embedding.rst:210 | ||
msgid "" | ||
@@ -477,7 +607,7 @@ msgstr "" | ||
#: ../Doc/extending/embedding.rst:216 | ||
msgid "pValue = PyObject_CallObject(pFunc, pArgs);" | ||
msgstr "pValue = PyObject_CallObject(pFunc, pArgs);" | ||
#: ../Doc/extending/embedding.rst:218 | ||
msgid "" | ||
@@ -544,6 +674,33 @@ msgid "" | ||
" return PyModule_Create(&EmbModule);\n" | ||
"}" | ||
msgstr "" | ||
"static int numargs=0;\n" | ||
"\n" | ||
"/* Return the number of arguments of the application command line */\n" | ||
"static PyObject*\n" | ||
"emb_numargs(PyObject *self, PyObject *args)\n" | ||
"{\n" | ||
" if(!PyArg_ParseTuple(args, \":numargs\"))\n" | ||
" return NULL;\n" | ||
" return PyLong_FromLong(numargs);\n" | ||
"}\n" | ||
"\n" | ||
"static PyMethodDef EmbMethods[] = {\n" | ||
" {\"numargs\", emb_numargs, METH_VARARGS,\n" | ||
" \"Return the number of arguments received by the process.\"},\n" | ||
" {NULL, NULL, 0, NULL}\n" | ||
"};\n" | ||
"\n" | ||
"static PyModuleDef EmbModule = {\n" | ||
" PyModuleDef_HEAD_INIT, \"emb\", NULL, -1, EmbMethods,\n" | ||
" NULL, NULL, NULL, NULL\n" | ||
"};\n" | ||
"\n" | ||
"static PyObject*\n" | ||
"PyInit_emb(void)\n" | ||
"{\n" | ||
" return PyModule_Create(&EmbModule);\n" | ||
"}" | ||
#: ../Doc/extending/embedding.rst:265 | ||
msgid "" | ||
@@ -559,23 +716,26 @@ msgid "" | ||
"numargs = argc;\n" | ||
"PyImport_AppendInittab(\"emb\", &PyInit_emb);" | ||
msgstr "" | ||
"numargs = argc;\n" | ||
"PyImport_AppendInittab(\"emb\", &PyInit_emb);" | ||
#: ../Doc/extending/embedding.rst:271 | ||
msgid "" | ||
"These two lines initialize the ``numargs`` variable, and make the :func:`!" | ||
"emb.numargs` function accessible to the embedded Python interpreter. With " | ||
"these extensions, the Python script can do things like" | ||
msgstr "" | ||
"Estas dos líneas inicializan la variable ``numargs`` y hacen que la función :" | ||
"func:`!emb.numargs` sea accesible para el intérprete de Python incorporado. " | ||
"Con estas extensiones, el script de Python puede hacer cosas como" | ||
#: ../Doc/extending/embedding.rst:275 | ||
msgid "" | ||
"import emb\n" | ||
"print(\"Number of arguments\", emb.numargs())" | ||
msgstr "" | ||
"import emb\n" | ||
"print(\"Number of arguments\", emb.numargs())" | ||
#: ../Doc/extending/embedding.rst:280 | ||
msgid "" | ||
@@ -647,21 +807,27 @@ msgid "" | ||
"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " | ||
"-g -fwrapv -O3 -Wall" | ||
msgstr "" | ||
"$ /opt/bin/python3.11-config --cflags\n" | ||
"-I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare -DNDEBUG " | ||
"-g -fwrapv -O3 -Wall" | ||
#: ../Doc/extending/embedding.rst:323 | ||
msgid "" | ||
"``pythonX.Y-config --ldflags --embed`` will give you the recommended flags " | ||
"when linking:" | ||
msgstr "" | ||
"``pythonX.Y-config --ldflags --embed`` le dará las banderas recomendadas al " | ||
"vincular:" | ||
#: ../Doc/extending/embedding.rst:326 | ||
msgid "" | ||
"$ /opt/bin/python3.11-config --ldflags --embed\n" | ||
"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" | ||
"lpthread -ldl -lutil -lm" | ||
msgstr "" | ||
"$ /opt/bin/python3.11-config --ldflags --embed\n" | ||
"-L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -" | ||
"lpthread -ldl -lutil -lm" | ||
#: ../Doc/extending/embedding.rst:332 | ||
msgid "" | ||
@@ -703,3 +869,8 @@ msgid "" | ||
">>> sysconfig.get_config_var('LINKFORSHARED')\n" | ||
"'-Xlinker -export-dynamic'" | ||
msgstr "" | ||
">>> import sysconfig\n" | ||
">>> sysconfig.get_config_var('LIBS')\n" | ||
"'-lpthread -ldl -lutil'\n" | ||
">>> sysconfig.get_config_var('LINKFORSHARED')\n" | ||
"'-Xlinker -export-dynamic'" |