X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc_config.py;fp=plc_config.py;h=07097f3b6061368caa4dcab93f5975d3b185d022;hb=2be867636695778c955bbfce0eb27b37fe00c361;hp=fcab1f62d2ac00cdf379de1a76f077383cb3f8d3;hpb=ce74bb0bd3771bd27fe487ff5da21fb7f8a6c1ca;p=myplc.git diff --git a/plc_config.py b/plc_config.py index fcab1f6..07097f3 100644 --- a/plc_config.py +++ b/plc_config.py @@ -719,6 +719,31 @@ DO NOT EDIT. This file was automatically generated at return buf.getvalue() + def output_ruby(self, show_comments = True, encoding = "utf-8"): + """ + Return variables as a shell script. + """ + + buf = codecs.lookup(encoding)[3](StringIO()) + buf.writelines(["# " + line + os.linesep for line in self._header()]) + + for (category_id, (category, variables)) in self._variables.iteritems(): + for variable in variables.values(): + (id, name, value, comments) = self._sanitize_variable(category_id, variable) + if show_comments: + buf.write(os.linesep) + if name is not None: + buf.write("# " + name + os.linesep) + if comments is not None: + buf.writelines(["# " + line + os.linesep for line in comments]) + # bash does not have the concept of NULL + if value is not None: + buf.write("$" + id + "=" + value + os.linesep) + + return buf.getvalue() + + + def output_php(self, encoding = "utf-8"): """