示例#1
0
 def __call__(self, decl):
     if self.decl_type is not None:
         if not isinstance(decl, self.decl_type):
             return False
     if self.name is not None:
         if not self.check_name(decl):
             return False
     if self.header_dir is not None:
         if decl.location:
             decl_dir = os.path.abspath(
                 os.path.dirname(decl.location.file_name))
             decl_dir = utils.normalize_path(decl_dir)
             if decl_dir[:len(self.header_dir)] != self.header_dir:
                 return False
         else:
             return False
     if self.header_file is not None:
         if decl.location:
             decl_file = os.path.abspath(decl.location.file_name)
             decl_file = utils.normalize_path(decl_file)
             if decl_file != self.header_file:
                 return False
         else:
             return False
     return True
示例#2
0
 def __call__(self, decl):
     if self.decl_type is not None:
         if not isinstance(decl, self.decl_type):
             return False
     if self.name is not None:
         if not self.check_name(decl):
             return False
     if self.header_dir is not None:
         if decl.location:
             decl_dir = os.path.abspath(
                 os.path.dirname(decl.location.file_name))
             decl_dir = utils.normalize_path(decl_dir)
             if decl_dir[:len(self.header_dir)] != self.header_dir:
                 return False
         else:
             return False
     if self.header_file is not None:
         if decl.location:
             decl_file = os.path.abspath(decl.location.file_name)
             decl_file = utils.normalize_path(decl_file)
             if decl_file != self.header_file:
                 return False
         else:
             return False
     return True
示例#3
0
    def __init__(
            self,
            name=None,
            decl_type=None,
            header_dir=None,
            header_file=None):
        """
        :param decl_type: declaration type to match by. For example
        :class:`enumeration_t`.
        :type decl_type: any class that derives from :class:`declaration_t`
        class

        :param name: declaration name, could be full name.
        :type name: str

        :param header_dir: absolute directory path
        :type header_dir: str

        :param header_file: absolute file path
        :type header_file: str

        """
        # An other option is that pygccxml will create absolute path using
        # os.path.abspath function. But I think this is just wrong, because
        # abspath builds path using current working directory. This behavior
        # is fragile and very difficult to find a bug.
        matcher_base_t.__init__(self)
        self.decl_type = decl_type
        self.__name = None
        self.__opt_is_tmpl_inst = None
        self.__opt_tmpl_name = None
        self.__opt_is_full_name = None
        self.__decl_name_only = None

        # Set the name through the setter.
        self.name = name

        self.header_dir = header_dir
        self.header_file = header_file

        if self.header_dir:
            self.header_dir = utils.normalize_path(self.header_dir)
            if not os.path.isabs(self.header_dir):
                raise RuntimeError(
                    "Path to header directory should be absolute!")

        if self.header_file:
            self.header_file = utils.normalize_path(self.header_file)
            if not os.path.isabs(self.header_file):
                raise RuntimeError("Path to header file should be absolute!")
示例#4
0
    def __init__(self,
                 name=None,
                 decl_type=None,
                 header_dir=None,
                 header_file=None):
        """
        :param decl_type: declaration type to match by. For example
        :class:`enumeration_t`.
        :type decl_type: any class that derives from :class:`declaration_t`
        class

        :param name: declaration name, could be full name.
        :type name: str

        :param header_dir: absolute directory path
        :type header_dir: str

        :param header_file: absolute file path
        :type header_file: str

        """
        # An other option is that pygccxml will create absolute path using
        # os.path.abspath function. But I think this is just wrong, because
        # abspath builds path using current working directory. This behavior
        # is fragile and very difficult to find a bug.
        matcher_base_t.__init__(self)
        self.decl_type = decl_type
        self.__name = None
        self.__opt_is_tmpl_inst = None
        self.__opt_tmpl_name = None
        self.__opt_is_full_name = None
        self.__decl_name_only = None

        # Set the name through the setter.
        self.name = name

        self.header_dir = header_dir
        self.header_file = header_file

        if self.header_dir:
            self.header_dir = utils.normalize_path(self.header_dir)
            if not os.path.isabs(self.header_dir):
                raise RuntimeError(
                    "Path to header directory should be absolute!")

        if self.header_file:
            self.header_file = utils.normalize_path(self.header_file)
            if not os.path.isabs(self.header_file):
                raise RuntimeError("Path to header file should be absolute!")
 def __filter_by_location( self, flatten_decls ):
     for decl in flatten_decls:
         if not decl.location:
             continue
         fpath = pygccxml_utils.normalize_path( decl.location.file_name )
         if pygccxml_utils.contains_parent_dir( fpath, self.__parsed_dirs ):
             continue
         if fpath in self.__parsed_files:
             continue
         found = False
         for pfile in self.__parsed_files:
             if fpath.endswith( pfile ):
                 found = True
                 break
         if not found:
             decl.exclude()
示例#6
0
def is_sub_path(root, some_path):
    root = utils.normalize_path(root)
    some_path = utils.normalize_path(some_path)
    return some_path.startswith(root)
示例#7
0
def is_sub_path(root, some_path):
    root = utils.normalize_path(root)
    some_path = utils.normalize_path(some_path)
    return some_path.startswith(root)