'Make a new client object.'

def CreateClientObject(self, vfs_fixture):

    aff4.FACTORY.Delete(self.client_id, token=self.token)
    with test_lib.FakeTime(self.age):
        for (path, (aff4_type, attributes)) in vfs_fixture:
            path %= self.args
            aff4_object = aff4.FACTORY.Create(self.client_id.Add(path), aff4_type, mode='rw', token=self.token)
            for (attribute_name, value) in attributes.items():
                attribute = aff4.Attribute.PREDICATES[attribute_name]
                if isinstance(value, (str, unicode)):
                    value %= self.args
                if aff4.issubclass(attribute.attribute_type, rdf_protodict.RDFValueArray):
                    rdfvalue_object = attribute()
                    for item in value:
                        new_object = rdfvalue_object.rdf_type.FromTextFormat(utils.SmartStr(item))
                        rdfvalue_object.Append(new_object)
                elif aff4.issubclass(attribute.attribute_type, rdf_structs.RDFProtoStruct):
                    rdfvalue_object = attribute.attribute_type.FromTextFormat(utils.SmartStr(value))
                elif aff4.issubclass(attribute.attribute_type, rdfvalue.RDFInteger):
                    rdfvalue_object = attribute(int(value))
                else:
                    rdfvalue_object = attribute(value)
                if (aff4_object.Get(aff4_object.Schema.PATHSPEC) is None):
                    if (attribute.attribute_type == rdf_client.StatEntry):
                        stat_object = attribute.attribute_type.FromTextFormat(utils.SmartStr(value))
                        if stat_object.pathspec:
                            pathspec_attribute = aff4.Attribute('aff4:pathspec', rdf_paths.PathSpec, 'The    pathspec    used    to    retrieve    this    object    from    the    client.', 'pathspec')
                            aff4_object.AddAttribute(pathspec_attribute, stat_object.pathspec)
                if (attribute in ['aff4:content', 'aff4:content']):
                    aff4_object.Write(rdfvalue_object)
                else:
                    aff4_object.AddAttribute(attribute, rdfvalue_object)
            if (aff4_type == aff4_grr.VFSGRRClient):
                kb = rdf_client.KnowledgeBase()
                artifact.SetCoreGRRKnowledgeBaseValues(kb, aff4_object)
                aff4_object.Set(aff4_object.Schema.KNOWLEDGE_BASE, kb)
            aff4_object.Flush()
            if (aff4_type == aff4_grr.VFSGRRClient):
                index = client_index.CreateClientIndex(token=self.token)
                index.AddClient(aff4_object)
