def _write_spec_file(self, instance, rpm_name, template_name, params):
        requires_what = params.get('requires', [])
        conflicts_what = params.get('conflicts', [])
        test_requires_what = params.get('test_requires', [])
        test_conflicts_what = params.get('test_conflicts', [])
        egg_info = getattr(instance, 'egg_info', None)
        if egg_info:

            def ei_names(key):
                try:
                    requires_python = [str(req) for req in egg_info[key]]
                except __HOLE__:
                    return [], []
                else:
                    return self.py2rpm_helper.names_to_rpm_deps(requires_python)

            rpm_requires, rpm_conflicts = ei_names('dependencies')
            requires_what.extend(rpm_requires)
            conflicts_what.extend(rpm_conflicts)
            rpm_test_requires, rpm_test_conflicts = ei_names('test_dependencies')
            test_requires_what.extend(rpm_test_requires)
            test_conflicts_what.extend(rpm_test_conflicts)

        params["requires"] = requires_what
        params["conflicts"] = conflicts_what
        params["test_requires"] = test_requires_what
        params["test_conflicts"] = test_conflicts_what
        params["epoch"] = self.OPENSTACK_EPOCH
        params["part_fn"] = lambda filename: sh.joinpths(
            settings.TEMPLATE_DIR,
            self.SPEC_TEMPLATE_DIR,
            filename)
        parsed_version = pkg_resources.parse_version(params["version"])
        params.update(self._make_spec_functors(parsed_version))
        content = utils.load_template(self.SPEC_TEMPLATE_DIR, template_name)[1]
        spec_filename = sh.joinpths(self.rpmbuild_dir, "SPECS", "%s.spec" % rpm_name)
        sh.write_file(spec_filename, utils.expand_template(content, params),
                      tracewriter=self.tracewriter)
        return spec_filename
dataset/ETHPy150Open openstack/anvil/anvil/packaging/yum.py/YumDependencyHandler._write_spec_file