def parse_arguments(self):
        """ Parse command line arguments and
        return a dictionary of option-value pairs """

        try:
            self.optparse = __import__('optparse')
            # For invoking help, when no arguments
            # are passed.
            if len(sys.argv)==1:
                sys.argv.append('-h')

            self._parse_arguments1()
        except ImportError:
            try:
                import getopt
                self.getopt = __import__('getopt')                
                self._parse_arguments2()
            except ImportError:
                raise GenericOptionParserError,'Fatal Error: No optparse or getopt modules found'

        return self._optdict
 Parse command line arguments and
        return a dictionary of option-value pairs 
recipes/Python/425345_Generic_commandline/recipe-425345.py