def create_rc_file(self, packages):
print("<STR_LIT>" % self.rc_filename)<EOL>if not self.config.sections():<EOL><INDENT>self._write_default_sections()<EOL><DEDENT>sections = {}<EOL>section_text = []<EOL>for i, section in enumerate(self.config.sections()):<EOL><INDENT>if section == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>sections[i] = section<EOL>section_text.append('<STR_LIT>' % (i, section))<EOL><DEDENT>section_text = '<STR_LIT>'.join(section_text)<EOL>self._remap_stdin()<EOL>package_names = set()<EOL>lines = packages.readlines()<EOL>requirements = self._parse_requirements(lines)<EOL>for (package, version) in requirements:<EOL><INDENT>package_names.add(package)<EOL>section, configured_version = self._get_option(package)<EOL>if section:<EOL><INDENT>if configured_version:<EOL><INDENT>if configured_version != version:<EOL><INDENT>print("<STR_LIT>"<EOL>% (package, configured_version, version))<EOL>self.config.set(section, package, version)<EOL><DEDENT><DEDENT>continue<EOL><DEDENT>section = self._get_section(package, sections, section_text)<EOL>self._set_option(section, package, version)<EOL><DEDENT>for section in self.config.sections():<EOL><INDENT>if section == '<STR_LIT>':<EOL><INDENT>continue<EOL><DEDENT>for option in self.config.options(section):<EOL><INDENT>if option not in package_names:<EOL><INDENT>print("<STR_LIT>" % option)<EOL>self.config.remove_option(section, option)<EOL><DEDENT><DEDENT><DEDENT>rc_file = open(self.rc_filename, '<STR_LIT>')<EOL>self.config.write(rc_file)<EOL>rc_file.close()<EOL>
Create a set of requirements files for config