import inspect
import json
import os
import sys

from LoadMiWor.ui.processTool.parserWor.ParserMiCommand.clsParser import baseParser


def initLoadLibParser():
    def_name_json_descriptor="descriptionParsers.json"
    curent_path=os.path.dirname(os.path.abspath(__file__))
    file_json=os.path.join(curent_path,def_name_json_descriptor)
    data_descriptions=None
    with open(file_json) as json_file:
        data_descriptions = json.load(json_file)
    dict_pattern= {}
    list_parsers=data_descriptions['list_parser']
    for item in list_parsers:
        name=item['name']
        pattern=item['pattern']
        dict_pattern[name]=baseParser(pattern)
    return dict_pattern

