def _configure(<EOL>self, target, conf=None, logger=None, callconf=None, keepstate=None,<EOL>modules=None<EOL>):
result = target<EOL>self.loadmodules(modules=modules)<EOL>modules = []<EOL>if conf is None:<EOL><INDENT>conf = self.conf<EOL><DEDENT>if logger is None:<EOL><INDENT>logger = self.logger<EOL><DEDENT>if callconf is None:<EOL><INDENT>callconf = self.callparams<EOL><DEDENT>if keepstate is None:<EOL><INDENT>keepstate = self.keepstate<EOL><DEDENT>subcats = {}  <EOL>params = []  <EOL>sub_conf_prefix = Configurable.SUB_CONF_PREFIX<EOL>for cat in conf.values():  <EOL><INDENT>cname = cat.name<EOL>if cname.startswith(sub_conf_prefix):<EOL><INDENT>subcnames = cname.split(sub_conf_prefix)<EOL>pname = subcnames[<NUM_LIT:1>]<EOL>fcname = cname[<NUM_LIT:1> + len(pname):]<EOL>if not fcname:<EOL><INDENT>fcname = str(random())<EOL><DEDENT>fcat = cat.copy(name=fcname)<EOL>if pname in subcats:<EOL><INDENT>subcats[pname].append(fcat)<EOL><DEDENT>else:<EOL><INDENT>subcats[pname] = [fcat]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>cparams = cat.params<EOL>params += cparams.values()<EOL><DEDENT><DEDENT>if callconf and callable(target):<EOL><INDENT>conf = self._toconf(params)<EOL>args, kwargs = self.getcallparams(conf=conf, target=target)<EOL>result = target = target(*args, **kwargs)<EOL><DEDENT>for param in params:<EOL><INDENT>value, pname = param.value, param.name<EOL>if pname in subcats:  <EOL><INDENT>subcallconf = True<EOL>if keepstate and hasattr(target, pname):<EOL><INDENT>subcallconf = False<EOL>value = getattr(target, pname)<EOL><DEDENT>cats = subcats[pname]<EOL>subconf = configuration(*cats)<EOL>targets = applyconfiguration(<EOL>targets=[value], conf=subconf, callconf=subcallconf,<EOL>keepstate=keepstate, modules=modules<EOL>)<EOL>value = targets[<NUM_LIT:0>]<EOL><DEDENT>if param.error:<EOL><INDENT>continue<EOL><DEDENT>elif self.foreigns or param.local:<EOL><INDENT>try:<EOL><INDENT>setattr(target, pname, value)<EOL><DEDENT>except Exception:<EOL><INDENT>if logger is not None:<EOL><INDENT>logger.error(<EOL>'<STR_LIT>'.format(<EOL>pname, value, target, format_exc()<EOL>)<EOL>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Configure this class with input conf only if auto_conf or
        configure is true.

        This method should be overriden for specific conf

        :param target: object to configure. self targets by default.
        :param Configuration conf: configuration model to configure. Default is
            this conf.
        :param Logger logger: logger to use.
        :param bool callconf: if True, use conf in target __call__ parameters.
        :param bool keepstate: if True recreate sub objects if they already
            exist.
        :param list modules: modules to reload before.
        :return: configured target.