From fa5480e8bccec39278e9c5f81c09d1e702fd0fd7 Mon Sep 17 00:00:00 2001
From: Sebastian Koslowski <koslowski@kit.edu>
Date: Sun, 24 Nov 2013 20:23:39 +0100
Subject: modtool: no more exit() in modtool package

Conflicts:
	gr-utils/python/modtool/modtool_newmod.py
---
 gr-utils/python/modtool/modtool_makexml.py | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'gr-utils/python/modtool/modtool_makexml.py')

diff --git a/gr-utils/python/modtool/modtool_makexml.py b/gr-utils/python/modtool/modtool_makexml.py
index 777cc09e1f..4b67d1b062 100644
--- a/gr-utils/python/modtool/modtool_makexml.py
+++ b/gr-utils/python/modtool/modtool_makexml.py
@@ -20,32 +20,32 @@
 #
 """ Automatically create XML bindings for GRC from block code """
 
-import sys
 import os
 import re
 import glob
-from optparse import OptionGroup
 
-from modtool_base import ModTool
+from modtool_base import ModTool, ModToolException
 from parser_cc_block import ParserCCBlock
 from grc_xml_generator import GRCXMLGenerator
 from cmakefile_editor import CMakeFileEditor
 from util_functions import ask_yes_no
 
+
 class ModToolMakeXML(ModTool):
     """ Make XML file for GRC block bindings """
     name = 'makexml'
     aliases = ('mx',)
+
     def __init__(self):
         ModTool.__init__(self)
 
-    def setup(self):
-        ModTool.setup(self)
-        options = self.options
+    def setup(self, options, args):
+        ModTool.setup(self, options, args)
+
         if options.block_name is not None:
             self._info['pattern'] = options.block_name
-        elif len(self.args) >= 2:
-            self._info['pattern'] = self.args[1]
+        elif len(args) >= 2:
+            self._info['pattern'] = args[1]
         else:
             self._info['pattern'] = raw_input('Which blocks do you want to parse? (Regex): ')
         if len(self._info['pattern']) == 0:
@@ -67,7 +67,6 @@ class ModToolMakeXML(ModTool):
                 self._make_grc_xml_from_block_data(params, iosig, blockname)
         # 2) Go through python/
 
-
     def _search_files(self, path, path_glob):
         """ Search for files matching pattern in the given path. """
         files = glob.glob("%s/%s"% (path, path_glob))
@@ -152,7 +151,7 @@ class ModToolMakeXML(ModTool):
                                    _type_translate
                                   )
         except IOError:
-            print "Can't open some of the files necessary to parse %s." % fname_cc
-            sys.exit(1)
+            raise ModToolException("Can't open some of the files necessary to parse {}.".format(fname_cc))
+
         return (parser.read_params(), parser.read_io_signature(), blockname)
 
-- 
cgit v1.2.3