예제 #1
0
파일: commands.py 프로젝트: mactanxin/cli
    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
예제 #2
0
파일: commands.py 프로젝트: erinix/cli
    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
예제 #3
0
def unparse_(fn):
    output_msg(unparse(FunctionDefinition(fn.name, fn.param_names, fn.exp)))
예제 #4
0
파일: functions.py 프로젝트: erinix/cli
def unparse_(fn):
    output_msg(unparse(FunctionDefinition(
        fn.name,
        fn.param_names,
        fn.exp
    )))