'Function to extract the strings from menus.py'

def parseMenu(self, spmod, strings, entry, level):

    if isinstance(entry, list):
        id = entry[0]
        value = entry[1]
        if isinstance(value, list):
            parseMenu = self.parseMenu
            for element in entry:
                parseMenu(spmod, strings, element, (level + 1))
        elif (self.cflag == 1):
            self.class_name = value
            self.cflag = 0
        elif ((token.tok_name[id] == 'NAME') and (value == 'class')):
            self.cflag = 1
        elif (self.fflag == 1):
            self.func_name = value
            self.fflag = 0
        elif ((token.tok_name[id] == 'NAME') and (value == 'def') and ((self.findent == (-1)) or (level == self.findent))):
            if (self.class_name == 'S3OptionsMenu'):
                self.findent = level
                self.fflag = 1
            else:
                self.func_name = ''
        elif ((token.tok_name[id] == 'NAME') and (value == 'T')):
            self.sflag = 1
        elif (self.sflag == 1):
            if (token.tok_name[id] == 'LPAR'):
                self.tflag = 1
                self.bracket = 1
            self.sflag = 0
        elif (self.tflag == 1):
            if (token.tok_name[id] == 'LPAR'):
                self.bracket += 1
                if (self.bracket > 1):
                    self.outstr += '('
            elif (token.tok_name[id] == 'RPAR'):
                self.bracket -= 1
                if (self.bracket > 0):
                    self.outstr += ')'
                else:
                    if (spmod == 'core'):
                        if (self.func_name == ''):
                            strings.append((entry[2], self.outstr))
                    elif (self.func_name == spmod):
                        strings.append((entry[2], self.outstr))
                    self.outstr = ''
                    self.tflag = 0
            elif (self.bracket > 0):
                self.outstr += value
        elif ((token.tok_name[id] == 'NAME') and (value == 'M')):
            self.mflag = 1
        elif (self.mflag == 1):
            if (token.tok_name[id] == 'STRING'):
                if (spmod == 'core'):
                    if (self.func_name == ''):
                        strings.append((entry[2], value))
                elif (self.func_name == spmod):
                    strings.append((entry[2], value))
            elif ((token.tok_name[id] == 'EQUAL') or (token.tok_name[id] == 'RPAR')):
                self.mflag = 0
