Skip to content

Commit cce1585

Browse files
committed
[validation] Add new function docstrings
1 parent 38adb0a commit cce1585

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

odml/validation.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,35 @@ def section_repository_present(sec):
134134

135135

136136
def document_unique_ids(doc):
137+
"""
138+
Traverse an odML Document and check whether all
139+
assigned ids are unique within the document.
140+
141+
Yields all duplicate odML object id entries
142+
that are encountered.
143+
144+
:param doc: odML document
145+
"""
137146
id_map = {doc.id: "Document '%s'" % doc.get_path()}
138147
for i in section_unique_ids(doc, id_map):
139148
yield i
140149

141150

142151
def section_unique_ids(parent, id_map=None):
152+
"""
153+
Traverse a parent (odML Document or Section)
154+
and check whether all assigned ids are unique.
155+
156+
A "id":"odML object / path" dictionary of additional
157+
'to-be-excluded' ids may be handed in via the
158+
*id_map* attribute.
159+
160+
Yields all duplicate odML object id entries
161+
that are encountered.
162+
163+
:param parent: odML Document or Section
164+
:param id_map: "id":"odML object / path" dictionary
165+
"""
143166
if not id_map:
144167
id_map = {}
145168

@@ -157,11 +180,25 @@ def section_unique_ids(parent, id_map=None):
157180
yield i
158181

159182

160-
def property_unique_ids(parent, id_map=None):
183+
def property_unique_ids(section, id_map=None):
184+
"""
185+
Check whether all ids assigned to the odML
186+
Properties of an odML Section are unique.
187+
188+
A "id":"odML object / path" dictionary of additional
189+
'to-be-excluded' ids may be handed in via the
190+
*id_map* attribute.
191+
192+
Yields all duplicate odML object id entries
193+
that are encountered.
194+
195+
:param section: odML Section
196+
:param id_map: "id":"odML object / path" dictionary
197+
"""
161198
if not id_map:
162199
id_map = {}
163200

164-
for prop in parent.properties:
201+
for prop in section.properties:
165202
if prop.id in id_map:
166203
yield ValidationError(prop, "Duplicate id in Property '%s' and '%s'" %
167204
(prop.get_path(), id_map[prop.id]))

0 commit comments

Comments
 (0)