def _CheckDocument(document):
 no_repeat_date_names = set()
 no_repeat_number_names = set()
 for field in document.fields:
  if isinstance(field, NumberField):
   if (field.name in no_repeat_number_names):
    raise ValueError(('Invalid document %s: field %s with type date or number may not be repeated.' % (document.doc_id, field.name)))
   no_repeat_number_names.add(field.name)
  elif isinstance(field, DateField):
   if (field.name in no_repeat_date_names):
    raise ValueError(('Invalid document %s: field %s with type date or number may not be repeated.' % (document.doc_id, field.name)))
   no_repeat_date_names.add(field.name)

def _CheckDocument ( document ) : no_repeat_date_names = set ( ) no_repeat_number_names = set ( ) for field in document . fields : if isinstance ( field , NumberField ) : if ( field . name in no_repeat_number_names ) : raise ValueError ( ( 'Invalid document %s: field %s with type date or number may not be repeated.' % ( document . doc_id , field . name ) ) ) no_repeat_number_names . add ( field . name ) elif isinstance ( field , DateField ) : if ( field . name in no_repeat_date_names ) : raise ValueError ( ( 'Invalid document %s: field %s with type date or number may not be repeated.' % ( document . doc_id , field . name ) ) ) no_repeat_date_names . add ( field . name )
check that the document is valid .