def _make_plugin_spec(dest_file, name, version, summary, license, packager, vendor, url): with open(SPEC_TEMPLATE, "r") as f: template = f.read() extra_vars = {"NAME": name, "VERSION": version, "SUMMARY": summary, "LICENSE": license, "PACKAGER": packager, "VENDOR": vendor, "URL": url} res = envtpl.render_string(template, extra_variables=extra_vars) # because, you can have some template inside extra vars res = envtpl.render_string(res) with open(dest_file, "w") as f: f.write(res)
def _make_plugin_spec(dest_file, name, version, summary, license, packager, vendor, url): with open(SPEC_TEMPLATE, "r") as f: template = f.read() extra_vars = {"NAME": name, "VERSION": version, "SUMMARY": summary, "LICENSE": license, "PACKAGER": packager, "VENDOR": vendor, "URL": url} res = envtpl.render_string(template, extra_variables=extra_vars, keep_multi_blank_lines=False) # because, you can have some template inside extra vars res = envtpl.render_string(res, keep_multi_blank_lines=False) with open(dest_file, "w") as f: f.write(res)
def parse(self, stream): """Parses the keys and values from a config file. NOTE: For keys that were specified to configargparse as action="store_true" or "store_false", the config file value must be one of: "yes", "no", "true", "false". Otherwise an error will be raised. Args: stream: A config file input stream (such as an open file object). Returns: OrderedDict of items where the keys have type string and the values have type either string or list (eg. to support config file formats like YAML which allow lists). """ f = self.custom_environment_callable f(self.plugin_name, self.step_name) config = os.environ.get('MFCONFIG', 'GENERIC') config_parser = ExtendedConfigParser(config=config, inheritance='im', interpolation=None) content = stream.read() if (sys.version_info < (3, 0)): content = content.decode("utf-8") config_parser.read_string(content) section = "step_%s" % self.step_name result = collections.OrderedDict() for key in config_parser.options(section): if not key.startswith('arg_'): continue if (sys.version_info < (3, 0)): result[key.replace('arg_', '', 1)] = envtpl.render_string( config_parser.get(section, key), keep_multi_blank_lines=False).encode('utf-8') else: result[key.replace('arg_', '', 1)] = envtpl.render_string( config_parser.get(section, key), keep_multi_blank_lines=False) return result