<commit_before>#!/ms/dist/python/PROJ/core/2.5.0/bin/python
# ex: set expandtab softtabstop=4 shiftwidth=4: -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# Copyright (C) 2008 <NAME>
""" Remove any old entries in the install tree, used by Makefile."""

import os
import sys

def clean_old(installdir):
    if not os.path.isdir(installdir):
        print >>sys.stderr, "Warning: '%s' is not a directory, not searching for and removing stale files." % installdir
        return
    src = os.path.realpath(os.path.dirname(__file__))
    for (dirpath, dirnames, filenames) in os.walk(installdir):
        relative_dirpath = dirpath.replace(installdir, '', 1)
        for f in filenames:
            if f.endswith('.pyc'):
                continue
            if not os.path.exists(os.path.join(src, relative_dirpath, f)):
                old_file = os.path.join(dirpath, f)
                print "Removing %s" % old_file
                os.remove(old_file)
                if old_file.endswith('.py'):
                    old_pyc = old_file + 'c'
                    if os.path.exists(old_pyc):
                        print "Removing %s" % old_pyc
                        os.remove(old_pyc)

if __name__ == '__main__':
    if len(sys.argv) > 2:
        print >>sys.stderr, "Takes only one argument, the install directory to prune."
        sys.exit(1)
    if len(sys.argv) < 2:
        print >>sys.stderr, "The install directory to prune is required."
        sys.exit(1)
    clean_old(sys.argv[1])
<commit_msg>Fix to regen dropin.cache for twistd on `make install` only as needed.<commit_after>#!/ms/dist/python/PROJ/core/2.5.0/bin/python
# ex: set expandtab softtabstop=4 shiftwidth=4: -*- cpy-indent-level: 4; indent-tabs-mode: nil -*-
# Copyright (C) 2008 <NAME>
""" Remove any old entries in the install tree, used by Makefile."""

import os
import sys

def clean_old(installdir):
    if not os.path.isdir(installdir):
        print >>sys.stderr, "Warning: '%s' is not a directory, not searching for and removing stale files." % installdir
        return
    src = os.path.realpath(os.path.dirname(__file__))
    for (dirpath, dirnames, filenames) in os.walk(installdir):
        relative_dirpath = dirpath.replace(installdir, '', 1)
        for f in filenames:
            # Can't compare with src, since we only have .py files there.
            # Assume that the .pyc will either be removed because its
            # corresponding .py is removed, or rebuilt as necessary.
            if f.endswith('.pyc'):
                continue
            # This will be updated as needed, and has no corresponding
            # file in src.
            if f == 'dropin.cache':
                continue
            if not os.path.exists(os.path.join(src, relative_dirpath, f)):
                old_file = os.path.join(dirpath, f)
                print "Removing %s" % old_file
                os.remove(old_file)
                if old_file.endswith('.py'):
                    old_pyc = old_file + 'c'
                    if os.path.exists(old_pyc):
                        print "Removing %s" % old_pyc
                        os.remove(old_pyc)

if __name__ == '__main__':
    if len(sys.argv) > 2:
        print >>sys.stderr, "Takes only one argument, the install directory to prune."
        sys.exit(1)
    if len(sys.argv) < 2:
        print >>sys.stderr, "The install directory to prune is required."
        sys.exit(1)
    clean_old(sys.argv[1])

{'fraction_non_alphanumeric': 0.11613090066608746, 'fraction_numerical': 0.00926730379380249, 'mean_word_length': 2.0922112802148614, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '7171674', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1066, 'n_words': 309}