def add_object_to_gitignore()

in pantri/scripts/lib/pantri.py [0:0]


    def add_object_to_gitignore(self, obj):
        """
        Determine extension or full path to add to gitignore
        """

        # TODO making a lot of assumptions when making this list. Need to improve
        # Build list of upload-able items to add to gitignore.
        rel_obj_path = os.path.relpath(obj, self.git_path)
        filename, file_ext = os.path.splitext(rel_obj_path)

        # Add extension or full path to gitignore
        if file_ext and re.match("^.[a-z]+$", file_ext, re.IGNORECASE):
            ext = "*" + file_ext.lower()
            if ext not in self.gitignore:
                self.gitignore.append(ext)
        else:
            if rel_obj_path not in self.gitignore:
                self.gitignore.append(rel_obj_path)