<commit_before># -*- coding: utf8 -*-
"""
Separate process for cache flushing

@author: <NAME>
"""

import os
from time import time, sleep
import argparse
import dedupsqlfs
import signal

class SimpleCacheFlusher(object):

    sleep_interval = 0.01
    flush_internal = 1

    flush_filepath = None

    mount_poing = None

    _stop_flag = False

    def start(self):
        if not self.mount_poing:
            raise ValueError("Setup mouht_poing value before thread start!")

        if not os.path.isdir(self.mount_poing):
            raise ValueError("Value of mouht_poing must be existing directory path!")

        self.flush_filepath = os.path.join(self.mount_poing, '.dedupsqlfs.io')
        self._stop_flag = False

    def _do_flush(self):

        if not os.path.exists(self.mount_poing):
            return

        if not os.path.isdir(self.mount_poing):
            return

        if not os.path.ismount(self.mount_poing):
            return

        file_io = open(self.flush_filepath, 'w+')
        file_io.seek(0, 0)
        file_io.write("Do not remove!\n")
        file_io.flush()
        file_io.close()


    def do_stop(self):
        self._stop_flag = True

    def run(self):

        last_flush = time()
        while not self._stop_flag:

            now = time()

            if now - last_flush < self.flush_internal:
                sleep(self.sleep_interval)
                continue

            self._do_flush()

            last_flush = now

            pass

        self._stop_flag = False

        return 0


flusher = SimpleCacheFlusher()


def main():
    global flusher

    parser = argparse.ArgumentParser(
        prog="%s/%s cache_flusher" % (dedupsqlfs.__name__, dedupsqlfs.__version__,),
        conflict_handler="resolve")

    # Register some custom command line options with the option parser.
    parser.add_argument('-h', '--help', action='help', help="show this help message and exit")

    parser.add_argument('mountpoint', help="specify mount point")

    args = parser.parse_args()

    flusher.mount_poing = args.mountpoint
    flusher.start()

    signal.signal(signal.SIGINT, flusher.do_stop)
    signal.signal(signal.SIGTERM, flusher.do_stop)

    return flusher.run()

# vim: ts=4 sw=4 et<commit_msg>Fix typo<commit_after># -*- coding: utf8 -*-
"""
Separate process for cache flushing

@author: <NAME>
"""

import os
from time import time, sleep
import argparse
import dedupsqlfs
import signal

class SimpleCacheFlusher(object):

    sleep_interval = 0.01
    flush_internal = 1

    flush_filepath = None

    mount_point = None

    _stop_flag = False

    def start(self):
        if not self.mount_point:
            raise ValueError("Setup mouht_point value before thread start!")

        if not os.path.isdir(self.mount_point):
            raise ValueError("Value of mouht_point must be existing directory path!")

        self.flush_filepath = os.path.join(self.mount_point, '.dedupsqlfs.io')
        self._stop_flag = False

    def _do_flush(self):

        if not os.path.exists(self.mount_point):
            return

        if not os.path.isdir(self.mount_point):
            return

        if not os.path.ismount(self.mount_point):
            return

        file_io = open(self.flush_filepath, 'w+')
        file_io.seek(0, 0)
        file_io.write("Do not remove!\n")
        file_io.flush()
        file_io.close()


    def do_stop(self):
        self._stop_flag = True

    def run(self):

        last_flush = time()
        while not self._stop_flag:

            now = time()

            if now - last_flush < self.flush_internal:
                sleep(self.sleep_interval)
                continue

            self._do_flush()

            last_flush = now

            pass

        self._stop_flag = False

        return 0


flusher = SimpleCacheFlusher()


def main():
    global flusher

    parser = argparse.ArgumentParser(
        prog="%s/%s cache_flusher" % (dedupsqlfs.__name__, dedupsqlfs.__version__,),
        conflict_handler="resolve")

    # Register some custom command line options with the option parser.
    parser.add_argument('-h', '--help', action='help', help="show this help message and exit")

    parser.add_argument('mountpoint', help="specify mount point")

    args = parser.parse_args()

    flusher.mount_point = args.mountpoint
    flusher.start()

    signal.signal(signal.SIGINT, flusher.do_stop)
    signal.signal(signal.SIGTERM, flusher.do_stop)

    return flusher.run()

# vim: ts=4 sw=4 et
{'fraction_non_alphanumeric': 0.10046470458065944, 'fraction_numerical': 0.004425757911042266, 'mean_word_length': 2.3580980683506687, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2739083', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1378, 'n_words': 332}