From 18449dbf1166bb346fee4f8be333ae96ac3460f4 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 9 Dec 2014 20:27:27 -0500 Subject: [PATCH] Python: document writer.StructureFieldDeclaration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- bindings/python/writer.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/bindings/python/writer.py b/bindings/python/writer.py index 7c6627e0..9bf9e688 100644 --- a/bindings/python/writer.py +++ b/bindings/python/writer.py @@ -745,9 +745,16 @@ class FloatFieldDeclaration(FloatingPointFieldDeclaration): class StructureFieldDeclaration(FieldDeclaration): + """ + Structure field declaration, i.e. an ordered mapping from field + names to field declarations. + """ + def __init__(self): """ - Create a new structure field declaration. + Creates an empty structure field declaration. + + :exc:`ValueError` is raised on error. """ self._ft = nbt._bt_ctf_field_type_structure_create() @@ -755,7 +762,10 @@ class StructureFieldDeclaration(FieldDeclaration): def add_field(self, field_type, field_name): """ - Add a field of type "field_type" to the structure. + Appends one :class:`FieldDeclaration` *field_type* named + *field_name* to the structure's ordered map. + + :exc:`ValueError` is raised on error. """ ret = nbt._bt_ctf_field_type_structure_add_field(self._ft, @@ -768,7 +778,10 @@ class StructureFieldDeclaration(FieldDeclaration): @property def fields(self): """ - Generator returning the structure's field as tuples of (field name, field declaration). + Generates the (field name, :class:`FieldDeclaration`) pairs + of this structure. + + :exc:`TypeError` is raised on error. """ count = nbt._bt_ctf_field_type_structure_get_field_count(self._ft) @@ -794,7 +807,10 @@ class StructureFieldDeclaration(FieldDeclaration): def get_field_by_name(self, name): """ - Get a field declaration by name (FieldDeclaration). + Returns the :class:`FieldDeclaration` mapped to the field name + *name* in this structure. + + :exc:`TypeError` is raised on error. """ field_type_native = nbt._bt_ctf_field_type_structure_get_field_type_by_name(self._ft, name) -- 2.34.1