Writes out symbol tables to project's config/.symbols directory

def index_apex_symbols(self, apex_class_name_or_names=None):
        '''
            Writes out symbol tables to project's config/.symbols directory
        '''
        
        try:
            if not os.path.exists(os.path.join(self.location,"config",".symbols")):
                os.makedirs(os.path.join(self.location,"config",".symbols"))
            
            symbol_table_result = {
                "records" : []
            }

            if apex_class_name_or_names == None:
                apex_ids = []
                classes = self.sfdc_client.list_metadata("ApexClass", True)
                for c in classes:
                    apex_ids.append(c['id'])

                list_of_apex_id_lists = list(util.list_grouper(20, apex_ids)) #split apex ids into lists of max size 20
                for apex_ids_list in list_of_apex_id_lists:                    
                    local_symbol_table_result = self.sfdc_client.get_symbol_tables_by_class_id(apex_ids_list)
                    if 'records' in local_symbol_table_result and len(local_symbol_table_result['records']) > 0:
                        symbol_table_result['records'] = symbol_table_result['records'] + local_symbol_table_result['records']
            else:
                class_names = []
                if type(apex_class_name_or_names) is not list:
                    apex_class_name_or_names = [apex_class_name_or_names]

                for class_name in apex_class_name_or_names:
                    apex_class_name = os.path.basename(class_name)
                    apex_class_name = apex_class_name.replace(".cls","")
                    class_names.append(apex_class_name)

                list_of_apex_class_name_lists = list(util.list_grouper(20, class_names)) #split apex ids into lists of max size 20
                for apex_class_names_list in list_of_apex_class_name_lists:                    
                    local_symbol_table_result = self.sfdc_client.get_symbol_tables_by_class_name(apex_class_names_list)
                    if 'records' in local_symbol_table_result and len(local_symbol_table_result['records']) > 0:
                        symbol_table_result['records'] = symbol_table_result['records'] + local_symbol_table_result['records']

            if 'records' in symbol_table_result and len(symbol_table_result['records']) > 0:
                for r in symbol_table_result['records']:
                    if "SymbolTable" in r and r["SymbolTable"] != None and r["SymbolTable"] != {}:
                        file_name = ""
                        if "NamespacePrefix" in r and r["NamespacePrefix"] != None:
                            file_name = r["NamespacePrefix"]+"."+r["Name"]+".json"
                        else:
                            file_name = r["Name"]+".json"
                        src = open(os.path.join(self.location,"config",".symbols",file_name), "w")
                        json_data = json.dumps(r["SymbolTable"], indent=4)
                        src.write(json_data)
                        src.close()

            return util.generate_success_response("Apex symbols indexed successfully")
        #except (TypeError):
        except BaseException, e:
            debug('------> error indexing apex symbols')
            debug(e.message)

            directories = []
            if os.path.exists(os.path.join(self.location, 'src', 'classes')):
                directories.append(os.path.join(self.location, 'src', 'classes'))

            if os.path.exists(os.path.join(self.location, 'src', 'triggers')):
                directories.append(os.path.join(self.location, 'src', 'triggers'))

            params = {
                'files'         : [],
                'directories'   : directories
            }
            retrieve_result = self.get_retrieve_result(params)
            fileProperties = retrieve_result.fileProperties
            apex_ids = []
            for prop in fileProperties:
                if prop.type == "ApexClass":
                    apex_ids.append(prop.id)   
            symbol_table_result = self.sfdc_client.get_symbol_table(apex_ids)
            debug(symbol_table_result)
            if 'records' in symbol_table_result and len(symbol_table_result['records']) > 0:
                for r in symbol_table_result['records']:
                    if "SymbolTable" in r and r["SymbolTable"] != None and r["SymbolTable"] != {}:
                        file_name = ""
                        if "NamespacePrefix" in r and r["NamespacePrefix"] != None:
                            file_name = r["NamespacePrefix"]+"."+r["Name"]+".json"
                        else:
                            file_name = r["ContentEntity"]["Name"]+".json"
                        src = open(os.path.join(self.location,"config",".symbols",file_name), "w")
                        json_data = json.dumps(r["SymbolTable"], indent=4)
                        src.write(json_data)
                        src.close()

            return util.generate_success_response("Apex symbols indexed successfully")