# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/xml_loader/htm_loader.py
# class HtmLoader(object):
#     """ Load htm.xml information into a Python element"""
# 
#     def __init__(self):
#         self.htms = []
#         self.htms_include = []
#         self.__load_xml(HTM_FILE)
# 
#     def __load_xml(self, file_name):
#         """Load the contents of htm.xml into a Python element"""
#         tree = elemTree.parse(file_name)
#         self.root = tree.getroot()
#         for htm in self.root.iter('function'):
#             self.htms.append(htm.attrib)
#         for htm_header in self.root.iter('header'):
#             self.htms_include.append(htm_header.attrib)
# 
#     def get_functions(self):
#         """Populate a list of HTM names"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get("type") == "function":
#                 self.htms.append(htm.get('target'))
#         return self.htms
# 
#     def get_includes(self):
#         """Populate a list of HTM includes in the header"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get('type') == 'header':
#                 self.htms_include.append(htm.get('target'))
#         return self.htms_include
# 
#     def get_fixes(self):
#         '''Method to populate a list of htm fixes'''
#         suggestion_dict = {}
#         for sysc in self.root.findall('htmapi'):
#             if sysc.get("replacer"):
#                 suggestion_dict[sysc.get("target")] = (sysc.get("replacer"))
#         return suggestion_dict


from clang.cindex import CursorKind
from ma.checkers.checker import Checker
from ma.xml_loader.htm_loader import HtmLoader

    def get_problem_msg(self):
        return self.problem_msg

    def get_problem_type(self):
        return self.problem_type

    def check_node(self, node):
        if node.kind != CursorKind.CALL_EXPR:
            return False
        if node.displayname in self.htm_functions:
            return True

    def check_include(self, include_name):
        if include_name in self.htm_includes:
            return True

    def get_solution(self, node):
        return self.__create_solution(node)

    def __create_solution(self, node):
        if 'rtmintrin.h' in str(node):
            return "replace rtmintrin.h for htmintrin.h"
        if not isinstance(node, basestring):
            if node.displayname in self.htm_fixes:
                fix = self.htm_fixes[node.displayname]
                return "replace " + node.displayname + " for " + fix

    def __get_hint(self):
        """Create the self.hint string"""

# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/xml_loader/htm_loader.py
# class HtmLoader(object):
#     """ Load htm.xml information into a Python element"""
# 
#     def __init__(self):
#         self.htms = []
#         self.htms_include = []
#         self.__load_xml(HTM_FILE)
# 
#     def __load_xml(self, file_name):
#         """Load the contents of htm.xml into a Python element"""
#         tree = elemTree.parse(file_name)
#         self.root = tree.getroot()
#         for htm in self.root.iter('function'):
#             self.htms.append(htm.attrib)
#         for htm_header in self.root.iter('header'):
#             self.htms_include.append(htm_header.attrib)
# 
#     def get_functions(self):
#         """Populate a list of HTM names"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get("type") == "function":
#                 self.htms.append(htm.get('target'))
#         return self.htms
# 
#     def get_includes(self):
#         """Populate a list of HTM includes in the header"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get('type') == 'header':
#                 self.htms_include.append(htm.get('target'))
#         return self.htms_include
# 
#     def get_fixes(self):
#         '''Method to populate a list of htm fixes'''
#         suggestion_dict = {}
#         for sysc in self.root.findall('htmapi'):
#             if sysc.get("replacer"):
#                 suggestion_dict[sysc.get("target")] = (sysc.get("replacer"))
#         return suggestion_dict


# Path: ma/checkers/htm_checker.py
from clang.cindex import CursorKind
from ma.checkers.checker import Checker
from ma.xml_loader.htm_loader import HtmLoader


    def get_problem_msg(self):
        return self.problem_msg

    def get_problem_type(self):
        return self.problem_type

    def check_node(self, node):
        if node.kind != CursorKind.CALL_EXPR:
            return False
        if node.displayname in self.htm_functions:
            return True

    def check_include(self, include_name):
        if include_name in self.htm_includes:
            return True

    def get_solution(self, node):
        return self.__create_solution(node)

    def __create_solution(self, node):
        if 'rtmintrin.h' in str(node):
            return "replace rtmintrin.h for htmintrin.h"
        if not isinstance(node, basestring):
            if node.displayname in self.htm_fixes:
                fix = self.htm_fixes[node.displayname]
                return "replace " + node.displayname + " for " + fix

    def __get_hint(self):
        """Create the self.hint string"""

        incl_hint = "\|".join(HtmLoader().get_includes())