(self, name_or_collection,
                            scandata=False, full=False)
return result
Validate a collection.

        Returns a dict of validation info. Raises CollectionInvalid if
        validation fails.

        :Parameters:
          - `name_or_collection`: A Collection object or the name of a
            collection to validate.
          - `scandata`: Do extra checks beyond checking the overall
            structure of the collection.
          - `full`: Have the server do a more thorough scan of the
            collection. Use with `scandata` for a thorough scan
            of the structure of the collection and the individual
            documents.
Validate a collection.
Validate a collection .
def validate_collection(self, name_or_collection,
                            scandata=False, full=False):
        """Validate a collection.

        Returns a dict of validation info. Raises CollectionInvalid if
        validation fails.

        :Parameters:
          - `name_or_collection`: A Collection object or the name of a
            collection to validate.
          - `scandata`: Do extra checks beyond checking the overall
            structure of the collection.
          - `full`: Have the server do a more thorough scan of the
            collection. Use with `scandata` for a thorough scan
            of the structure of the collection and the individual
            documents.
        """
        name = name_or_collection
        if isinstance(name, Collection):
            name = name.name

        if not isinstance(name, string_type):
            raise TypeError("name_or_collection must be an instance of "
                            "%s or Collection" % (string_type.__name__,))

        result = self.command("validate", _unicode(name),
                              scandata=scandata, full=full)

        valid = True
        # Pre 1.9 results
        if "result" in result:
            info = result["result"]
            if info.find("exception") != -1 or info.find("corrupt") != -1:
                raise CollectionInvalid("%s invalid: %s" % (name, info))
        # Sharded results
        elif "raw" in result:
            for _, res in iteritems(result["raw"]):
                if "result" in res:
                    info = res["result"]
                    if (info.find("exception") != -1 or
                            info.find("corrupt") != -1):
                        raise CollectionInvalid("%s invalid: "
                                                "%s" % (name, info))
                elif not res.get("valid", False):
                    valid = False
                    break
        # Post 1.9 non-sharded results.
        elif not result.get("valid", False):
            valid = False

        if not valid:
            raise CollectionInvalid("%s invalid: %r" % (name, result))

        return result
def validate_collection ( self , name_or_collection , scandata = False , full = False ) : name = name_or_collection if isinstance ( name , Collection ) : name = name . name if not isinstance ( name , string_type ) : raise TypeError ( "name_or_collection must be an instance of " "%s or Collection" % ( string_type . __name__ , ) ) result = self . command ( "validate" , _unicode ( name ) , scandata = scandata , full = full ) valid = True # Pre 1.9 results if "result" in result : info = result [ "result" ] if info . find ( "exception" ) != - 1 or info . find ( "corrupt" ) != - 1 : raise CollectionInvalid ( "%s invalid: %s" % ( name , info ) ) # Sharded results elif "raw" in result : for _ , res in iteritems ( result [ "raw" ] ) : if "result" in res : info = res [ "result" ] if ( info . find ( "exception" ) != - 1 or info . find ( "corrupt" ) != - 1 ) : raise CollectionInvalid ( "%s invalid: " "%s" % ( name , info ) ) elif not res . get ( "valid" , False ) : valid = False break # Post 1.9 non-sharded results. elif not result . get ( "valid" , False ) : valid = False if not valid : raise CollectionInvalid ( "%s invalid: %r" % ( name , result ) ) return result