<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vim
import re
import os
import os.path
from .utils import *
from .explorer import *
from .manager import *


#*****************************************************
# TagExplorer
#*****************************************************
class TagExplorer(Explorer):
    def __init__(self):
        self._tag_list = []
        self._file_tags = {}    # a dict with (key, value) = (tag file name, [mtime,taglist])

    def getContent(self, *args, **kwargs):
        return self.getFreshContent(*args, **kwargs)

    def getFreshContent(self, *args, **kwargs):
        has_new_tagfile = False
        has_changed_tagfile = False
        filenames = [name for name in self._file_tags]
        for tagfile in vim.eval("tagfiles()"):
            tagfile = os.path.abspath(tagfile)
            mtime = os.path.getmtime(tagfile)
            if tagfile not in self._file_tags:
                has_new_tagfile = True
                with lfOpen(tagfile, 'r', errors='ignore') as f:
                    self._file_tags[tagfile] = [mtime, f.readlines()[6:]]
            else:
                filenames.remove(tagfile)
                if mtime != self._file_tags[tagfile][0]:
                    has_changed_tagfile = True
                    with lfOpen(tagfile, 'r', errors='ignore') as f:
                        self._file_tags[tagfile] = [mtime, f.readlines()[6:]]

        for name in filenames:
            del self._file_tags[name]

        if has_new_tagfile == False and has_changed_tagfile == False:
            return self._tag_list
        else:<commit_msg>fix issue #381<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vim
import re
import os
import os.path
from .utils import *
from .explorer import *
from .manager import *


#*****************************************************
# TagExplorer
#*****************************************************
class TagExplorer(Explorer):
    def __init__(self):
        self._tag_list = []
        self._file_tags = {}    # a dict with (key, value) = (tag file name, [mtime,taglist])

    def getContent(self, *args, **kwargs):
        return self.getFreshContent(*args, **kwargs)

    def getFreshContent(self, *args, **kwargs):
        has_new_tagfile = False
        has_changed_tagfile = False
        filenames = [name for name in self._file_tags]
        for tagfile in vim.eval("tagfiles()"):
            tagfile = os.path.abspath(tagfile)
            mtime = os.path.getmtime(tagfile)
            if tagfile not in self._file_tags:
                has_new_tagfile = True
                with lfOpen(tagfile, 'r', encoding='utf-8', errors='ignore') as f:
                    self._file_tags[tagfile] = [mtime, f.readlines()[6:]]
            else:
                filenames.remove(tagfile)
                if mtime != self._file_tags[tagfile][0]:
                    has_changed_tagfile = True
                    with lfOpen(tagfile, 'r', encoding='utf-8', errors='ignore') as f:
                        self._file_tags[tagfile] = [mtime, f.readlines()[6:]]

        for name in filenames:
            del self._file_tags[name]

        if has_new_tagfile == False and has_changed_tagfile == False:
            return self._tag_list
        else:
{'fraction_non_alphanumeric': 0.1728131667174642, 'fraction_numerical': 0.003962206644315757, 'mean_word_length': 2.3185035389282103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5313533', 'n_tokens_mistral': 998, 'n_tokens_neox': 949, 'n_words': 229}