<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate(self, model, outfolder, *, exclude=None):
 """ Generate model code. Args: model: The meta-model to generate code for. outfolder: Path to the directoty that will contain the generated code. exclude: List of referenced resources for which code was already generated (to prevent regeneration). """

        with pythonic_names():
            super().generate(model, outfolder)

            check_dependency = self.with_dependencies and model.eResource
            if check_dependency:
                if exclude is None:
                    exclude = set()
                resource = model.eResource
                # the current resource had been managed and is excluded from further generations
                exclude.add(resource)
                rset = resource.resource_set
                direct_resources = {r for r in rset.resources.values() if r not in exclude}
                for resource in direct_resources:
                    self.generate(resource.contents[0], outfolder, exclude=exclude)