def run(self, context, args, kwargs, opargs): ns = self.exec_path[-1] if len(args) > 1: raise CommandException( _('Invalid syntax: {0}. For help see "help <command>"'.format( args))) result = [] if getattr(ns, 'serialize'): try: for i in ns.serialize(): result.append(unparse(i)) except NotImplementedError: return contents = '\n'.join(result) if len(args) == 1: filename = args[0] try: with open(filename, 'w') as f: f.write(contents) except IOError: raise CommandException( _('Error writing to file {0}'.format(filename))) return _('Configuration successfully dumped to file {0}'.format( filename)) else: return contents
def run(self, context, args, kwargs, opargs): ns = self.exec_path[-1] if len(args) > 1: raise CommandException(_('Invalid syntax: {0}. For help see "help <command>"'.format(args))) result = [] if getattr(ns, 'serialize'): try: for i in ns.serialize(): result.append(unparse(i)) except NotImplementedError: return contents = '\n'.join(result) if len(args) == 1: filename = args[0] try: with open(filename, 'w') as f: f.write(contents) except IOError: raise CommandException(_('Error writing to file {0}'.format(filename))) return _('Configuration successfully dumped to file {0}'.format(filename)) else: return contents
def unparse_(fn): output_msg(unparse(FunctionDefinition(fn.name, fn.param_names, fn.exp)))
def unparse_(fn): output_msg(unparse(FunctionDefinition( fn.name, fn.param_names, fn.exp )))