Changes in trunk/ext/_syckmodule.c [20:25]
- File:
-
- 1 edited
-
trunk/ext/_syckmodule.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/_syckmodule.c
r20 r25 43 43 PyDoc_STRVAR(PySyckNode_doc, 44 44 "_syck.Node() -> TypeError\n\n" 45 "_syck.Node is an abstract type. It is abase type for _syck.Scalar,\n"45 "_syck.Node is an abstract type. It is the base type for _syck.Scalar,\n" 46 46 "_syck.Seq, and _syck.Map. You cannot create an instance of _syck.Node\n" 47 47 "directly. You may use _syck.Node for type checking or subclassing.\n"); … … 220 220 " -> a Scalar node\n\n" 221 221 "_syck.Scalar represents a scalar node in Syck parser and emitter\n" 222 " graphs. A scalar node points to a single string value.\n");222 "trees. A scalar node points to a single string value.\n"); 223 223 224 224 typedef struct { … … 549 549 "Seq(value=[], tag=None, inline=False) -> a Seq node\n\n" 550 550 "_syck.Seq represents a sequence node in Syck parser and emitter\n" 551 " graphs. A sequence node points to an ordered set of subnodes.\n");551 "trees. A sequence node points to an ordered set of subnodes.\n"); 552 552 553 553 typedef struct { … … 718 718 719 719 PyDoc_STRVAR(PySyckMap_doc, 720 "Map(value= '', tag=None, inline=False) -> a Map node\n\n"720 "Map(value={}, tag=None, inline=False) -> a Map node\n\n" 721 721 "_syck.Map represents a mapping node in Syck parser and emitter\n" 722 " graphs. A mapping node points to an unordered collections of pairs.\n");722 "trees. A mapping node points to an unordered collections of pairs.\n"); 723 723 724 724 typedef struct { … … 833 833 PyDoc_STR("the node kind, always 'map', read-only"), &PySyck_MapKind}, 834 834 {"value", (getter)PySyckNode_getvalue, (setter)PySyckMap_setvalue, 835 PyDoc_STR("the node value, a mapping"), NULL},835 PyDoc_STR("the node value, a list of pairs or a dictionary"), NULL}, 836 836 {"tag", (getter)PySyckNode_gettag, (setter)PySyckNode_settag, 837 837 PyDoc_STR("the node tag, a string or None"), NULL}, … … 893 893 " -> a Parser object\n\n" 894 894 "_syck.Parser is a low-lever wrapper of the Syck parser. It parses\n" 895 "a YAML stream and produces a graphof Nodes.\n");895 "a YAML stream and produces a tree of Nodes.\n"); 896 896 897 897 typedef struct { … … 1017 1017 static PyGetSetDef PySyckParser_getsetters[] = { 1018 1018 {"source", (getter)PySyckParser_getsource, NULL, 1019 PyDoc_STR("IO source, a string or file-like object"), NULL},1019 PyDoc_STR("IO source, a string or a file-like object"), NULL}, 1020 1020 {"implicit_typing", (getter)PySyckParser_getimplicit_typing, NULL, 1021 1021 PyDoc_STR("implicit typing of builtin YAML types"), NULL}, … … 1253 1253 1254 1254 if (self->parsing) { 1255 PyErr_SetString(PyExc_RuntimeError, "do not call Parser.parse while it is already parsing"); 1255 PyErr_SetString(PyExc_RuntimeError, 1256 "do not call Parser.parse while it is already running"); 1256 1257 return NULL; 1257 1258 } … … 1292 1293 PyDoc_STRVAR(PySyckParser_parse_doc, 1293 1294 "parse() -> the root Node object\n\n" 1294 "Parses the source and returns the next document. On EOF, returns None\n" 1295 "and sets the 'eof' attribute on.\n"); 1295 "Parses the source and returns the root of the Node tree. Call it\n" 1296 "several times to retrieve all documents from the source. On EOF,\n" 1297 "returns None and sets the 'eof' attribute on.\n"); 1296 1298 1297 1299 static PyMethodDef PySyckParser_methods[] = { … … 1348 1350 1349 1351 PyDoc_STRVAR(PySyckEmitter_doc, 1350 "Emitter(output, headless=False, use_header=True, explicit_typing=True," 1351 " style=None, best_width=80, indent=2) -> an Emitter object\n\n" 1352 "_syck.Emitter is a low-lever wrapper of the Syck emitter. It emit\n" 1352 "Emitter(output, headless=False, use_header=False, use_version=False,\n" 1353 " explicit_typing=True, style=None, best_width=80, indent=2)\n" 1354 " -> an Emitter object\n\n" 1355 "_syck.Emitter is a low-lever wrapper of the Syck emitter. It emits\n" 1353 1356 "a tree of Nodes into a YAML stream.\n"); 1354 1357 … … 1530 1533 PyDoc_STR("headerless document flag"), NULL}, 1531 1534 {"use_header", (getter)PySyckEmitter_getuse_header, NULL, 1532 PyDoc_STR("force header "), NULL},1535 PyDoc_STR("force header flag"), NULL}, 1533 1536 {"use_version", (getter)PySyckEmitter_getuse_version, NULL, 1534 PyDoc_STR("force version "), NULL},1537 PyDoc_STR("force version flag"), NULL}, 1535 1538 {"explicit_typing", (getter)PySyckEmitter_getexplicit_typing, NULL, 1536 1539 PyDoc_STR("explicit typing for all collections"), NULL}, … … 1752 1755 Py_INCREF(output); 1753 1756 self->output = output; 1754 1755 /*1756 self->emitter = syck_new_emitter();1757 self->emitter->bonus = self;1758 self->emitter->headless = self->headless;1759 self->emitter->use_header = use_header;1760 self->emitter->use_version = use_version;1761 self->emitter->explicit_typing = explicit_typing;1762 self->emitter->style = self->style;1763 self->emitter->best_width = self->best_width;1764 self->emitter->indent = self->indent;1765 1766 syck_emitter_handler(self->emitter, PySyckEmitter_node_handler);1767 syck_output_handler(self->emitter, PySyckEmitter_write_handler);1768 */1769 1757 1770 1758 self->emitting = 0; … … 1974 1962 PyDoc_STRVAR(PySyckEmitter_emit_doc, 1975 1963 "emit(root_node) -> None\n\n" 1976 "Emit the Node tree to the output.\n");1964 "Emits the Node tree to the output.\n"); 1977 1965 1978 1966 static PyMethodDef PySyckEmitter_methods[] = { … … 2033 2021 2034 2022 PyDoc_STRVAR(PySyck_doc, 2035 "low-level wrapper for the Syck YAML parser and emitter"); 2023 "_syck is a low-level wrapper for the Syck YAML parser and emitter.\n" 2024 "Do not use it directly, use the module 'syck' instead.\n"); 2025 2026 static int 2027 add_slotnames(PyTypeObject *type) 2028 { 2029 PyObject *slotnames; 2030 PyObject *name; 2031 PyGetSetDef *getsetter; 2032 2033 if (!type->tp_getset) return 0; 2034 if (!type->tp_dict) return 0; 2035 2036 slotnames = PyList_New(0); 2037 if (!slotnames) return -1; 2038 2039 for (getsetter = type->tp_getset; getsetter->name; getsetter++) { 2040 if (!getsetter->set) continue; 2041 name = PyString_FromString(getsetter->name); 2042 if (!name) { 2043 Py_DECREF(slotnames); 2044 return -1; 2045 } 2046 if (PyList_Append(slotnames, name) < 0) { 2047 Py_DECREF(name); 2048 Py_DECREF(slotnames); 2049 return -1; 2050 } 2051 Py_DECREF(name); 2052 } 2053 2054 if (PyDict_SetItemString(type->tp_dict, "__slotnames__", slotnames) < 0) { 2055 Py_DECREF(slotnames); 2056 return -1; 2057 } 2058 2059 Py_DECREF(slotnames); 2060 return 0; 2061 } 2036 2062 2037 2063 PyMODINIT_FUNC … … 2044 2070 if (PyType_Ready(&PySyckScalar_Type) < 0) 2045 2071 return; 2072 if (add_slotnames(&PySyckScalar_Type) < 0) 2073 return; 2046 2074 if (PyType_Ready(&PySyckSeq_Type) < 0) 2047 2075 return; 2076 if (add_slotnames(&PySyckSeq_Type) < 0) 2077 return; 2048 2078 if (PyType_Ready(&PySyckMap_Type) < 0) 2079 return; 2080 if (add_slotnames(&PySyckMap_Type) < 0) 2049 2081 return; 2050 2082 if (PyType_Ready(&PySyckParser_Type) < 0)
Note: See TracChangeset
for help on using the changeset viewer.
